{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Band structure with/without SOC\n\nThis example shows how to compute the band structure of GaAs with and without spin-orbit term.\nWe essentially build two BandStructureWork inside a loop over nspinor in [1, 2]\nnspinor = 1 corresponds to a standard collinear calculation for non-magnetic systems while\nnspinor = 2 gives us the non-collinear case with spinor wavefunctions required for the treatment of SOC.\nSome of the variables in the input files must be changed depending on the value of nspinor.\n\nWe use relativistic NC pseudos made of two terms: scalar pseudo + SOC term.\nThe SOC term can be deactivated with the input variable `so_psp`.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import sys\nimport os\nimport abipy.data as abidata\nimport abipy.abilab as abilab\nimport abipy.flowtk as flowtk\n\n\ndef build_flow(options):\n # Set working directory (default is the name of the script with '.py' removed and \"run_\" replaced by \"flow_\")\n if not options.workdir:\n options.workdir = os.path.basename(sys.argv[0]).replace(\".py\", \"\").replace(\"run_\", \"flow_\")\n\n structure = abidata.structure_from_ucell(\"GaAs\")\n pseudos = abidata.pseudos(\"Ga-low_r.psp8\", \"As_r.psp8\")\n num_electrons = structure.num_valence_electrons(pseudos)\n #print(\"num_electrons:\", num_electrons)\n\n # Usa same shifts in all tasks.\n ngkpt = [4, 4, 4]\n shiftk = [\n [0.5, 0.5, 0.5],\n [0.5, 0.0, 0.0],\n [0.0, 0.5, 0.0],\n [0.0, 0.0, 0.5],\n ]\n\n # NSCF run on k-path with large number of bands\n kptbounds = [\n [0.5, 0.0, 0.0], # L point\n [0.0, 0.0, 0.0], # Gamma point\n [0.0, 0.5, 0.5], # X point\n ]\n\n # Initialize the flow.\n flow = flowtk.Flow(options.workdir, manager=options.manager)\n\n for nspinor in [1, 2]:\n # Multi will contain two datasets (GS + NSCF) for the given nspinor.\n multi = abilab.MultiDataset(structure=structure, pseudos=pseudos, ndtset=2)\n\n # Global variables.\n multi.set_vars(\n ecut=20,\n nspinor=nspinor,\n nspden=1 if nspinor == 1 else 4,\n so_psp=\"*0\" if nspinor == 1 else \"*1\", # Important!\n #paral_kgb=1,\n )\n\n nband_occ = num_electrons // 2 if nspinor == 1 else num_electrons\n #print(nband_occ)\n\n # Dataset 1 (GS run)\n multi[0].set_vars(tolvrs=1e-8, nband=nband_occ + 4)\n multi[0].set_kmesh(ngkpt=ngkpt, shiftk=shiftk, kptopt=1 if nspinor == 1 else 4)\n\n multi[1].set_vars(iscf=-2, nband=nband_occ + 4, tolwfr=1.e-12)\n multi[1].set_kpath(ndivsm=10, kptbounds=kptbounds)\n\n # Get the SCF and the NSCF input.\n scf_input, nscf_input = multi.split_datasets()\n\n flow.register_work(flowtk.BandStructureWork(scf_input, nscf_input))\n\n return flow\n\n\n# This block generates the thumbnails in the AbiPy gallery.\n# You can safely REMOVE this part if you are using this script for production runs.\nif os.getenv(\"READTHEDOCS\", False):\n __name__ = None\n import tempfile\n options = flowtk.build_flow_main_parser().parse_args([\"-w\", tempfile.mkdtemp()])\n build_flow(options).graphviz_imshow()\n\n\n@flowtk.flow_main\ndef main(options):\n \"\"\"\n This is our main function that will be invoked by the script.\n flow_main is a decorator implementing the command line interface.\n Command line args are stored in `options`.\n \"\"\"\n return build_flow(options)\n\n\nif __name__ == \"__main__\":\n sys.exit(main())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Run the script with:\n\n run_gaas_ebands_soc.py -s\n\nthen use:\n\n abirun.py flow_si_ebands ebands --plot -t NscfTask\n\nto analyze (and plot) the electronic bands produced by the NsfTasks of the Flow.\n\n\n\nAlternatively, one can start a GSR robot for the NscfTask with:\n\n abirun.py flow_gaas_ebands_soc/ robot GSR -t NscfTask\n\nand then plot the two band structure on the same figure with:\n\n.. code-block:: ipython\n\n In [1]: %matplotlib\n In [2]: robot.combiplot_ebands()\n\n\n\n"
]
}
],
"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.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 0
}