{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Back to the main [Index](index.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Factory functions\n", "[[back to top](#top)]\n", "\n", "Abipy provides factory functions to build input files for typical calculations.\n", "These functions return `AbinitInput` or `MultiDataset` objects, depending\n", "on the number of steps required by the calculation.\n", "\n", "One can use the factories to generate automatically input files or\n", "call these functions inside python code to build workflows for high-throughput applications.\n", "Note that the default values do not always correspond to the default behaviour of Abinit.\n", "In particular, the majority of the factory functions construct input files \n", "for **spin-polarized calculations** (`nsppol=2`) with a **Fermi-Dirac** occupation scheme and \n", "a physical temperature of **0.1 eV**. \n", "It is always possible to change the default behaviour either\n", "by passing these options to the factory function or by changing the objects returned by the factory.\n", "\n", "Also note that the factory functions do not use `get*` or `ird*` variables to connect the different \n", "steps. Client code is in charge of connecting the different parts.\n", "For a command line interface, use the `abinp.py` script." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from __future__ import division, print_function, unicode_literals\n", "\n", "import os\n", "import warnings\n", "warnings.filterwarnings(\"ignore\") # to get rid of deprecation warnings\n", "\n", "import abipy.data as abidata\n", "import abipy.abilab as abilab\n", "abilab.enable_notebook() # This line tells AbiPy we are running inside a notebook\n", "from abipy.abilab import AbinitInput" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Ground-state calculation\n", "\n", "Let us generate an input file for a standard GS calculation for silicon in which \n", "the structure is read from an external CIF file:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "############################################################################################
# SECTION: basic
############################################################################################
# <Energy CUToff>
ecut 8
# <Number of Grid points for K PoinTs generation>
ngkpt 8 8 8
# <SHIFT for K points>
shiftk 0.5 0.5 0.5
# <Number of SHIFTs for K point grids>
nshiftk 1
# <KPoinTs OPTion>
kptopt 1
# <Number of SPin POLarization>
nsppol 1
# <Number of BANDs>
nband 8
# <TOLerance on the potential V(r) ReSidual>
tolvrs 1e-08
############################################################################################
# SECTION: gstate
############################################################################################
# <CHecK SYMmetry BREAKing>
chksymbreak 0
# <Number of SPINORial components of the wavefunctions>
nspinor 1
# <Number of SPin-DENsity components>
nspden 1
# <CHARGE>
charge 0.0
############################################################################################
# STRUCTURE
############################################################################################
# <Number of ATOMs>
natom 2
# <Number of TYPes of AToms>
ntypat 1
# <TYPe of AToms>
typat 1 1
# <charge -Z- of the NUCLeus>
znucl 14
# <vectors (X) of atom positions in REDuced coordinates>
xred
0.0000000000 0.0000000000 0.0000000000
0.2500000000 0.2500000000 0.2500000000
# <CELL lattice vector scaling>
acell 1.0 1.0 1.0
# <Real space PRIMitive translations>
rprim
6.3285005272 0.0000000000 3.6537614829
2.1095001757 5.9665675167 3.6537614829
0.0000000000 0.0000000000 7.3075229659" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "si_cif = abidata.cif_file(\"si.cif\")\n", "pseudos = os.path.join(abidata.pseudo_dir, \"14si.pspnc\")\n", "\n", "# Build input for GS calculation (unpolarized, no smearing, 1000 k-points per reciprocal atom) \n", "# ecut must be specified because this pseudopotential does not provide hints for ecut.\n", "# kppa stands for k-point per reciprocal atom.\n", "gs_inp = abilab.gs_input(\n", " si_cif, pseudos,\n", " kppa=1000, ecut=8, spin_mode=\"unpolarized\", smearing=None) # change default\n", "\n", "gs_inp.set_mnemonics(True)\n", "gs_inp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Input variables for band structure calculation + DOS\n", "\n", "A slightly more complicated example:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "code_folding": [], "run_control": { "marked": true } }, "outputs": [ { "data": { "text/html": [ "ndtset 3
############################################################################################
### Global Variables.
############################################################################################
nspinor 1
nsppol 1

ecut 8

nspden 1
charge 0.0
############################################################################################
# STRUCTURE
############################################################################################
natom 2
ntypat 1
typat 1 1
znucl 14
xred
0.0000000000 0.0000000000 0.0000000000
0.2500000000 0.2500000000 0.2500000000
acell 1.0 1.0 1.0
rprim
6.3285005272 0.0000000000 3.6537614829
2.1095001757 5.9665675167 3.6537614829
0.0000000000 0.0000000000 7.3075229659

#################
### DATASET 1 ###
#################
############################################################################################
# SECTION: basic
############################################################################################
ngkpt1 8 8 8
shiftk1 0.5 0.5 0.5
nshiftk1 1
kptopt1 1
nband1 8
tolvrs1 1e-08
############################################################################################
# SECTION: gstate
############################################################################################
chksymbreak1 0


#################
### DATASET 2 ###
#################
############################################################################################
# SECTION: basic
############################################################################################
kptopt2 -11
nband2 18
iscf2 -2
tolwfr2 1e-17
############################################################################################
# SECTION: gstate
############################################################################################
ndivsm2 15
kptbounds2
0.0000000000 0.0000000000 0.0000000000
0.5000000000 0.0000000000 0.5000000000
0.5000000000 0.2500000000 0.7500000000
0.3750000000 0.3750000000 0.7500000000
0.0000000000 0.0000000000 0.0000000000
0.5000000000 0.5000000000 0.5000000000
0.6250000000 0.2500000000 0.6250000000
0.5000000000 0.2500000000 0.7500000000
0.5000000000 0.5000000000 0.5000000000
0.3750000000 0.3750000000 0.7500000000
0.6250000000 0.2500000000 0.6250000000
0.5000000000 0.0000000000 0.5000000000


#################
### DATASET 3 ###
#################
############################################################################################
# SECTION: basic
############################################################################################
ngkpt3 14 14 14
shiftk3 0.5 0.5 0.5
nshiftk3 1
kptopt3 1
nband3 18
iscf3 -2
tolwfr3 1e-17
############################################################################################
# SECTION: gstate
############################################################################################
chksymbreak3 0


#<JSON>
#{
# "pseudos": [
# {
# "basename": "14si.pspnc",
# "type": "NcAbinitPseudo",
# "symbol": "Si",
# "Z": 14,
# "Z_val": 4.0,
# "l_max": 2,
# "md5": "3916b143991b1cfa1542b130be320e5e",
# "filepath": "/Users/gmatteo/git_repos/abipy/abipy/data/pseudos/14si.pspnc",
# "@module": "pymatgen.io.abinit.pseudos",
# "@class": "NcAbinitPseudo"
# }
# ]
#}
#</JSON>
" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# GS run + NSCF on a path + NSCF run on a k-mesh to compute the DOS\n", "multi = abilab.ebands_input(si_cif, pseudos,\n", " ecut=8, spin_mode=\"unpolarized\", smearing=None, dos_kppa=5000)\n", "\n", "multi" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Factories for GW calculations" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "ndtset 4
############################################################################################
### Global Variables.
############################################################################################
kptopt 1
nspinor 1
nsppol 1
shiftk 0.0 0.0 0.0

ngkpt 8 8 8
istwfk *1
ecut 8

nspden 1
charge 0.0
chksymbreak 0
nshiftk 1
############################################################################################
# STRUCTURE
############################################################################################
natom 2
ntypat 1
typat 1 1
znucl 14
xred
0.0000000000 0.0000000000 0.0000000000
0.2500000000 0.2500000000 0.2500000000
acell 1.0 1.0 1.0
rprim
6.3285005272 0.0000000000 3.6537614829
2.1095001757 5.9665675167 3.6537614829
0.0000000000 0.0000000000 7.3075229659

#################
### DATASET 1 ###
#################
############################################################################################
# SECTION: basic
############################################################################################
nband1 8
tolvrs1 1e-08


#################
### DATASET 2 ###
#################
############################################################################################
# SECTION: basic
############################################################################################
nband2 50
iscf2 -2
tolwfr2 1e-17


#################
### DATASET 3 ###
#################
############################################################################################
# SECTION: basic
############################################################################################
nband3 50
iscf3 -2
toldfe3 1e-08
############################################################################################
# SECTION: gstate
############################################################################################
optdriver3 3
############################################################################################
# SECTION: gw
############################################################################################
ecuteps3 2
inclvkb3 2
awtr3 1
symchi3 1
############################################################################################
# SECTION: paral
############################################################################################
gwpara3 2


#################
### DATASET 4 ###
#################
############################################################################################
# SECTION: basic
############################################################################################
nband4 50
iscf4 -2
toldfe4 1e-08
############################################################################################
# SECTION: gstate
############################################################################################
optdriver4 4
############################################################################################
# SECTION: gw
############################################################################################
gwcalctyp4 00
ecuteps4 2
ecutsigx4 8
symsigma4 1
gw_qprange4 1
ppmodel4 1
############################################################################################
# SECTION: paral
############################################################################################
gwpara4 2


#<JSON>
#{
# "pseudos": [
# {
# "basename": "14si.pspnc",
# "type": "NcAbinitPseudo",
# "symbol": "Si",
# "Z": 14,
# "Z_val": 4.0,
# "l_max": 2,
# "md5": "3916b143991b1cfa1542b130be320e5e",
# "filepath": "/Users/gmatteo/git_repos/abipy/abipy/data/pseudos/14si.pspnc",
# "@module": "pymatgen.io.abinit.pseudos",
# "@class": "NcAbinitPseudo"
# }
# ]
#}
#</JSON>
" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Generate an input file for GW calculations with the plasmon-pole model.\n", "# The calculations consists of a GS run to get the density followed by a \n", "# nscf-run to compute the WFK file with `nscf_nband` states.\n", "# The cutoff for the screening is given by `ecuteps` while the cutoff for\n", "# the exchange part of the self-energy is equal to ecut.\n", "# kppa defines the k-point sampling.\n", "kppa = 1000\n", "ecut = ecutsigx = 8\n", "ecuteps = 2\n", "nscf_nband = 50\n", "\n", "multi = abilab.g0w0_with_ppmodel_inputs(\n", " si_cif, pseudos, kppa, nscf_nband, ecuteps, ecutsigx,\n", " ecut=ecut, smearing=None, spin_mode=\"unpolarized\")\n", "\n", "multi" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Back to the main [Index](index.ipynb)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.0" }, "latex_envs": { "bibliofile": "biblio.bib", "cite_by": "apalike", "current_citInitial": 1, "eqLabelWithNumbers": true, "eqNumInitial": 0 } }, "nbformat": 4, "nbformat_minor": 4 }