本文整理汇总了Python中abipy.core.structure.Structure.as_structure方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.as_structure方法的具体用法?Python Structure.as_structure怎么用?Python Structure.as_structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类abipy.core.structure.Structure
的用法示例。
在下文中一共展示了Structure.as_structure方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scf_input
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def scf_input(structure, pseudos, kppa=None, ecut=None, pawecutdg=None, nband=None, accuracy="normal",
spin_mode="polarized", smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None,
shift_mode="Monkhorst-Pack"):
structure = Structure.as_structure(structure)
abinit_input = AbinitInput(structure, pseudos)
# Set the cutoff energies.
abinit_input.set_vars(_find_ecut_pawecutdg(ecut, pawecutdg, abinit_input.pseudos))
# SCF calculation.
kppa = _DEFAULTS.get("kppa") if kppa is None else kppa
shifts = (0.5, 0.5, 0.5) if shift_mode[0].lower() == "m" else (0.0, 0.0, 0.0)
scf_ksampling = aobj.KSampling.automatic_density(structure, kppa, chksymbreak=0, shifts=shifts)
scf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm=scf_algorithm,
charge=charge, nband=nband, fband=None)
if spin_mode=="polarized":
abinit_input.set_autospinat()
if scf_electrons.nband is None:
scf_electrons.nband = _find_scf_nband(structure, abinit_input.pseudos, scf_electrons,abinit_input.get('spinat', None))
abinit_input.set_vars(scf_ksampling.to_abivars())
abinit_input.set_vars(scf_electrons.to_abivars())
abinit_input.set_vars(_stopping_criterion("scf", accuracy))
return abinit_input
示例2: __init__
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def __init__(self, nspinor, nsppol, nspden, datar, structure, iorder="c"):
"""
Args:
nspinor: Number of spinorial components.
nsppol: Number of spins.
nspden: Number of spin density components.
datar: [nspden, nx, ny, nz] array with the scalar field in real space.
See also ``read_denpot``.
structure: |Structure| object describing the crystalline structure.
iorder: Order of the array. "c" for C ordering, "f" for Fortran ordering.
"""
self.nspinor, self.nsppol, self.nspden = nspinor, nsppol, nspden
# Convert to Abipy Structure.
self._structure = Structure.as_structure(structure)
iorder = iorder.lower()
assert iorder in ["f", "c"]
if iorder == "f":
# (z,x,y) --> (x,y,z)
datar = transpose_last3dims(datar)
# Init Mesh3D
mesh_shape = datar.shape[-3:]
self._mesh = Mesh3D(mesh_shape, structure.lattice.matrix)
# Make sure we have the correct shape.
self._datar = np.reshape(datar, (nspden,) + self.mesh.shape)
示例3: ion_ioncell_relax_and_ebands_input
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def ion_ioncell_relax_and_ebands_input(structure, pseudos,
kppa=None, nband=None,
ecut=None, pawecutdg=None, accuracy="normal", spin_mode="polarized",
smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None):
"""
Returns a :class:`AbinitInput` for a structural relaxation. The first dataset optmizes the
atomic positions at fixed unit cell. The second datasets optimizes both ions and unit cell parameters.
Args:
structure: :class:`Structure` object.
pseudos: List of filenames or list of :class:`Pseudo` objects or :class:`PseudoTable` object.
kppa: Defines the sampling used for the Brillouin zone.
nband: Number of bands included in the SCF run.
accuracy: Accuracy of the calculation.
spin_mode: Spin polarization.
smearing: Smearing technique.
charge: Electronic charge added to the unit cell.
scf_algorithm: Algorithm used for solving of the SCF cycle.
"""
structure = Structure.as_structure(structure)
relax_multi = ion_ioncell_relax_input(structure, pseudos,
kppa=kppa, nband=nband,
ecut=ecut, pawecutdg=pawecutdg, accuracy=accuracy, spin_mode=spin_mode,
smearing=smearing, charge=charge, scf_algorithm=scf_algorithm)
ebands_multi = ebands_input(structure, pseudos,
kppa=kppa, nscf_nband=None, ndivsm=15,
ecut=ecut, pawecutdg=pawecutdg, scf_nband=None, accuracy=accuracy, spin_mode=spin_mode,
smearing=smearing, charge=charge, scf_algorithm=scf_algorithm, dos_kppa=None)
return relax_multi + ebands_multi
示例4: set_structure
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def set_structure(self, structure):
structure = Structure.as_structure(structure)
self._structure = structure
if structure is None: return
self.set_vars(**structure.to_abivars())
示例5: __init__
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def __init__(self, entries):
self.entries = entries
from abipy.core.structure import Structure
for e in entries:
e.structure = Structure.as_structure(e.structure)
self.structures = [e.structure for e in entries]
self.mpids = [e.entry_id for e in entries]
# Create phase diagram.
from pymatgen.analysis.phase_diagram import PhaseDiagram
self.phasediagram = PhaseDiagram(self.entries)
示例6: ion_ioncell_relax_input
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def ion_ioncell_relax_input(structure, pseudos,
kppa=None, nband=None,
ecut=None, pawecutdg=None, accuracy="normal", spin_mode="polarized",
smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None):
"""
Returns a :class:`AbinitInput` for a structural relaxation. The first dataset optmizes the
atomic positions at fixed unit cell. The second datasets optimizes both ions and unit cell parameters.
Args:
structure: :class:`Structure` object.
pseudos: List of filenames or list of :class:`Pseudo` objects or :class:`PseudoTable` object.
kppa: Defines the sampling used for the Brillouin zone.
nband: Number of bands included in the SCF run.
accuracy: Accuracy of the calculation.
spin_mode: Spin polarization.
smearing: Smearing technique.
charge: Electronic charge added to the unit cell.
scf_algorithm: Algorithm used for solving of the SCF cycle.
"""
structure = Structure.as_structure(structure)
multi = MultiDataset(structure, pseudos, ndtset=2)
# Set the cutoff energies.
multi.set_vars(_find_ecut_pawecutdg(ecut, pawecutdg, multi.pseudos))
kppa = _DEFAULTS.get("kppa") if kppa is None else kppa
ksampling = aobj.KSampling.automatic_density(structure, kppa, chksymbreak=0)
electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm=scf_algorithm,
charge=charge, nband=nband, fband=None)
if spin_mode=="polarized":
spinat_dict = multi[0].set_autospinat()
multi[1].set_vars(spinat_dict)
if electrons.nband is None:
electrons.nband = _find_scf_nband(structure, multi.pseudos, electrons, multi[0].get('spinat', None))
ion_relax = aobj.RelaxationMethod.atoms_only(atoms_constraints=None)
ioncell_relax = aobj.RelaxationMethod.atoms_and_cell(atoms_constraints=None)
multi.set_vars(electrons.to_abivars())
multi.set_vars(ksampling.to_abivars())
multi[0].set_vars(ion_relax.to_abivars())
multi[0].set_vars(_stopping_criterion("relax", accuracy))
multi[1].set_vars(ioncell_relax.to_abivars())
multi[1].set_vars(_stopping_criterion("relax", accuracy))
return multi
示例7: display_structure
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def display_structure(obj, **kwargs):
"""
Use Jsmol to display a structure in the jupyter notebook.
Requires `nbjsmol` notebook extension installed on the local machine.
Install it with `pip install nbjsmol`. See also https://github.com/gmatteo/nbjsmol.
Args:
obj: Structure object or file with a structure or python object with a `structure` attribute.
kwargs: Keyword arguments passed to `nbjsmol_display`
"""
try:
from nbjsmol import nbjsmol_display
except ImportError as exc:
raise ImportError(str(exc) +
"\ndisplay structure requires nbjsmol package\n."
"Install it with `pip install nbjsmol.`\n"
"See also https://github.com/gmatteo/nbjsmol.")
# Cast to structure, get string with cif data and pass it to nbjsmol.
structure = Structure.as_structure(obj)
return nbjsmol_display(structure.to(fmt="cif"), ext=".cif", **kwargs)
示例8: _get_structure
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def _get_structure(self, obj):
"""Extract the structure from the input object."""
return Structure.as_structure(obj)
示例9: bse_with_mdf_inputs
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def bse_with_mdf_inputs(structure, pseudos,
scf_kppa, nscf_nband, nscf_ngkpt, nscf_shiftk,
ecuteps, bs_loband, bs_nband, soenergy, mdf_epsinf,
ecut=None, pawecutdg=None,
exc_type="TDA", bs_algo="haydock", accuracy="normal", spin_mode="polarized",
smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None):
"""
Returns a :class:`AbinitInput` object that performs a GS + NSCF + Bethe-Salpeter calculation.
The self-energy corrections are approximated with the scissors operator.
The screening in modeled with the model dielectric function.
Args:
structure: :class:`Structure` object.
pseudos: List of filenames or list of :class:`Pseudo` objects or :class:`PseudoTable` object.
scf_kppa: Defines the sampling used for the SCF run.
nscf_nband: Number of bands included in the NSCF run.
nscf_ngkpt: Divisions of the k-mesh used for the NSCF and the BSE run.
nscf_shiftk: Shifts used for the NSCF and the BSE run.
ecuteps: Cutoff energy [Ha] for the screening matrix.
bs_loband: Index of the first occupied band included the e-h basis set
(ABINIT convention i.e. first band starts at 1).
Can be scalar or array of shape (nsppol,)
bs_nband: Highest band idex used for the construction of the e-h basis set.
soenergy: Scissor energy in Hartree.
mdf_epsinf: Value of the macroscopic dielectric function used in expression for the model dielectric function.
ecut: cutoff energy in Ha (if None, ecut is initialized from the pseudos according to accuracy)
pawecutdg: cutoff energy in Ha for PAW double-grid (if None, pawecutdg is initialized from the pseudos
according to accuracy)
exc_type: Approximation used for the BSE Hamiltonian (Tamm-Dancoff or coupling).
bs_algo: Algorith for the computatio of the macroscopic dielectric function.
accuracy: Accuracy of the calculation.
spin_mode: Spin polarization.
smearing: Smearing technique.
charge: Electronic charge added to the unit cell.
scf_algorithm: Algorithm used for solving the SCF cycle.
"""
structure = Structure.as_structure(structure)
multi = MultiDataset(structure, pseudos, ndtset=3)
# Set the cutoff energies.
d = _find_ecut_pawecutdg(ecut, pawecutdg, multi.pseudos)
multi.set_vars(ecut=d.ecut, ecutwfn=d.ecut, pawecutdg=d.pawecutdg)
# Ground-state
scf_ksampling = aobj.KSampling.automatic_density(structure, scf_kppa, chksymbreak=0)
scf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm=scf_algorithm,
charge=charge, nband=None, fband=None)
if scf_electrons.nband is None:
scf_electrons.nband = _find_scf_nband(structure, multi.pseudos, scf_electrons)
multi[0].set_vars(scf_ksampling.to_abivars())
multi[0].set_vars(scf_electrons.to_abivars())
multi[0].set_vars(_stopping_criterion("scf", accuracy))
# NSCF calculation with the randomly-shifted k-mesh.
nscf_ksampling = aobj.KSampling.monkhorst(nscf_ngkpt, shiftk=nscf_shiftk, chksymbreak=0)
nscf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm={"iscf": -2},
charge=charge, nband=nscf_nband, fband=None)
multi[1].set_vars(nscf_ksampling.to_abivars())
multi[1].set_vars(nscf_electrons.to_abivars())
multi[1].set_vars(_stopping_criterion("nscf", accuracy))
# BSE calculation.
exc_ham = aobj.ExcHamiltonian(bs_loband, bs_nband, soenergy, coulomb_mode="model_df", ecuteps=ecuteps,
spin_mode=spin_mode, mdf_epsinf=mdf_epsinf, exc_type=exc_type, algo=bs_algo,
bs_freq_mesh=None, with_lf=True, zcut=None)
multi[2].set_vars(nscf_ksampling.to_abivars())
multi[2].set_vars(nscf_electrons.to_abivars())
multi[2].set_vars(exc_ham.to_abivars())
#multi[2].set_vars(_stopping_criterion("nscf", accuracy))
# TODO: Cannot use istwfk != 1.
multi.set_vars(istwfk="*1")
return multi
示例10: g0w0_with_ppmodel_inputs
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def g0w0_with_ppmodel_inputs(structure, pseudos,
kppa, nscf_nband, ecuteps, ecutsigx,
ecut=None, pawecutdg=None,
accuracy="normal", spin_mode="polarized", smearing="fermi_dirac:0.1 eV",
ppmodel="godby", charge=0.0, scf_algorithm=None, inclvkb=2, scr_nband=None,
sigma_nband=None, gw_qprange=1):
"""
Returns a :class:`AbinitInput` object that performs G0W0 calculations with the plasmon pole approximation.
Args:
structure: Pymatgen structure.
pseudos: List of filenames or list of :class:`Pseudo` objects or :class:`PseudoTable` object.
kppa: Defines the sampling used for the SCF run.
nscf_nband: Number of bands included in the NSCF run.
ecuteps: Cutoff energy [Ha] for the screening matrix.
ecutsigx: Cutoff energy [Ha] for the exchange part of the self-energy.
ecut: cutoff energy in Ha (if None, ecut is initialized from the pseudos according to accuracy)
pawecutdg: cutoff energy in Ha for PAW double-grid (if None, pawecutdg is initialized
from the pseudos according to accuracy)
accuracy: Accuracy of the calculation.
spin_mode: Spin polarization.
smearing: Smearing technique.
ppmodel: Plasmonpole technique.
charge: Electronic charge added to the unit cell.
scf_algorithm: Algorithm used for solving of the SCF cycle.
inclvkb: Treatment of the dipole matrix elements (see abinit variable).
scr_nband: Number of bands used to compute the screening (default is nscf_nband)
sigma_nband: Number of bands used to compute the self-energy (default is nscf_nband)
gw_qprange: Option for the automatic selection of k-points and bands for GW corrections.
See Abinit docs for more detail. The default value makes the code compute the
QP energies for all the point in the IBZ and one band above and one band below the Fermi level.
"""
structure = Structure.as_structure(structure)
multi = MultiDataset(structure, pseudos, ndtset=4)
# Set the cutoff energies.
multi.set_vars(_find_ecut_pawecutdg(ecut, pawecutdg, multi.pseudos))
scf_ksampling = aobj.KSampling.automatic_density(structure, kppa, chksymbreak=0)
scf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm=scf_algorithm,
charge=charge, nband=None, fband=None)
if scf_electrons.nband is None:
scf_electrons.nband = _find_scf_nband(structure, multi.pseudos, scf_electrons)
multi[0].set_vars(scf_ksampling.to_abivars())
multi[0].set_vars(scf_electrons.to_abivars())
multi[0].set_vars(_stopping_criterion("scf", accuracy))
nscf_ksampling = aobj.KSampling.automatic_density(structure, kppa, chksymbreak=0)
nscf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm={"iscf": -2},
charge=charge, nband=nscf_nband, fband=None)
multi[1].set_vars(nscf_ksampling.to_abivars())
multi[1].set_vars(nscf_electrons.to_abivars())
multi[1].set_vars(_stopping_criterion("nscf", accuracy))
# nbdbuf
# Screening.
if scr_nband is None: scr_nband = nscf_nband
screening = aobj.Screening(ecuteps, scr_nband, w_type="RPA", sc_mode="one_shot",
hilbert=None, ecutwfn=None, inclvkb=inclvkb)
multi[2].set_vars(nscf_ksampling.to_abivars())
multi[2].set_vars(nscf_electrons.to_abivars())
multi[2].set_vars(screening.to_abivars())
multi[2].set_vars(_stopping_criterion("screening", accuracy)) # Dummy
#scr_strategy = ScreeningStrategy(scf_strategy, nscf_strategy, screening)
# Sigma.
if sigma_nband is None: sigma_nband = nscf_nband
self_energy = aobj.SelfEnergy("gw", "one_shot", sigma_nband, ecutsigx, screening,
gw_qprange=gw_qprange, ppmodel=ppmodel)
multi[3].set_vars(nscf_ksampling.to_abivars())
multi[3].set_vars(nscf_electrons.to_abivars())
multi[3].set_vars(self_energy.to_abivars())
multi[3].set_vars(_stopping_criterion("sigma", accuracy)) # Dummy
#sigma_strategy = aobj.SelfEnergyStrategy(scf_strategy, nscf_strategy, scr_strategy, self_energy)
# TODO: Cannot use istwfk != 1.
multi.set_vars(istwfk="*1")
return multi
示例11: ebands_input
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def ebands_input(structure, pseudos,
kppa=None, nscf_nband=None, ndivsm=15,
ecut=None, pawecutdg=None, scf_nband=None, accuracy="normal", spin_mode="polarized",
smearing="fermi_dirac:0.1 eV", charge=0.0, scf_algorithm=None, dos_kppa=None):
"""
Returns a :class:`AbinitInput` for band structure calculations.
Args:
structure: :class:`Structure` object.
pseudos: List of filenames or list of :class:`Pseudo` objects or :class:`PseudoTable` object.
kppa: Defines the sampling used for the SCF run. Defaults to 1000 if not given.
nscf_nband: Number of bands included in the NSCF run. Set to scf_nband + 10 if None.
ndivsm: Number of divisions used to sample the smallest segment of the k-path.
ecut: cutoff energy in Ha (if None, ecut is initialized from the pseudos according to accuracy)
pawecutdg: cutoff energy in Ha for PAW double-grid (if None, pawecutdg is initialized from the pseudos
according to accuracy)
scf_nband: Number of bands for SCF run. If scf_nband is None, nband is automatically initialized
from the list of pseudos, the structure and the smearing option.
accuracy: Accuracy of the calculation.
spin_mode: Spin polarization.
smearing: Smearing technique.
charge: Electronic charge added to the unit cell.
scf_algorithm: Algorithm used for solving of the SCF cycle.
dos_kppa: Scalar or List of integers with the number of k-points per atom
to be used for the computation of the DOS (None if DOS is not wanted).
"""
structure = Structure.as_structure(structure)
if dos_kppa is not None and not isinstance(dos_kppa, (list, tuple)):
dos_kppa = [dos_kppa]
multi = MultiDataset(structure, pseudos, ndtset=2 if dos_kppa is None else 2 + len(dos_kppa))
# Set the cutoff energies.
multi.set_vars(_find_ecut_pawecutdg(ecut, pawecutdg, multi.pseudos))
# SCF calculation.
kppa = _DEFAULTS.get("kppa") if kppa is None else kppa
scf_ksampling = aobj.KSampling.automatic_density(structure, kppa, chksymbreak=0)
scf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm=scf_algorithm,
charge=charge, nband=scf_nband, fband=None)
if spin_mode=="polarized":
multi[0].set_autospinat()
if scf_electrons.nband is None:
scf_electrons.nband = _find_scf_nband(structure, multi.pseudos, scf_electrons, multi[0].get('spinat', None))
multi[0].set_vars(scf_ksampling.to_abivars())
multi[0].set_vars(scf_electrons.to_abivars())
multi[0].set_vars(_stopping_criterion("scf", accuracy))
# Band structure calculation.
nscf_ksampling = aobj.KSampling.path_from_structure(ndivsm, structure)
nscf_nband = scf_electrons.nband + 10 if nscf_nband is None else nscf_nband
nscf_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm={"iscf": -2},
charge=charge, nband=nscf_nband, fband=None)
multi[1].set_vars(nscf_ksampling.to_abivars())
multi[1].set_vars(nscf_electrons.to_abivars())
multi[1].set_vars(_stopping_criterion("nscf", accuracy))
# DOS calculation with different values of kppa.
if dos_kppa is not None:
for i, kppa in enumerate(dos_kppa):
dos_ksampling = aobj.KSampling.automatic_density(structure, kppa, chksymbreak=0)
#dos_ksampling = aobj.KSampling.monkhorst(dos_ngkpt, shiftk=dos_shiftk, chksymbreak=0)
dos_electrons = aobj.Electrons(spin_mode=spin_mode, smearing=smearing, algorithm={"iscf": -2},
charge=charge, nband=nscf_nband)
dt = 2 + i
multi[dt].set_vars(dos_ksampling.to_abivars())
multi[dt].set_vars(dos_electrons.to_abivars())
multi[dt].set_vars(_stopping_criterion("nscf", accuracy))
return multi
示例12: get_abistructure_from_abiref
# 需要导入模块: from abipy.core.structure import Structure [as 别名]
# 或者: from abipy.core.structure.Structure import as_structure [as 别名]
def get_abistructure_from_abiref(basename):
"""Return an Abipy |Structure| from the basename of one of the reference files."""
from abipy.core.structure import Structure
return Structure.as_structure(abidata.ref_file(basename))