text
stringlengths
81
112k
String with the list of files and prefixes needed to execute ABINIT. def filesfile_string(self): """String with the list of files and prefixes needed to execute ABINIT.""" lines = [] app = lines.append pj = os.path.join app(self.input_file.path) # Path to the in...
True if the task is a GS Task and uses paral_kgb with the given value. def uses_paral_kgb(self, value=1): """True if the task is a GS Task and uses paral_kgb with the given value.""" paral_kgb = self.get_inpvar("paral_kgb", 0) # paral_kgb is used only in the GS part. return paral_kgb ==...
Change the input structure. def _change_structure(self, new_structure): """Change the input structure.""" # Compare new and old structure for logging purpose. # TODO: Write method of structure to compare self and other and return a dictionary old_structure = self.input.structure ...
Find an optimal set of parameters for the execution of the task This method can change the ABINIT input variables and/or the submission parameters e.g. the number of CPUs for MPI and OpenMp. Set: self.pconfs where pconfs is a :class:`ParalHints` object with the configuration reported...
Find the optimal Parallel configuration. def find_optconf(self, pconfs): """Find the optimal Parallel configuration.""" # Save pconfs for future reference. self.set_pconfs(pconfs) # Select the partition on which we'll be running and set MPI/OMP cores. optconf = self.manager.sel...
Helper function used to select the files of a task. Args: what: string with the list of characters selecting the file type Possible choices: i ==> input_file, o ==> output_file, f ==> files_file, j ==>...
method to fix crashes/error caused by abinit Returns: 1 if task has been fixed else 0. def fix_abicritical(self): """ method to fix crashes/error caused by abinit Returns: 1 if task has been fixed else 0. """ event_handlers = self.event_handlers...
This function tries to fix critical events originating from the queue submission system. General strategy, first try to increase resources in order to fix the problem, if this is not possible, call a task specific method to attempt to decrease the demands. Returns: 1 if task has be...
Parse the timer data in the main output file of Abinit. Requires timopt /= 0 in the input file (usually timopt = -1) Return: :class:`AbinitTimerParser` instance, None if error. def parse_timing(self): """ Parse the timer data in the main output file of Abinit. Requires timopt /...
Absolute path of the HIST file. Empty string if file is not present. def hist_path(self): """Absolute path of the HIST file. Empty string if file is not present.""" # Lazy property to avoid multiple calls to has_abiext. try: return self._hist_path except AttributeError: ...
Open the HIST file located in the in self.outdir. Returns :class:`HistFile` object, None if file could not be found or file is not readable. def open_hist(self): """ Open the HIST file located in the in self.outdir. Returns :class:`HistFile` object, None if file could not be found or fi...
Absolute path of the GSR file. Empty string if file is not present. def gsr_path(self): """Absolute path of the GSR file. Empty string if file is not present.""" # Lazy property to avoid multiple calls to has_abiext. try: return self._gsr_path except AttributeError: ...
Open the GSR file located in the in self.outdir. Returns :class:`GsrFile` object, None if file could not be found or file is not readable. def open_gsr(self): """ Open the GSR file located in the in self.outdir. Returns :class:`GsrFile` object, None if file could not be found or file is...
Plot the SCF cycle results with matplotlib. Returns `matplotlib` figure, None if some error occurred. def inspect(self, **kwargs): """ Plot the SCF cycle results with matplotlib. Returns `matplotlib` figure, None if some error occurred. """ try:...
NSCF calculations should use the same FFT mesh as the one employed in the GS task (in principle, it's possible to interpolate inside Abinit but tests revealed some numerical noise Here we change the input file of the NSCF task to have the same FFT mesh. def setup(self): """ NSCF calcula...
Restart the structural relaxation. Structure relaxations can be restarted only if we have the WFK file or the DEN or the GSR file from which we can read the last structure (mandatory) and the wavefunctions (not mandatory but useful). Prefer WFK over other files since we can reuse the wavefuncti...
Plot the evolution of the structural relaxation with matplotlib. Args: what: Either "hist" or "scf". The first option (default) extracts data from the HIST file and plot the evolution of the structural parameters, forces, pressures and energies. The s...
Note that ABINIT produces lots of out_TIM1_DEN files for each step. Here we list all TIM*_DEN files, we select the last one and we rename it in out_DEN This change is needed so that we can specify dependencies with the syntax {node: "DEN"} without having to know the number of iterations needed ...
Absolute path of the DDB file. Empty string if file is not present. def ddb_path(self): """Absolute path of the DDB file. Empty string if file is not present.""" # Lazy property to avoid multiple calls to has_abiext. try: return self._ddb_path except AttributeError: ...
Replace the default behaviour of make_links. More specifically, this method implements the logic required to connect DFPT calculation to `DDK` files. Remember that DDK is an extension introduced in AbiPy to deal with the irdddk input variable and the fact that the 3 files with du/dk produced by ...
DFPT calculations can be restarted only if we have the 1WF file or the 1DEN file. from which we can read the first-order wavefunctions or the first order density. Prefer 1WF over 1DEN since we can reuse the wavefunctions. def restart(self): """ DFPT calculations can be restarted only if...
Plot the Phonon SCF cycle results with matplotlib. Returns: `matplotlib` figure, None if some error occurred. def inspect(self, **kwargs): """ Plot the Phonon SCF cycle results with matplotlib. Returns: `matplotlib` figure, None if some error occurred. ...
Method that can be called by the scheduler to decrease the memory demand of a specific task. Returns True in case of success, False in case of Failure. def reduce_memory_demand(self): """ Method that can be called by the scheduler to decrease the memory demand of a specific task. Return...
Absolute path of the SCR file. Empty string if file is not present. def scr_path(self): """Absolute path of the SCR file. Empty string if file is not present.""" # Lazy property to avoid multiple calls to has_abiext. try: return self._scr_path except AttributeError: ...
Open the SIGRES file located in the in self.outdir. Returns :class:`ScrFile` object, None if file could not be found or file is not readable. def open_scr(self): """ Open the SIGRES file located in the in self.outdir. Returns :class:`ScrFile` object, None if file could not be found or f...
Absolute path of the SIGRES file. Empty string if file is not present. def sigres_path(self): """Absolute path of the SIGRES file. Empty string if file is not present.""" # Lazy property to avoid multiple calls to has_abiext. try: return self._sigres_path except AttributeErr...
Open the SIGRES file located in the in self.outdir. Returns :class:`SigresFile` object, None if file could not be found or file is not readable. def open_sigres(self): """ Open the SIGRES file located in the in self.outdir. Returns :class:`SigresFile` object, None if file could not be f...
Returns an instance of :class:`ScissorsBuilder` from the SIGRES file. Raise: `RuntimeError` if SIGRES file is not found. def get_scissors_builder(self): """ Returns an instance of :class:`ScissorsBuilder` from the SIGRES file. Raise: `RuntimeError` if SIGRES fi...
BSE calculations with Haydock can be restarted only if we have the excitonic Hamiltonian and the HAYDR_SAVE file. def restart(self): """ BSE calculations with Haydock can be restarted only if we have the excitonic Hamiltonian and the HAYDR_SAVE file. """ # TODO: This ver...
Absolute path of the MDF file. Empty string if file is not present. def mdf_path(self): """Absolute path of the MDF file. Empty string if file is not present.""" # Lazy property to avoid multiple calls to has_abiext. try: return self._mdf_path except AttributeError: ...
Open the MDF file located in the in self.outdir. Returns :class:`MdfFile` object, None if file could not be found or file is not readable. def open_mdf(self): """ Open the MDF file located in the in self.outdir. Returns :class:`MdfFile` object, None if file could not be found or file is...
Set the working directory of the task. def set_workdir(self, workdir, chroot=False): """Set the working directory of the task.""" super().set_workdir(workdir, chroot=chroot) # Small hack: the log file of optics is actually the main output file. self.output_file = self.log_file
Optic does not use `get` or `ird` variables hence we should never try to change the input when we connect this task def set_vars(self, *args, **kwargs): """ Optic does not use `get` or `ird` variables hence we should never try to change the input when we connect this task """ ...
String with the list of files and prefixes needed to execute ABINIT. def filesfile_string(self): """String with the list of files and prefixes needed to execute ABINIT.""" lines = [] app = lines.append #optic.in ! Name of input file #optic.out ! Unused #optic ...
Returns (at runtime) the absolute path of the DDK files produced by the DDK runs. def ddk_filepaths(self): """Returns (at runtime) the absolute path of the DDK files produced by the DDK runs.""" # This to support new version of optic that used DDK.nc paths = [ddk_task.outdir.has_abiext("DDK.nc"...
Construct and write the input file of the calculation. def make_input(self): """Construct and write the input file of the calculation.""" # Set the file paths. all_files ={"ddkfile_" + str(n + 1): ddk for n, ddk in enumerate(self.ddk_filepaths)} all_files.update({"wfkfile": self.wfk_fil...
restart from scratch, this is to be used if a job is restarted with more resources after a crash def reset_from_scratch(self): """ restart from scratch, this is to be used if a job is restarted with more resources after a crash """ # Move output files produced in workdir to _reset other...
Build a :class:`AnaddbTask` with a temporary workdir. The task is executed via the shell with 1 MPI proc. Mainly used for post-processing the DDB files. Args: mpi_procs: Number of MPI processes to use. anaddb_input: string with the anaddb variables. ddb_node: The nod...
String with the list of files and prefixes needed to execute ABINIT. def filesfile_string(self): """String with the list of files and prefixes needed to execute ABINIT.""" lines = [] app = lines.append app(self.input_file.path) # 1) Path of the input file app(self.outp...
Returns (at runtime) the absolute path of the input DDB file. def ddb_filepath(self): """Returns (at runtime) the absolute path of the input DDB file.""" # This is not very elegant! A possible approach could to be path self.ddb_node.outdir! if isinstance(self.ddb_node, FileNode): return self.dd...
Returns (at runtime) the absolute path of the input MD file. def md_filepath(self): """Returns (at runtime) the absolute path of the input MD file.""" if self.md_node is None: return "MD_FILE_DOES_NOT_EXIST" if isinstance(self.md_node, FileNode): return self.md_node.filepath path = sel...
Returns (at runtime) the absolute path of the input GKK file. def gkk_filepath(self): """Returns (at runtime) the absolute path of the input GKK file.""" if self.gkk_node is None: return "GKK_FILE_DOES_NOT_EXIST" if isinstance(self.gkk_node, FileNode): return self.gkk_node.filepath pat...
Returns (at runtime) the absolute path of the input DKK file. def ddk_filepath(self): """Returns (at runtime) the absolute path of the input DKK file.""" if self.ddk_node is None: return "DDK_FILE_DOES_NOT_EXIST" if isinstance(self.ddk_node, FileNode): return self.ddk_node.filepath pat...
Open PHBST file produced by Anaddb and returns :class:`PhbstFile` object. def open_phbst(self): """Open PHBST file produced by Anaddb and returns :class:`PhbstFile` object.""" from abipy.dfpt.phonons import PhbstFile phbst_path = os.path.join(self.workdir, "run.abo_PHBST.nc") if not phb...
Open PHDOS file produced by Anaddb and returns :class:`PhdosFile` object. def open_phdos(self): """Open PHDOS file produced by Anaddb and returns :class:`PhdosFile` object.""" from abipy.dfpt.phonons import PhdosFile phdos_path = os.path.join(self.workdir, "run.abo_PHDOS.nc") if not phd...
Reads and returns a pymatgen structure from a NetCDF file containing crystallographic data in the ETSF-IO format. Args: ncdata: filename or NetcdfReader instance. site_properties: Dictionary with site properties. cls: The Structure class to instanciate. def structure_from_ncdata(ncdata...
Navigate all the groups in the file starting from top. If top is None, the root group is used. def walk_tree(self, top=None): """ Navigate all the groups in the file starting from top. If top is None, the root group is used. """ if top is None: top = self.roo...
Returns the value of a dimension. Args: dimname: Name of the variable path: path to the group. default: return `default` if `dimname` is not present and `default` is not `NO_DEFAULT` else raise self.Error. def read_dimvalue(self, dimname, path="/", default=N...
List of variable names stored in the group specified by path. def read_varnames(self, path="/"): """List of variable names stored in the group specified by path.""" if path == "/": return self.rootgrp.variables.keys() else: group = self.path2group[path] retur...
Returns the values of variable with name varname in the group specified by path. Args: varname: Name of the variable path: path to the group. cmode: if cmode=="c", a complex ndarrays is constructed and returned (netcdf does not provide native support from com...
Read a list of variables/dimensions from file. If a key is not present the corresponding entry in the output dictionary is set to None. def read_keys(self, keys, dict_cls=AttrDict, path="/"): """ Read a list of variables/dimensions from file. If a key is not present the corresponding en...
Chemical symbols char [number of atom species][symbol length]. def chemical_symbols(self): """Chemical symbols char [number of atom species][symbol length].""" charr = self.read_value("chemical_symbols") symbols = [] for v in charr: s = "".join(c.decode("utf-8") for c in v) ...
Returns the crystalline structure. def read_structure(self, cls=Structure): """Returns the crystalline structure.""" if self.ngroups != 1: raise NotImplementedError("In file %s: ngroups != 1" % self.path) return structure_from_ncdata(self, cls=cls)
Read the variables associated to the Abinit header. Return :class:`AbinitHeader` def read_abinit_hdr(self): """ Read the variables associated to the Abinit header. Return :class:`AbinitHeader` """ d = {} for hvar in _HDR_VARIABLES.values(): ncname =...
String representation. kwargs are passed to `pprint.pformat`. Args: verbose: Verbosity level title: Title string. def to_string(self, verbose=0, title=None, **kwargs): """ String representation. kwargs are passed to `pprint.pformat`. Args: verbose: ...
Add an electrode to the plot. Args: electrode: An electrode. All electrodes satisfying the AbstractElectrode interface should work. label: A label for the electrode. If None, defaults to a counting system, i.e. 'Electrode 1', 'Electrode 2', ... def add_e...
Returns a plot object. Args: width: Width of the plot. Defaults to 8 in. height: Height of the plot. Defaults to 6 in. Returns: A matplotlib plot object. def get_plot(self, width=8, height=8): """ Returns a plot object. Args: wi...
Save the plot to an image file. Args: filename: Filename to save to. image_format: Format to save to. Defaults to eps. def save(self, filename, image_format="eps", width=8, height=6): """ Save the plot to an image file. Args: filename: Filename to s...
Process structure from previous run. Args: vasprun (Vasprun): Vasprun that contains the final structure from previous run. outcar (Outcar): Outcar that contains the magnetization info from previous run. sym_prec (float): Tolerance for symmetry finding for standardiza...
Batch write vasp input for a sequence of structures to output_dir, following the format output_dir/{group}/{formula}_{number}. Args: structures ([Structure]): Sequence of Structures. vasp_input_set (VaspInputSet): VaspInputSet class that creates vasp input files from structures. Not...
List of POTCAR symbols. def potcar_symbols(self): """ List of POTCAR symbols. """ elements = self.poscar.site_symbols potcar_symbols = [] settings = self._config_dict["POTCAR"] if isinstance(settings[elements[-1]], dict): for el in elements: ...
Returns all input files as a dict of {filename: vasp object} Returns: dict of {filename: object}, e.g., {'INCAR': Incar object, ...} def all_input(self): """ Returns all input files as a dict of {filename: vasp object} Returns: dict of {filename: object}, e.g.,...
Writes a set of VASP input to a directory. Args: output_dir (str): Directory to output the VASP input files make_dir_if_not_present (bool): Set to True if you want the directory (and the whole path) to be created if it is not present. include_...
Gets the default number of electrons for a given structure. def nelect(self): """ Gets the default number of electrons for a given structure. """ # if structure is not sorted this can cause problems, so must take # care to remove redundant symbols when counting electrons ...
Writes out a KPOINTS file using the fully automated grid method. Uses Gamma centered meshes for hexagonal cells and Monk grids otherwise. Algorithm: Uses a simple approach scaling the number of divisions along each reciprocal lattice vector proportional to its length. def kpoin...
Generate a set of Vasp input files for static calculations from a directory of previous Vasp run. Args: prev_calc_dir (str): Directory containing the outputs( vasprun.xml and OUTCAR) of previous vasp run. standardize (float): Whether to standardize to a primitive...
Generate a set of Vasp input files for HSE calculations from a directory of previous Vasp run. if mode=="gap", it explicitly adds VBM and CBM of the prev run to the k-point list of this run. Args: prev_calc_dir (str): Directory containing the outputs (vasprun.xml and...
Generate a set of Vasp input files for NonSCF calculations from a directory of previous static Vasp run. Args: prev_calc_dir (str): The directory contains the outputs( vasprun.xml and OUTCAR) of previous vasp run. copy_chgcar: Whether to copy the old CHGCAR. Defa...
Generate a set of Vasp input files for SOC calculations from a directory of previous static Vasp run. SOC calc requires all 3 components for MAGMOM for each atom in the structure. Args: prev_calc_dir (str): The directory contains the outputs( vasprun.xml and OUTCAR) ...
Generate gamma center k-points mesh grid for GW calc, which is requested by GW calculation. def kpoints(self): """ Generate gamma center k-points mesh grid for GW calc, which is requested by GW calculation. """ return Kpoints.automatic_density_by_vol(self.structure, ...
Generate a set of Vasp input files for GW or BSE calculations from a directory of previous Exact Diag Vasp run. Args: prev_calc_dir (str): The directory contains the outputs( vasprun.xml of previous vasp run. copy_wavecar: Whether to copy the old WAVECAR, WAVEDER...
k_product, default to 50, is kpoint number * length for a & b directions, also for c direction in bulk calculations Automatic mesh & Gamma is the default setting. def kpoints(self): """ k_product, default to 50, is kpoint number * length for a & b directions, also for c ...
k_product, default to 40, is kpoint number * length for a & b directions, also for c direction in bulk calculations Automatic mesh & Gamma is the default setting. def kpoints(self): """ k_product, default to 40, is kpoint number * length for a & b directions, also for c directio...
Remove any atom jumps across the cell def _process_structures(structures): """ Remove any atom jumps across the cell """ input_structures = structures structures = [input_structures[0]] for s in input_structures[1:]: prev = structures[-1] for i in...
NEB inputs has a special directory structure where inputs are in 00, 01, 02, .... Args: output_dir (str): Directory to output the VASP input files make_dir_if_not_present (bool): Set to True if you want the directory (and the whole path) to be created if it is no...
Gets a unit vector parallel to input vector def get_uvec(vec): """ Gets a unit vector parallel to input vector""" l = np.linalg.norm(vec) if l < 1e-8: return vec return vec / l
Function that converts a list of tensors corresponding to a structure and returns a dictionary consisting of unique tensor keys with symmop values corresponding to transformations that will result in derivative tensors from the original list Args: tensors (list of tensors): list of Tensor objec...
Helper function to find a value in a tensor-keyed- dictionary using an approximation to the key. This is useful if rounding errors in construction occur or hashing issues arise in tensor-keyed-dictionaries (e. g. from symmetry_reduce). Resolves most hashing issues, and is preferable to redefining ...
returns the matrix with all entries below a certain threshold (i.e. tol) set to zero def zeroed(self, tol=1e-3): """ returns the matrix with all entries below a certain threshold (i.e. tol) set to zero """ new_tensor = self.copy() new_tensor[abs(new_tensor) < tol...
Applies a rotation directly, and tests input matrix to ensure a valid rotation. Args: matrix (3x3 array-like): rotation matrix to be applied to tensor tol (float): tolerance for testing rotation matrix validity def rotate(self, matrix, tol=1e-3): """ Applies a r...
Calculates the result of an einstein summation expression def einsum_sequence(self, other_arrays, einsum_string=None): """ Calculates the result of an einstein summation expression """ if not isinstance(other_arrays, list): raise ValueError("other tensors must be list of " ...
Convenience method for projection of a tensor into a vector. Returns the tensor dotted into a unit vector along the input n. Args: n (3x1 array-like): direction to project onto Returns (float): scalar value corresponding to the projection of the ten...
Method for averaging the tensor projection over the unit with option for custom quadrature. Args: quad (dict): quadrature for integration, should be dictionary with "points" and "weights" keys defaults to quadpy.sphere.Lebedev(19) as read from file R...
Gets index sets for equivalent tensor values Args: voigt (bool): whether to get grouped indices of voigt or full notation tensor, defaults to false **kwargs: keyword args for np.isclose. Can take atol and rtol for absolute and relative to...
Creates a summary dict for tensor with associated symbol Args: voigt (bool): whether to get symbol dict for voigt notation tensor, as opposed to full notation, defaults to true zero_index (bool): whether to set initial index to zero, defau...
Wrapper around numpy.round to ensure object of same type is returned Args: decimals :Number of decimal places to round to (default: 0). If decimals is negative, it specifies the number of positions to the left of the decimal point. Returns (Tensor): ...
Returns a generally symmetrized tensor, calculated by taking the sum of the tensor and its transpose with respect to all possible permutations of indices def symmetrized(self): """ Returns a generally symmetrized tensor, calculated by taking the sum of the tensor and its transpo...
Returns a "voigt"-symmetrized tensor, i. e. a voigt-notation tensor such that it is invariant wrt permutation of indices def voigt_symmetrized(self): """ Returns a "voigt"-symmetrized tensor, i. e. a voigt-notation tensor such that it is invariant wrt permutation of indices """ ...
Returns a tensor that is invariant with respect to symmetry operations corresponding to a structure Args: structure (Structure): structure from which to generate symmetry operations symprec (float): symmetry tolerance for the Spacegroup Analyzer u...
Tests whether a tensor is invariant with respect to the symmetry operations of a particular structure by testing whether the residual of the symmetric portion is below a tolerance Args: structure (Structure): structure to be fit to tol (float): tolerance for symm...
Returns the tensor in Voigt notation def voigt(self): """ Returns the tensor in Voigt notation """ v_matrix = np.zeros(self._vscale.shape, dtype=self.dtype) this_voigt_map = self.get_voigt_dict(self.rank) for ind in this_voigt_map: v_matrix[this_voigt_map[ind...
Tests symmetry of tensor to that necessary for voigt-conversion by grouping indices into pairs and constructing a sequence of possible permutations to be used in a tensor transpose def is_voigt_symmetric(self, tol=1e-6): """ Tests symmetry of tensor to that necessary for voigt-conversio...
Returns a dictionary that maps indices in the tensor to those in a voigt representation based on input rank Args: rank (int): Tensor rank to generate the voigt map def get_voigt_dict(rank): """ Returns a dictionary that maps indices in the tensor to those in a voigt...
Constructor based on the voigt notation vector or matrix. Args: voigt_input (array-like): voigt input for a given tensor def from_voigt(cls, voigt_input): """ Constructor based on the voigt notation vector or matrix. Args: voigt_input (array-like): voigt input ...
Given a structure associated with a tensor, determines the rotation matrix for IEEE conversion according to the 1987 IEEE standards. Args: structure (Structure): a structure associated with the tensor to be converted to the IEEE standard refine_rotation (...
Given a structure associated with a tensor, attempts a calculation of the tensor in IEEE format according to the 1987 IEEE standards. Args: structure (Structure): a structure associated with the tensor to be converted to the IEEE standard initial_fit (boo...
Transforms a tensor from one basis for an original structure into a new basis defined by a new structure. Args: original_structure (Structure): structure corresponding to the basis of the current tensor new_structure (Structure): structure corresponding to the ...
Creates a tensor from values and indices, with options for populating the remainder of the tensor. Args: values (floats): numbers to place at indices indices (array-likes): indices to place values at populate (bool): whether to populate the tensor structu...
Takes a partially populated tensor, and populates the non-zero entries according to the following procedure, iterated until the desired convergence (specified via prec) is achieved. 1. Find non-zero entries 2. Symmetrize the tensor with respect to crystal symmetry and (option...
Serializes the tensor object Args: voigt (bool): flag for whether to store entries in voigt-notation. Defaults to false, as information may be lost in conversion. Returns (Dict): serialized format tensor object def as_dict(self, voigt=False): ...