{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# useful to autoreload the module without restarting the kernel\n", "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from mppi import InputFiles as I, Calculators as C, Utilities as U\n", "from mppi.Calculators import Tools" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "omp = 1\n", "mpi = 8" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial for the YamboCalculator class" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This tutorial describes the usage of the YamboCalculator class, that manages the run of (many) calculations in\n", "parallel with the Yambo package." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Perform an Hartree-Fock computation for Silicon" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "__Follow the tutorial for the QeCalculator to produce the .save folder needed to generate the yambo SAVE.__\n", "\n", "The first step needed to perform a Yambo computation is to generate the SAVE folder from a QuantumESPRESSO\n", "computation and to init the Yambo run_dir folder. \n", "\n", "The mppi.Calculators.Tools module has a functions that perform these tasks" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "input_dir = 'QeCalculator_test/outdir_nscf/bands_8.save'" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SAVE folder YamboCalculator_test/SAVE already present. No operations performed.\n" ] } ], "source": [ "run_dir = 'YamboCalculator_test'\n", "Tools.init_yambo_dir(yambo_dir=run_dir,input_dir=input_dir,overwrite_if_found=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now the YamboInput class can create the yambo input object.\n", "\n", "We consider a HF computation" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'args': 'yambo -x -V rl',\n", " 'folder': 'YamboCalculator_test',\n", " 'filename': 'yambo.in',\n", " 'arguments': ['HF_and_locXC'],\n", " 'variables': {'FFTGvecs': [2133.0, 'RL'],\n", " 'SE_Threads': [0.0, ''],\n", " 'EXXRLvcs': [3000.0, 'mHa'],\n", " 'VXCRLvcs': [13107.0, 'RL'],\n", " 'QPkrange': [[1, 2, 1, 8], '']}}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "exx = 3.0 # Hartree\n", "inp = I.YamboInput(args='yambo -x -V rl',folder=run_dir)\n", "inp.set_kRange(1,2) #restrict the analysis to the first two kpoints\n", "inp['variables']['EXXRLvcs'] = [exx*1e3,'mHa']\n", "name = 'hf_exx'+str(exx)\n", "jobname = 'hf_job_exx'+str(exx)\n", "inp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To run the computation we create an istance of YamboCalculator. This object behaves almost exactly as\n", "the QeCalculator for what concern the user interface.\n", "\n", "The first step is to create an istance of the RunRules class that contains the options of the calculator" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'scheduler': 'direct', 'mpi': 8, 'omp_num_threads': 1}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rr = C.RunRules(mpi=mpi,omp_num_threads=omp)\n", "rr" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[0;31mInit signature:\u001b[0m\n", "\u001b[0mC\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mYamboCalculator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mrunRules\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mexecutable\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'yambo'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mskip\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mclean_restart\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mdry_run\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mwait_end_run\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mactivate_BeeOND\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mverbose\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0mfatlog\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mDocstring:\u001b[0m \n", "Perform a Yambo calculation. The parameters used to define the parellelization\n", "strategy are provided in the `runRules` object.\n", "\n", "Parameters:\n", " runRulues (:class:`RunRules`) : instance of the :class:`RunRules` class\n", " executable (:py:class:`string`) : set the executable (yambo, ypp, yambo_rt, ...) of the Yambo package\n", " skip (:py:class:`bool`) : if True evaluate if the computation can be skipped. This is done by checking that the\n", " report file built by yambo exists and contains the string `game_over`, defined as a data member of this class\n", " clean_restart (:py:class:`bool`) : if True delete the folder with the output files and the database before running the computation\n", " dry_run (:py:class:`bool`) : with this option enabled the calculator setup the calculations and write the script\n", " for submitting the job, but the computations are not run\n", " wait_end_run (:py:class:`bool`) : with this option disabled the run method does not wait the end of the run.\n", " This option may be useful for interacting with the code in particular in _asincronous_ computation managed\n", " by the slurm scheduler\n", " activate_BeeOND (:py:class:`bool`) : if True set I/O of the run in the BeeOND_dir created by the slurm scheduler.\n", " The value of the ``BeeOND_dir`` is written as a data member of the class and can be modified if needed\n", " verbose (:py:class:`bool`) : set the amount of information provided on terminal\n", " fatlog (:py:class:`bool`) : if True set the `-fatlog` key to provide more information in the report file\n", " kwargs : other parameters that are stored in the _global_options dictionary\n", "\n", " Computations are performed in the folder specified by the ``run_dir`` parameter. The ``name`` parameter is\n", " used as name of the yambo input and as the name of the folder where yambo writes the o- `output` files.\n", " The ``jobname`` parameter is the name of the folder where yambo writes the .ndb databases. If this parameter\n", " is not provided in the run method the assumption jobname=name is made by the calculator.\n", "\n", " Example:\n", " >>> rr = RunRules(scheduler='slurm',ntasks_per_node=4,memory='124GB')\n", " >>> code = YamboCalculator(rr,executable='yambo',skip=True,verbose=True)\n", " >>> code.run(input = ..., run_dir = ...,name = ...,jobname = ..., **kwargs)\n", "\n", " When the run method is called the class runs the command:\n", " cd run_dir ; `mpirun command` executable_name -F name.in -J jobname -C name - O out_dir\n", "\n", " where the arguments of the run method are:\n", "\n", "Args:\n", " run_dir (:py:class:`string`) : the folder in which the simulation is performed\n", " input (:py:class:`string`) : instance of the :class:`YamboInput` class\n", " that define the input objects\n", " name (:py:class:`string`) : string with the names associated to the input file (without extension).\n", " This string is used also as the name of the folder in which results are written (argument of the -C option of yambo) as\n", " well as a part of the name of the output files\n", " jobname (:py:class:`list` or :py:class:`string`) : string (or list of strings) with the value(s) of the jobname folders\n", " (argument of the -J option of yambo). The first element is the folder name, where yambo writes the database.\n", " The other values (if provided) are the folders where yambo seeks for pre existing databases. All the elements of the\n", " list are assumed to be located in the ``run_dir`` of the calculator. If this variable is not specified the value of\n", " name is attributed to jobname\n", " out_dir (:py:class:`string`) : position of the folder in which the $jobname folder is located. This parameter\n", " is automatically set by the calculator the value of ``BeeOND_dir`` if the option `activate_BeeOND` is enabled.\n", " Otherwise all the folders are written in the ``run_dir``\n", " kwargs : other parameters that are stored in the run_options dictionary\n", "\u001b[0;31mFile:\u001b[0m ~/Applications/MPPI/mppi/Calculators/YamboCalculator.py\n", "\u001b[0;31mType:\u001b[0m type\n", "\u001b[0;31mSubclasses:\u001b[0m \n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "C.YamboCalculator?" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initialize a Yambo calculator with scheduler direct\n" ] }, { "data": { "text/plain": [ "{'scheduler': 'direct',\n", " 'mpi': 8,\n", " 'omp_num_threads': 1,\n", " 'executable': 'yambo',\n", " 'skip': True,\n", " 'clean_restart': True,\n", " 'dry_run': False,\n", " 'wait_end_run': True,\n", " 'activate_BeeOND': False,\n", " 'verbose': True,\n", " 'fatlog': False}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "code = C.YamboCalculator(rr)\n", "code.global_options()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The structure of the folder in which yambo writes its results is governed by the name and jobname \n", "variables. It is possible to provide only the name variable. \n", "\n", "The effect of this choice can be seen in the command string executed by the calculator." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run command: mpirun -np 8 yambo -F hf_exx3.0.in -J hf_job_exx3.0 -C hf_exx3.0\n", "computation hf_exx3.0 is running...\n", "computation hf_exx3.0 ended\n", "Run performed in 13s\n" ] }, { "data": { "text/plain": [ "{'output': {'hf': 'YamboCalculator_test/hf_exx3.0/o-hf_job_exx3.0.hf'},\n", " 'report': 'YamboCalculator_test/hf_exx3.0/r-hf_job_exx3.0_HF_and_locXC',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'HF_and_locXC': 'YamboCalculator_test/hf_job_exx3.0/ndb.HF_and_locXC'}" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(run_dir=run_dir,input=inp,name=name,jobname=jobname)\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this case yambo create in the ``run_dir`` the hf_exx3.0 folder that contains the o- _output_ files and the hf_job_exx3.0 that contains the .ndb databases.\n", "Result is a dictionary that contain the names of the o- file and the databases created by yambo.\n", "\n", "Instead, if we only provide the name parameter all the files are written by yambo in the `name` folder" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run command: mpirun -np 8 yambo -F hf_exx3.0_only.in -J hf_exx3.0_only -C hf_exx3.0_only\n", "computation hf_exx3.0_only is running...\n", "computation hf_exx3.0_only ended\n", "Run performed in 13s\n" ] }, { "data": { "text/plain": [ "{'output': {'hf': 'YamboCalculator_test/hf_exx3.0_only/o-hf_exx3.0_only.hf'},\n", " 'report': 'YamboCalculator_test/hf_exx3.0_only/r-hf_exx3.0_only_HF_and_locXC',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'HF_and_locXC': 'YamboCalculator_test/hf_exx3.0_only/ndb.HF_and_locXC'}" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(run_dir=run_dir,input=inp,name=name+'_only')\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Usage of the skip parameter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we repeat a calculation that has been already performed and skip = True the class skip its computation, for instance" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Skip the run of hf_exx3.0\n" ] }, { "data": { "text/plain": [ "{'output': {'hf': 'YamboCalculator_test/hf_exx3.0/o-hf_job_exx3.0.hf'},\n", " 'report': 'YamboCalculator_test/hf_exx3.0/r-hf_job_exx3.0_HF_and_locXC',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'HF_and_locXC': 'YamboCalculator_test/hf_job_exx3.0/ndb.HF_and_locXC'}" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(run_dir=run_dir,input=inp,name=name,jobname=jobname,skip=True)\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Instead, if skip is False the folders with the results are erased and the computation run again" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "delete folder: YamboCalculator_test/hf_exx3.0_only\n", "run command: mpirun -np 8 yambo -F hf_exx3.0_only.in -J hf_exx3.0_only -C hf_exx3.0_only\n", "computation hf_exx3.0_only is running...\n", "computation hf_exx3.0_only ended\n", "Run performed in 13s\n" ] }, { "data": { "text/plain": [ "{'output': {'hf': 'YamboCalculator_test/hf_exx3.0_only/o-hf_exx3.0_only.hf'},\n", " 'report': 'YamboCalculator_test/hf_exx3.0_only/r-hf_exx3.0_only_HF_and_locXC',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'HF_and_locXC': 'YamboCalculator_test/hf_exx3.0_only/ndb.HF_and_locXC'}" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(run_dir=run_dir,input=inp,name=name+'_only',skip=False)\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The clean of the results folder can be suppressed with the option clean_restart=False" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run performed starting from existing results\n", "run command: mpirun -np 8 yambo -F hf_exx3.0_only.in -J hf_exx3.0_only -C hf_exx3.0_only\n", "computation hf_exx3.0_only is running...\n", "computation hf_exx3.0_only ended\n" ] }, { "data": { "text/plain": [ "{'output': {'hf': 'YamboCalculator_test/hf_exx3.0_only/o-hf_exx3.0_only.hf_01'},\n", " 'report': 'YamboCalculator_test/hf_exx3.0_only/r-hf_exx3.0_only_HF_and_locXC_01',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'HF_and_locXC': 'YamboCalculator_test/hf_exx3.0_only/ndb.HF_and_locXC'}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(run_dir=run_dir,input=inp,name=name+'_only',skip=False,clean_restart=False)\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "__In this case output folder contains several replica of the report and of the output files.__\n", "\n", "__The class ensures that the files associated to the last run are used to build the results dictionary.__" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Test of the slurm scheduler" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If the `slurm` scheduler is chosen the calculator prepare the slurm script and submit it. \n", "\n", "In this case the mpi variable is not used and the calculator is set using the `ntasks_per_node`,`nodes`\n", "and `cpus_per_task variables`, apart from the `omp_num_threads`." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'scheduler': 'slurm',\n", " 'nodes': 1,\n", " 'ntasks_per_node': 4,\n", " 'cpus_per_task': 1,\n", " 'omp_num_threads': 2,\n", " 'gpus_per_node': None,\n", " 'memory': None,\n", " 'time': None,\n", " 'partition': None,\n", " 'account': None,\n", " 'qos': None,\n", " 'map_by': None,\n", " 'pe': 1,\n", " 'rank_by': None}" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rr = C.RunRules(scheduler='slurm',ntasks_per_node=4,omp_num_threads=2)\n", "rr" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initialize a Yambo calculator with scheduler slurm\n" ] }, { "data": { "text/plain": [ "{'scheduler': 'slurm',\n", " 'nodes': 1,\n", " 'ntasks_per_node': 4,\n", " 'cpus_per_task': 1,\n", " 'omp_num_threads': 2,\n", " 'gpus_per_node': None,\n", " 'memory': None,\n", " 'time': None,\n", " 'partition': None,\n", " 'account': None,\n", " 'qos': None,\n", " 'map_by': None,\n", " 'pe': 1,\n", " 'rank_by': None,\n", " 'executable': 'yambo',\n", " 'skip': True,\n", " 'clean_restart': True,\n", " 'dry_run': False,\n", " 'wait_end_run': True,\n", " 'activate_BeeOND': False,\n", " 'verbose': True,\n", " 'fatlog': False}" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "code = C.YamboCalculator(rr)\n", "code.global_options()" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run performed starting from existing results\n", "run command: mpirun -np 4 yambo -F hf_exx3.0.in -J hf_job_exx3.0 -C hf_exx3.0\n", "Dry_run option active. Script not submitted\n", "The wait_end_run is False or the dry_run option is active. The calculator proceedes to the postprocessing\n", "Run performed in 13s\n" ] }, { "data": { "text/plain": [ "{'output': {'hf': 'YamboCalculator_test/hf_exx3.0/o-hf_job_exx3.0.hf'},\n", " 'report': 'YamboCalculator_test/hf_exx3.0/r-hf_job_exx3.0_HF_and_locXC',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'HF_and_locXC': 'YamboCalculator_test/hf_job_exx3.0/ndb.HF_and_locXC'}" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results = code.run(run_dir=run_dir,input=inp,name=name,jobname=jobname,dry_run=True,skip=False,clean_restart=False)\n", "results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The slurm script is written in the run_dir. The execution of the run requires that the slurm scheduler is installed." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Perform a GW computation for Silicon" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We make usage of the YamboCalculator to perform a different yambo computation. In this way we control\n", "how this class manage the output files and the ndb database in various cases." ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initialize a Yambo calculator with scheduler direct\n" ] } ], "source": [ "rr = C.RunRules(mpi=mpi,omp_num_threads=omp)\n", "code = C.YamboCalculator(rr)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "inp = I.YamboInput(args='yambo -d -k hartee -g n -p p -V qp',folder=run_dir)\n", "inp.set_kRange(1,2)\n", "#inp" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run command: mpirun -np 8 yambo -F qp_test1.in -J qp_test1 -C qp_test1\n", "computation qp_test1 is running...\n", "computation qp_test1 ended\n", "Run performed in 18s\n" ] }, { "data": { "text/plain": [ "{'output': {'qp': 'YamboCalculator_test/qp_test1/o-qp_test1.qp'},\n", " 'report': 'YamboCalculator_test/qp_test1/r-qp_test1_HF_and_locXC_gw0_dyson_em1d_ppa_el_el_corr',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'QP': 'YamboCalculator_test/qp_test1/ndb.QP',\n", " 'HF_and_locXC': 'YamboCalculator_test/qp_test1/ndb.HF_and_locXC',\n", " 'dipoles': 'YamboCalculator_test/qp_test1/ndb.dipoles',\n", " 'pp': 'YamboCalculator_test/qp_test1/ndb.pp'}" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(input=inp,run_dir=run_dir,name='qp_test1')\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Perform the same computation but specify also a jobname " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run command: mpirun -np 8 yambo -F qp_test2.in -J qp_job_test2 -C qp_test2\n", "computation qp_test2 is running...\n", "computation qp_test2 ended\n", "Run performed in 17s\n" ] }, { "data": { "text/plain": [ "{'output': {'qp': 'YamboCalculator_test/qp_test2/o-qp_job_test2.qp'},\n", " 'report': 'YamboCalculator_test/qp_test2/r-qp_job_test2_HF_and_locXC_gw0_dyson_em1d_ppa_el_el_corr',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'QP': 'YamboCalculator_test/qp_job_test2/ndb.QP',\n", " 'HF_and_locXC': 'YamboCalculator_test/qp_job_test2/ndb.HF_and_locXC',\n", " 'dipoles': 'YamboCalculator_test/qp_job_test2/ndb.dipoles',\n", " 'pp': 'YamboCalculator_test/qp_job_test2/ndb.pp'}" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(input = inp, run_dir = run_dir, name='qp_test2', jobname = 'qp_job_test2')\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Test of the ExtendOut option in the input file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The ExtendOut option enables the writing of all the variables in the output files of Yambo. \n", "This feature has no effect for an HF computation and we test for a QP one:" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "inp = I.YamboInput(args='yambo -d -k hartee -g n -p p -V qp',folder=run_dir)\n", "inp.set_kRange(1,2)\n", "inp.set_extendOut()\n", "#inp" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run command: mpirun -np 8 yambo -F qp_test_ExtendOut.in -J qp_test_ExtendOut -C qp_test_ExtendOut\n", "computation qp_test_ExtendOut is running...\n", "computation qp_test_ExtendOut ended\n", "Run performed in 16s\n" ] }, { "data": { "text/plain": [ "{'output': {'qp': 'YamboCalculator_test/qp_test_ExtendOut/o-qp_test_ExtendOut.qp'},\n", " 'report': 'YamboCalculator_test/qp_test_ExtendOut/r-qp_test_ExtendOut_HF_and_locXC_gw0_dyson_em1d_ppa_el_el_corr',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1',\n", " 'QP': 'YamboCalculator_test/qp_test_ExtendOut/ndb.QP',\n", " 'HF_and_locXC': 'YamboCalculator_test/qp_test_ExtendOut/ndb.HF_and_locXC',\n", " 'dipoles': 'YamboCalculator_test/qp_test_ExtendOut/ndb.dipoles',\n", " 'pp': 'YamboCalculator_test/qp_test_ExtendOut/ndb.pp'}" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(input = inp, run_dir = run_dir,name='qp_test_ExtendOut')\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "you can check that the o- files contain more information. This feature is managed by the YamboParser class of the package." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Perform a ypp computation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The YamboCalculator class can manage also ypp computation.\n", "\n", "Let's see an example by performing a band calculation along a path" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'args': 'ypp -s b',\n", " 'folder': 'YamboCalculator_test',\n", " 'filename': 'ypp.in',\n", " 'arguments': [],\n", " 'variables': {'INTERP_Shell_Fac': [20.0, ''],\n", " 'INTERP_NofNN': [1.0, ''],\n", " 'OutputAlat': [0.0, ''],\n", " 'BANDS_steps': [10.0, ''],\n", " 'PROJECT_mode': 'none',\n", " 'INTERP_mode': 'NN',\n", " 'cooIn': 'rlu',\n", " 'cooOut': 'rlu',\n", " 'CIRCUIT_E_DB_path': 'none',\n", " 'BANDS_bands': [[1, 8], '']}}" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "inp = I.YamboInput(args='ypp -s b',folder=run_dir,filename='ypp.in') \n", "inp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We define a calculator for ypp. This calculation requires 1 mpirun (see yambo for further information)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Initialize a Yambo calculator with scheduler direct\n" ] }, { "data": { "text/plain": [ "{'scheduler': 'direct',\n", " 'mpi': 1,\n", " 'omp_num_threads': 1,\n", " 'executable': 'ypp',\n", " 'skip': True,\n", " 'clean_restart': True,\n", " 'dry_run': False,\n", " 'wait_end_run': True,\n", " 'activate_BeeOND': False,\n", " 'verbose': True,\n", " 'fatlog': False}" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rr['mpi']=1\n", "code = C.YamboCalculator(rr,executable='ypp')\n", "code.global_options()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set the input parameter to perform the band computation along a path" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "# in alat\n", "G = [0.,0.,0.]\n", "X = [1.,0.,0.]\n", "L = [0.5,0.5,0.5]\n", "K = [1.0,0.5,0.]\n", "path = [L,G,X,K,G]\n", "\n", "band_range = [2,5]\n", "bands_step = 30" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'args': 'ypp -s b',\n", " 'folder': 'YamboCalculator_test',\n", " 'filename': 'ypp.in',\n", " 'arguments': [],\n", " 'variables': {'INTERP_Shell_Fac': [20.0, ''],\n", " 'INTERP_NofNN': [1.0, ''],\n", " 'OutputAlat': [0.0, ''],\n", " 'BANDS_steps': [30, ''],\n", " 'PROJECT_mode': 'none',\n", " 'INTERP_mode': 'NN',\n", " 'cooIn': 'alat',\n", " 'cooOut': 'alat',\n", " 'CIRCUIT_E_DB_path': 'none',\n", " 'BANDS_bands': [[2, 5], ''],\n", " 'BANDS_kpts': [[[0.5, 0.5, 0.5],\n", " [0.0, 0.0, 0.0],\n", " [1.0, 0.0, 0.0],\n", " [1.0, 0.5, 0.0],\n", " [0.0, 0.0, 0.0]],\n", " '']}}" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# scissor\n", "# inp['variables']['GfnQP_E'] = [1.0,1.0,1.0]\n", "\n", "# band structure\n", "# Some methods that perform these operation can be added in the YamboInput class\n", "inp['variables']['BANDS_steps'] = [bands_step,'']\n", "inp['variables']['BANDS_bands'] = [band_range,'']\n", "inp['variables']['BANDS_kpts'] = [path,'']\n", "inp['variables']['cooIn'] = 'alat'\n", "inp['variables']['cooOut'] = 'alat'\n", "inp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Also for these kind of computation we can use the skip and the clean_restart options" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "run performed starting from existing results\n", "run command: mpirun -np 1 ypp -F bands_test1.in -J bands_test1 -C bands_test1\n", "computation bands_test1 is running...\n", "computation bands_test1 ended\n" ] }, { "data": { "text/plain": [ "{'output': {'bands_interpolated': 'YamboCalculator_test/bands_test1/o-bands_test1.bands_interpolated'},\n", " 'report': 'YamboCalculator_test/bands_test1/r-bands_test1_electrons_bnds',\n", " 'dft': 'YamboCalculator_test/SAVE/ns.db1'}" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = code.run(run_dir=run_dir,input=inp,name='bands_test1',skip=False,clean_restart=False)\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this case the report does not contains the `time_profile` string so the simulation time is not provided. \n", "\n", "Result can be parsed using the YamboParser class of this package." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" } }, "nbformat": 4, "nbformat_minor": 4 }