Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
qpoints = [
0.00000000E+00, 0.00000000E+00, 0.00000000E+00,
]
qpoints = np.reshape(qpoints, (-1,3))
# Global variables used both for the GS and the DFPT run.
global_vars = dict(nband=4,
ecut=3.0,
ngkpt=[4, 4, 4],
shiftk=[0, 0, 0],
tolvrs=1.0e-8,
paral_kgb=paral_kgb,
)
multi = abilab.MultiDataset(structure, pseudos=pseudos, ndtset=1+len(qpoints))
multi.set_structure(structure)
multi.set_vars(global_vars)
for i, qpt in enumerate(qpoints):
# Response-function calculation for phonons.
multi[i+1].set_vars(
nstep=20,
rfphon=1, # Will consider phonon-type perturbation
nqpt=1, # One one wavevector is to be considered
qpt=qpt, # The q-point
rfatpol=[1, len(structure)], # Only the first atom is displaced
rfdir=[1, 1, 1], # Along the first reduced coordinate axis
#kptopt 2 # Automatic generation of k points, taking
)
#!/usr/bin/env python
r"""
X-ray diffraction pattern
=========================
This example shows how to plot the X-ray diffraction pattern with pymatgen
"""
from abipy import abilab
import abipy.data as abidata
# Extract the structure (supports multiple formats e.g netcdf, Abinit input, cif, POSCAR)
# Also available via the `abistruct.py xrd FILE` command line interface.
structure = abilab.Structure.from_file(abidata.ref_file("si_scf_WFK.nc"))
import sys
if sys.version[0:3] > '2.7':
# pmg broke py compatibility
structure.plot_xrd()
def build_flow(options):
# Set working directory (default is the name of the script with '.py' removed and "run_" replaced by "flow_")
if not options.workdir:
options.workdir = os.path.basename(sys.argv[0]).replace(".py", "").replace("run_", "flow_")
# Build GS input file.
pseudos = abidata.pseudos("Si.GGA_PBE-JTH-paw.xml")
#silicon = abilab.Structure.zincblende(5.431, ["Si", "Si"], units="ang")
silicon = abidata.cif_file("si.cif")
scf_input = abilab.AbinitInput(silicon, pseudos)
ecut = 12
scf_input.set_vars(
ecut=ecut,
pawecutdg=40,
nband=6,
paral_kgb=0,
iomode=3,
toldfe=1e-9,
)
# K-point sampling (shifted)
scf_input.set_autokmesh(nksmall=4)
from abipy.flowtk.gs_works import EosWork
flow = flowtk.Flow(options.workdir, manager=options.manager)
#!/usr/bin/env python
r"""
MgB2 Fermi surface
==================
This example shows how to plot the Fermi surface with matplotlib
"""
from abipy import abilab
import abipy.data as abidata
with abilab.abiopen(abidata.ref_file("mgb2_kmesh181818_FATBANDS.nc")) as fbnc_kmesh:
ebands = fbnc_kmesh.ebands
# Build ebands in full BZ.
eb3d = ebands.get_ebands3d()
# Use matplotlib to plot isosurfaces corresponding to the Fermi level (default)
# Warning: requires skimage package, rendering could be slow.
eb3d.plot_isosurfaces()
# then compress the volume to trigger dilatmx.
structure.perturb(distance=0.1)
structure.scale_lattice(structure.volume * 0.6)
global_vars = dict(
ecut=4,
ngkpt=[4,4,4],
shiftk=[0,0,0],
nshiftk=1,
chksymbreak=0,
paral_kgb=paral_kgb,
iomode=3,
#prtwf=0,
)
multi = abilab.MultiDataset(structure, pseudos=abidata.pseudos("14si.pspnc"), ndtset=2)
# Global variables
multi.set_vars(global_vars)
# Dataset 1 (Atom Relaxation)
multi[0].set_vars(
optcell=0,
ionmov=2,
tolrff=0.02,
tolmxf=5.0e-5,
#ntime=50,
ntime=3, #To test the restart
#dilatmx=1.1, # FIXME: abinit crashes if I don't use this
)
# Dataset 2 (Atom + Cell Relaxation)
#!/usr/bin/env python
"""
This example shows how to plot the band structure of Nickel
using the eigenvalues stored in the GSR file produced by abinit at the end of the GS run.
"""
from abipy import abilab
import abipy.data as abidata
# Open the GSR file and extract the band structure.
# (alternatively one can use the shell and `abiopen.py OUT_GSR.nc -nb`
# to open the file in a jupyter notebook.
with abilab.abiopen(abidata.ref_file("ni_666k_GSR.nc")) as ncfile:
ni_ebands_kmesh = ncfile.ebands
with abilab.abiopen(abidata.ref_file("ni_kpath_GSR.nc")) as ncfile:
ni_ebands_kpath = ncfile.ebands
# Energy limits in eV for plots. The pseudo contains semi-core states but
# we are not interested in this energy region. Fermi level set to zero.
elims = [-10, 2]
# Plot band energies on k-path
ni_ebands_kpath.plot(ylims=elims, title="Ni band structure")
# Compute DOS with Gaussian method.
ni_edos = ni_ebands_kmesh.get_edos()
# Plot energies on k-path + DOS
ni_ebands_kpath.plot_with_edos(ni_edos, ylims=elims,
title="Ni band structure + DOS")
def gs_input(nsppol):
# Fe normal bcc structure for test of a ferromagnetic calculation
# The first dataset is without magnetization for comparison
structure = abilab.Structure.from_abivars(dict(
natom=1,
ntypat=1,
typat=1,
znucl=26,
acell=3*[5.42],
rprim=[-0.5, 0.5, 0.5,
0.5, -0.5, 0.5,
0.5, 0.5, -0.5],
xred=[0.0, 0.0, 0.0])
)
inp = abilab.AbinitInput(structure, pseudos=abidata.pseudos("26fe.pspnc"))
inp.set_kmesh(ngkpt=[4, 4, 4], shiftk=[0.5, 0.5, 0.5])
# Optimization of the lattice parameters
inp.set_vars(
0.50000000E+00 0.75000000E+00 0.75000000E+00
0.75000000E+00 0.50000000E+00 0.75000000E+00
0.75000000E+00 0.75000000E+00 0.50000000E+00
""", sep=" ").reshape((-1,3))
# Crystal structure (32 Al atoms)
structure = abilab.Structure.from_abivars(
acell=3*[12.81],
rprim=np.eye(3),
ntypat=1,
typat=32*[1],
znucl=13.0,
xred=xred,
)
inp = abilab.AbinitInput(structure, pseudos)
inp.set_vars(
# parallelization
paral_kgb=1,
#npband=10,
#npfft=3,
#npkpt=4,
#bandpp=2,
ecut=3.0,
pawecutdg=6.0 if paw else None,
nband=80,
nsppol=1,
# SCF cycle parameters
tolvrs=1.e-3,