aiida_vasp.utils package¶
Subpackages¶
Submodules¶
Utils for AiiDA.
that have now standardized in AiiDA will be removed.
- aiida_vasp.utils.aiida_utils.cmp_get_authinfo(computer)[source]¶
Get an existing authinfo or None for the given computer and current user.
- aiida_vasp.utils.aiida_utils.cmp_load_verdi_data()[source]¶
Load the verdi data click command group for any version since 0.11.
- aiida_vasp.utils.aiida_utils.compress_cell(structure, volume_change)[source]¶
Apply compression or tensile forces to the unit cell.
- aiida_vasp.utils.aiida_utils.create_authinfo(computer, store=False)[source]¶
Allow the current user to use the given computer.
- aiida_vasp.utils.aiida_utils.displace_position(structure, displacement, entry)[source]¶
Displace a position in the StructureData.
- aiida_vasp.utils.aiida_utils.get_data_class(data_type)[source]¶
Provide access to the orm.data classes with deferred dbenv loading.
- aiida_vasp.utils.aiida_utils.querybuild(cls, **kwargs)[source]¶
Instantiates and returns a QueryBuilder instance.
The QueryBuilder’s path has one vertice so far, namely this class. Additional parameters (e.g. filters or a label), can be passes as keyword arguments.
- Parameters:
label – Label to give
filters – filters to apply
project – projections
- Returns:
a QueryBuilder instance.
Utils for bands structures.
- aiida_vasp.utils.bands.get_bs_dims(bands_array)[source]¶
Get the dimensions from the bands array of a BandsData node.
- Parameters:
bands_array (numpy.array) – an array with bands as stored in an array.bands data node
- Returns:
a tuple containing num_bands, num_kp, num_spins. if the array is only 2d, num_spins = 0
- Rtype tuple:
- aiida_vasp.utils.bands.get_kp_labels(bands_node, kpoints_node=None)[source]¶
Get Kpoint labels with their x-positions in matplotlib compatible format.
A KpointsData node can optionally be given to fall back to if no labels are found on the BandsData node. The caller is responsible for ensuring the nodes match. This should be the case if you take the kpoints from the input and the bands from the output of a calculation node.
- Parameters:
bands_node (BandsData) – The BandsData node will be searched labels first
kpoints_node (KpointsData) – The optional KpointsData node will be searched only if no labels are present on the BandsData node. No consistency checks are performed.
- Returns:
(kpx, kpl), the x-coordinates and text labels
- Return type:
- Raises:
AttributeError – if neither of the given nodes have a labels attribute
- aiida_vasp.utils.bands.plot_bands(bands_node, **kwargs)[source]¶
Plot a bandstructure node using matplotlib.
- aiida_vasp.utils.bands.plot_bstr(bands_node, kpoints_node=None, title=None, efermi=None, use_parent_calc=False, **kwargs)[source]¶
Use matplotlib to plot the bands stored in a BandsData node.
A KpointsData node can optionally be given as a fallback for kpoint labels. The caller is responsible for giving a node with matching labels (as in they are in/out nodes of the same calculation).
- Parameters:
bands_node (BandsData) – The BandsData node will be searched labels first
kpoints_node (KpointsData) – The optional KpointsData node will be searched only if no labels are present on the BandsData node. No consistency checks are performed.
- Returns:
the matplotlib figure containing the plot
Utils for comparing band structures.
- aiida_vasp.utils.compare_bands.band_gap(bands, occ, efermi=None)[source]¶
Find the band gap in a bandstructure.
- Parameters:
bands (numpy.array) – 2D bands array (as from BandsData.get_bands())
occ (numpy.array) – 2D occupations array matching bands
efermi (float) – optional: Fermi Energy level
- Returns:
- {‘gap’: gap energy difference,
’direct’: bool wether it’s a direct band gap ‘vector’: start and end points to draw the band gap as an arrow in the bandstructure plot. the points consist of (k, Dispersion) coordinates }
- aiida_vasp.utils.compare_bands.bands_error(bands1, bands2)[source]¶
Band for band rms error sqrt((|B1_i - B2_i|^2)/n) where BX_i is the i-th band of Band Structure Node X.
Only works for BandsData nodes with 2d band arrays.
- aiida_vasp.utils.compare_bands.compare_bands(vasp_bands, wannier_bands_list, plot_folder=None)[source]¶
Compare a band structure from vasp with different ones from wannier90 obtained for different window parameters.
- Parameters:
vasp_bands – band structure output node from vasp calculation
wannier_bands_list – list of band structure output nodes from wannier90 calculations
plot_folder – if given, create a plot for each comparison in that folder
- Returns:
- aiida_vasp.utils.compare_bands.compare_from_window_wf(workflow, **kwargs)[source]¶
Find the relevant bands in the window workflow and compare them.
- aiida_vasp.utils.compare_bands.get_band_properties(eigenvalues, occupations)[source]¶
Get some key information about the band structure
Parameters¶
- eigenvaluesnp.ndarray
The eigenvalue array has shape (NS, NB, NK) or (NB, NK), where NS is the number of spins, NB is the number of bands and NK is the number of kpoints.
- occupations: np.ndarray
Same format as eigenvalues but instead holds occupation numbers.
Returns¶
- bands_infodict
A dictionary holds information about VBM and CBM locations and bandgaps.
- aiida_vasp.utils.compare_bands.get_band_properties_from_data(bandsdata)[source]¶
Acquire bands information from BandsData
Parameters¶
- bandsdataBandsData
A BandsData node to be processed
Returns¶
- bands_infodict
Same output as get_band_properties
- aiida_vasp.utils.compare_bands.get_outer_window(bands_node, silent=False)[source]¶
Get the
outer_window
parameter as a tuple (min, max), if it was given.Check if bands_node
is a child of a calculation and
that calculation has a parameter data input node with linkname parameters and
that node has the keys ‘dis_win_min’ and ‘dis_win_max’.
If that is the case, output outer_window = (min, max).
- aiida_vasp.utils.compare_bands.make_reference_bands_inline(wannier_bands, vasp_bands, efermi=None)[source]¶
Compare bandstructure results from wannier and vasp.
Takes two input array.bands nodes, stores them if they’re not already stored. Takes the relevant bands from the vasp bandstructure and stores and outputs them in a node with linkname ‘bandcmp’.
Also returns a parameter data node with linkname ‘bandinfo’ containing fermi energy, bandgap etc of the reference bandstructure.
- aiida_vasp.utils.compare_bands.plot_errors_vs_iwsize(comparison_info)[source]¶
Plot Band structure errors versus size of the inner window parameter for wannier90.
Default mapping between atomic element and potential.
Currently the default for LDA and PBE GW is included.
Utils for setting symbols on chemical elements.
- class aiida_vasp.utils.default_symbols.PawInfo(symbol, default_enmax, valency)[source]¶
Bases:
object
Simple class to bundle and pass around info about a PAW.
- aiida_vasp.utils.default_symbols.get_all(version_nr='latest', use_gw=False)[source]¶
Get recommendations for all symbols.
- Parameters:
version_nr – VASP version number
use_gw – Get recommendations for GW (default: LDA)
- Returns:
recommendations dict
- aiida_vasp.utils.default_symbols.get_recommendations(version_nr='latest', use_gw=False)[source]¶
Get recommendations for a certain type of PAW.
- Parameters:
version_nr – VASP version number
use_gw – get recommendations for GW instead LDA pseudopotentials
- Returns:
recommendations dict
Delegate types.
- aiida_vasp.utils.delegates.delegate_method_kwargs(prefix='_init_with_')[source]¶
Get a kwargs delegating decorator.
- Params prefix:
(str) common prefix of delegate functions
Extensions of dictionaries.
- class aiida_vasp.utils.extended_dicts.DictWithAttributes(dictionary=None)[source]¶
Bases:
AttributeDict
Extension of the AttributeDict from Aiida.common.
This class internally stores values in a dictionary, but exposes the keys also as attributes, i.e. asking for attrdict.key will return the value of attrdict[‘key’] and so on.
If the key is not in the dict a default value will be returned.
- aiida_vasp.utils.extended_dicts.delete_keys_from_dict(dictionary, keys)[source]¶
Delete a key from a nested dictionary.
Extended to support somekey.someotherkey in case we need some restrictions on the nesting.
- aiida_vasp.utils.extended_dicts.delete_nested_key(dictionary, keys)[source]¶
Delete the dictionary entry corresponding to a nested hierarchy of keys.
- aiida_vasp.utils.extended_dicts.find_key_in_dicts(dictionary, supplied_key)[source]¶
Find a key in a nested dictionary.
- aiida_vasp.utils.extended_dicts.update_nested_dict(dict1, dict2)[source]¶
Updated a nested dictionary, where dict1 is updated with values in dict2.
General utils.
- aiida_vasp.utils.general.copytree(src, dst, symlinks=False, ignore=None)[source]¶
Fixes annoying complaint about existing directory running tests
In Python 3.8 there is a flag for shutil.copytree that handles this, but we still support 3.6 and 3.7.
Inheritance tools.
docstring present on the base class.
- aiida_vasp.utils.inheritance.update_docstring(method_name, content, append=True)[source]¶
Update docstring of (an inherited) class method.
For subclasses that use hooks to change behavior of superclass methods.
- Parameters:
append – If true, append to the docstring, else overwrite it entirely.
Example:
class Base(object): def method(self, **kwargs): '''Print the base_arg kwarg.''' print kwargs.pop('base_arg') self.process_additional(**kwargs) def process_additional(self, **kwargs): pass @update_docstring('method', '\n\nAlso print the sub_arg kwarg.', append=True) class Subclass(Base): def process_additional(self, **kwargs): print kwargs['sub_arg'] @update_docstring('method', 'Print all kwargs.', append=False) class Allprinter(Base): def process_additional(self, **kwargs): for _, value in kwargs.items(): print value
Utility functions for running NEB calculations
- aiida_vasp.utils.neb.fix_atom_order(reference, to_fix)[source]¶
Fix atom order by finding NN distances bet ween two frames. This resolves the issue where two closely matching structures having diffferent atomic orders. Note that the two frames must be close enough for this to work
- aiida_vasp.utils.neb.neb_interpolate(init_structure, final_strucrture, nimages)[source]¶
Interplate NEB frames using the starting and the final structures
Get around the PBC warpping problem by calculating the MIC displacements from the initial to the final structure
Utils for the workchains.
- aiida_vasp.utils.workchains.compare_structures(structure_a, structure_b)[source]¶
Compare two StructureData objects A, B and return a delta (A - B) of the relevant properties.
- aiida_vasp.utils.workchains.compose_exit_code(status, message)[source]¶
Compose an ExitCode instance based on a status and message.
- aiida_vasp.utils.workchains.fetch_k_grid(rec_cell, k_spacing)[source]¶
Suggest a sensible k-point sampling based on a supplied spacing.
- Parameters:
rec_cell – A two dimensional ndarray of floats defining the reciprocal lattice with each vector as row elements.
k_spacing – The k-point spacing.
- Return kgrid:
The k-point grid given the supplied rec_cell and kstep
This is usable for instance when performing plane wave cutoff convergence tests without a base k-point grid.
- aiida_vasp.utils.workchains.prepare_process_inputs(inputs, namespaces=None, exclude_parameters=None)[source]¶
Prepare the inputs dictionary for a calculation.
Any remaining bare dictionaries in the inputs dictionary will be wrapped in a Dict data node except for the ‘options’, ‘metadata’, ‘potential’ and any key specified in the parameters namespaces. They all should remain a standard dictionary. Another exception are dictionaries whose keys are not strings but for example tuples.