INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Given a structure returns back the structure scaled to predicted volume. Args: structure ( Structure ): structure w/ unknown volume
def get_predicted_structure(self, structure, icsd_vol=False): """ Given a structure, returns back the structure scaled to predicted volume. Args: structure (Structure): structure w/unknown volume Returns: a Structure object with predicted volume "...
Pair the geometrically equivalent atoms of the molecules. Calculate RMSD on all possible isomorphism mappings and return mapping with the least RMSD
def uniform_labels(self, mol1, mol2): """ Pair the geometrically equivalent atoms of the molecules. Calculate RMSD on all possible isomorphism mappings and return mapping with the least RMSD Args: mol1: First molecule. OpenBabel OBMol or pymatgen Molecule object. ...
Return inchi as molecular hash
def get_molecule_hash(self, mol): """ Return inchi as molecular hash """ obconv = ob.OBConversion() obconv.SetOutFormat(str("inchi")) obconv.AddOption(str("X"), ob.OBConversion.OUTOPTIONS, str("DoNotAddH")) inchi_text = obconv.WriteString(mol) match = re.s...
Get the inchi canonical labels of the heavy atoms in the molecule
def _inchi_labels(mol): """ Get the inchi canonical labels of the heavy atoms in the molecule Args: mol: The molecule. OpenBabel OBMol object Returns: The label mappings. List of tuple of canonical label, original label List of equivalent...
Calculate the centroids of a group atoms indexed by the labels of inchi
def _group_centroid(mol, ilabels, group_atoms): """ Calculate the centroids of a group atoms indexed by the labels of inchi Args: mol: The molecule. OpenBabel OBMol object ilabel: inchi label map Returns: Centroid. Tuple (x, y, z) """ ...
Create a virtual molecule by unique atoms the centriods of the equivalent atoms
def _virtual_molecule(self, mol, ilabels, eq_atoms): """ Create a virtual molecule by unique atoms, the centriods of the equivalent atoms Args: mol: The molecule. OpenBabel OBMol object ilables: inchi label map eq_atoms: equivalent atom labels ...
Align the label of topologically identical atoms of second molecule towards first molecule
def _align_heavy_atoms(mol1, mol2, vmol1, vmol2, ilabel1, ilabel2, eq_atoms): """ Align the label of topologically identical atoms of second molecule towards first molecule Args: mol1: First molecule. OpenBabel OBMol object mol2: Second...
Align the label of topologically identical atoms of second molecule towards first molecule
def _align_hydrogen_atoms(mol1, mol2, heavy_indices1, heavy_indices2): """ Align the label of topologically identical atoms of second molecule towards first molecule Args: mol1: First molecule. OpenBabel OBMol object mol2: Second mol...
The the elements of the atoms in the specified order
def _get_elements(mol, label): """ The the elements of the atoms in the specified order Args: mol: The molecule. OpenBabel OBMol object. label: The atom indices. List of integers. Returns: Elements. List of integers. """ elements = [i...
Is the molecule a linear one
def _is_molecule_linear(self, mol): """ Is the molecule a linear one Args: mol: The molecule. OpenBabel OBMol object. Returns: Boolean value. """ if mol.NumAtoms() < 3: return True a1 = mol.GetAtom(1) a2 = mol.GetAtom(...
Return inchi as molecular hash
def get_molecule_hash(self, mol): """ Return inchi as molecular hash """ obmol = BabelMolAdaptor(mol).openbabel_mol inchi = self._inchi_labels(obmol)[2] return inchi
Fit two molecules.
def fit(self, mol1, mol2): """ Fit two molecules. Args: mol1: First molecule. OpenBabel OBMol or pymatgen Molecule object mol2: Second molecule. OpenBabel OBMol or pymatgen Molecule object Returns: A boolean value indicates whether two molecules are ...
Get RMSD between two molecule with arbitrary atom order.
def get_rmsd(self, mol1, mol2): """ Get RMSD between two molecule with arbitrary atom order. Returns: RMSD if topology of the two molecules are the same Infinite if the topology is different """ label1, label2 = self._mapper.uniform_labels(mol1, mol2) ...
Calculate the RMSD.
def _calc_rms(mol1, mol2, clabel1, clabel2): """ Calculate the RMSD. Args: mol1: The first molecule. OpenBabel OBMol or pymatgen Molecule object mol2: The second molecule. OpenBabel OBMol or pymatgen Molecule object clabel1: Th...
Group molecules by structural equality.
def group_molecules(self, mol_list): """ Group molecules by structural equality. Args: mol_list: List of OpenBabel OBMol or pymatgen objects Returns: A list of lists of matched molecules Assumption: if s1=s2 and s2=s3, then s1=s3 This may...
Convert a dictionary representing a Fortran namelist into a string.
def nmltostring(nml): """Convert a dictionary representing a Fortran namelist into a string.""" if not isinstance(nml,dict): raise ValueError("nml should be a dict !") curstr = "" for key,group in nml.items(): namelist = ["&" + key] for k, v in group.items(): if isinstance(...
Initialize an instance from an: class: AbinitTask instance.
def from_node(cls, task): """Initialize an instance from an :class:`AbinitTask` instance.""" new = super().from_node(task) new.update( executable=task.executable, #executable_version: #task_events= pseudos=[p.as_dict() for p in task.input.pseudos]...
Read the AutoParal section ( YAML format ) from filename. Assumes the file contains only one section.
def parse(self, filename): """ Read the `AutoParal` section (YAML format) from filename. Assumes the file contains only one section. """ with abiinspect.YamlTokenizer(filename) as r: doc = r.next_doc_with_tag("!Autoparal") try: d = yaml.saf...
Build a list of Parallel configurations from two lists containing the number of MPI processes and the number of OpenMP threads i. e. product ( mpi_procs omp_threads ). The configuration have parallel efficiency set to 1. 0 and no input variables. Mainly used for preparing benchmarks.
def from_mpi_omp_lists(cls, mpi_procs, omp_threads): """ Build a list of Parallel configurations from two lists containing the number of MPI processes and the number of OpenMP threads i.e. product(mpi_procs, omp_threads). The configuration have parallel efficiency set to 1.0 and ...
Remove all the configurations that do not satisfy the given condition.
def select_with_condition(self, condition, key=None): """ Remove all the configurations that do not satisfy the given condition. Args: condition: dict or :class:`Condition` object with operators expressed with a Mongodb-like syntax key: Selects the sub-dictio...
Sort the configurations in place. items with highest efficiency come first
def sort_by_efficiency(self, reverse=True): """Sort the configurations in place. items with highest efficiency come first""" self._confs.sort(key=lambda c: c.efficiency, reverse=reverse) return self
Sort the configurations in place. items with highest speedup come first
def sort_by_speedup(self, reverse=True): """Sort the configurations in place. items with highest speedup come first""" self._confs.sort(key=lambda c: c.speedup, reverse=reverse) return self
Sort the configurations in place. items with lowest memory per proc come first.
def sort_by_mem_per_proc(self, reverse=False): """Sort the configurations in place. items with lowest memory per proc come first.""" # Avoid sorting if mem_per_cpu is not available. if any(c.mem_per_proc > 0.0 for c in self): self._confs.sort(key=lambda c: c.mem_per_proc, reverse=rev...
Sort and return a new list of configurations ordered according to the: class: TaskPolicy policy.
def get_ordered_with_policy(self, policy, max_ncpus): """ Sort and return a new list of configurations ordered according to the :class:`TaskPolicy` policy. """ # Build new list since we are gonna change the object in place. hints = self.__class__(self.info, confs=[c for c in self...
Converts an object obj into a: class: TaskPolicy. Accepts:
def as_policy(cls, obj): """ Converts an object obj into a `:class:`TaskPolicy. Accepts: * None * TaskPolicy * dict-like object """ if obj is None: # Use default policy. return TaskPolicy() else: if isinstan...
Initialize the: class: TaskManager from the YAML file manager. yaml. Search first in the working directory and then in the AbiPy configuration directory.
def from_user_config(cls): """ Initialize the :class:`TaskManager` from the YAML file 'manager.yaml'. Search first in the working directory and then in the AbiPy configuration directory. Raises: RuntimeError if file is not found. """ global _USER_CONFIG_TASKM...
Read the configuration parameters from the Yaml file filename.
def from_file(cls, filename): """Read the configuration parameters from the Yaml file filename.""" try: with open(filename, "r") as fh: return cls.from_dict(yaml.safe_load(fh)) except Exception as exc: print("Error while reading TaskManager parameters from...
Convert obj into TaskManager instance. Accepts string filepath dictionary TaskManager object. If obj is None the manager is initialized from the user config file.
def as_manager(cls, obj): """ Convert obj into TaskManager instance. Accepts string, filepath, dictionary, `TaskManager` object. If obj is None, the manager is initialized from the user config file. """ if isinstance(obj, cls): return obj if obj is None: return cls.from_u...
Create an instance from a dictionary.
def from_dict(cls, d): """Create an instance from a dictionary.""" return cls(**{k: v for k, v in d.items() if k in cls.ENTRIES})
Returns a new TaskManager with the same parameters as self but replace the: class: QueueAdapter with a: class: ShellAdapter with mpi_procs so that we can submit the job without passing through the queue.
def to_shell_manager(self, mpi_procs=1): """ Returns a new `TaskManager` with the same parameters as self but replace the :class:`QueueAdapter` with a :class:`ShellAdapter` with mpi_procs so that we can submit the job without passing through the queue. """ my_kwargs = copy.deepco...
Return a new TaskManager in which autoparal has been disabled. The jobs will be executed with mpi_procs MPI processes and omp_threads OpenMP threads. Useful for generating input files for benchmarks.
def new_with_fixed_mpi_omp(self, mpi_procs, omp_threads): """ Return a new `TaskManager` in which autoparal has been disabled. The jobs will be executed with `mpi_procs` MPI processes and `omp_threads` OpenMP threads. Useful for generating input files for benchmarks. """ ...
Given a list of parallel configurations pconfs this method select an optimal configuration according to some criterion as well as the: class: QueueAdapter to use.
def select_qadapter(self, pconfs): """ Given a list of parallel configurations, pconfs, this method select an `optimal` configuration according to some criterion as well as the :class:`QueueAdapter` to use. Args: pconfs: :class:`ParalHints` object with the list of parallel c...
This function is called when we have accepted the: class: ParalConf pconf. Returns pconf
def _use_qadpos_pconf(self, qadpos, pconf): """ This function is called when we have accepted the :class:`ParalConf` pconf. Returns pconf """ self._qadpos = qadpos # Change the number of MPI/OMP cores. self.set_mpi_procs(pconf.mpi_procs) if self.has_omp: ...
Write the submission script. Return the path of the script
def write_jobfile(self, task, **kwargs): """ Write the submission script. Return the path of the script ================ ============================================ kwargs Meaning ================ ============================================ exec_args ...
Build the input files and submit the task via the: class: Qadapter
def launch(self, task, **kwargs): """ Build the input files and submit the task via the :class:`Qadapter` Args: task: :class:`TaskObject` Returns: Process object. """ if task.status == task.S_LOCKED: raise ValueError("You shall not su...
Compare Abinit version to version_string with operator op
def compare_version(self, version_string, op): """Compare Abinit version to `version_string` with operator `op`""" from pkg_resources import parse_version from monty.operator import operator_from_str op = operator_from_str(op) return op(parse_version(self.version), parse_version(...
Convert delta into a MyTimedelta object.
def as_timedelta(cls, delta): """Convert delta into a MyTimedelta object.""" # Cannot monkey patch the __class__ and must pass through __new__ as the object is immutable. if isinstance(delta, cls): return delta return cls(delta.days, delta.seconds, delta.microseconds)
: class: timedelta with the run - time None if the Task is not running
def get_runtime(self): """:class:`timedelta` with the run-time, None if the Task is not running""" if self.start is None: return None if self.end is None: delta = datetime.datetime.now() - self.start else: delta = self.end - self.start return MyTimedelta...
: class: timedelta with the time spent in the Queue None if the Task is not running
def get_time_inqueue(self): """ :class:`timedelta` with the time spent in the Queue, None if the Task is not running .. note: This value is always greater than the real value computed by the resource manager as we start to count only when check_status sets the `Task` st...
Set the working directory. Cannot be set more than once unless chroot is True
def set_workdir(self, workdir, chroot=False): """Set the working directory. Cannot be set more than once unless chroot is True""" if not chroot and hasattr(self, "workdir") and self.workdir != workdir: raise ValueError("self.workdir != workdir: %s, %s" % (self.workdir, workdir)) se...
Set the: class: Work associated to this Task.
def set_work(self, work): """Set the :class:`Work` associated to this `Task`.""" if not hasattr(self, "_work"): self._work = work else: if self._work != work: raise ValueError("self._work != work")
The position of the task in the: class: Flow
def pos(self): """The position of the task in the :class:`Flow`""" for i, task in enumerate(self.work): if self == task: return self.work.pos, i raise ValueError("Cannot find the position of %s in flow %s" % (self, self.flow))
Set the values of the ABINIT variables in the input file. Return dict with old values.
def set_vars(self, *args, **kwargs): """ Set the values of the ABINIT variables in the input file. Return dict with old values. """ kwargs.update(dict(*args)) old_values = {vname: self.input.get(vname) for vname in kwargs} self.input.set_vars(**kwargs) if kwargs o...
Construct the input file of the calculation.
def make_input(self, with_header=False): """Construct the input file of the calculation.""" s = str(self.input) if with_header: s = str(self) + "\n" + s return s
Returns the path of the input file with extension ext. Use it when the file does not exist yet.
def ipath_from_ext(self, ext): """ Returns the path of the input file with extension ext. Use it when the file does not exist yet. """ return os.path.join(self.workdir, self.prefix.idata + "_" + ext)
Returns the path of the output file with extension ext. Use it when the file does not exist yet.
def opath_from_ext(self, ext): """ Returns the path of the output file with extension ext. Use it when the file does not exist yet. """ return os.path.join(self.workdir, self.prefix.odata + "_" + ext)
The task can run if its status is < S_SUB and all the other dependencies ( if any ) are done!
def can_run(self): """The task can run if its status is < S_SUB and all the other dependencies (if any) are done!""" all_ok = all(stat == self.S_OK for stat in self.deps_status) return self.status < self.S_SUB and self.status != self.S_LOCKED and all_ok
Cancel the job. Returns 1 if job was cancelled.
def cancel(self): """Cancel the job. Returns 1 if job was cancelled.""" if self.queue_id is None: return 0 if self.status >= self.S_DONE: return 0 exit_status = self.manager.cancel(self.queue_id) if exit_status != 0: logger.warning("manager.cancel returned exit_statu...
Disable autoparal and force execution with mpi_procs MPI processes and omp_threads OpenMP threads. Useful for generating benchmarks.
def with_fixed_mpi_omp(self, mpi_procs, omp_threads): """ Disable autoparal and force execution with `mpi_procs` MPI processes and `omp_threads` OpenMP threads. Useful for generating benchmarks. """ manager = self.manager if hasattr(self, "manager") else self.flow.manager ...
This method is called when the task reaches S_OK. It changes the extension of particular output files produced by Abinit so that the official extension is preserved e. g. out_1WF14 -- > out_1WF
def fix_ofiles(self): """ This method is called when the task reaches S_OK. It changes the extension of particular output files produced by Abinit so that the 'official' extension is preserved e.g. out_1WF14 --> out_1WF """ filepaths = self.outdir.list_filepaths()...
Called by restart once we have finished preparing the task for restarting.
def _restart(self, submit=True): """ Called by restart once we have finished preparing the task for restarting. Return: True if task has been restarted """ self.set_status(self.S_READY, msg="Restarted on %s" % time.asctime()) # Increase the counter. ...
Check if child process has terminated. Set and return returncode attribute.
def poll(self): """Check if child process has terminated. Set and return returncode attribute.""" self._returncode = self.process.poll() if self._returncode is not None: self.set_status(self.S_DONE, "status set to Done") return self._returncode
Wait for child process to terminate. Set and return returncode attribute.
def wait(self): """Wait for child process to terminate. Set and return returncode attribute.""" self._returncode = self.process.wait() try: self.process.stderr.close() except: pass self.set_status(self.S_DONE, "status set to Done") return self._re...
Interact with process: Send data to stdin. Read data from stdout and stderr until end - of - file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process or None if no data should be sent to the child.
def communicate(self, input=None): """ Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be s...
Kill the child.
def kill(self): """Kill the child.""" self.process.kill() self.set_status(self.S_ERROR, "status set to Error by task.kill") self._returncode = self.process.returncode
Reset the task status. Mainly used if we made a silly mistake in the initial setup of the queue manager and we want to fix it and rerun the task.
def reset(self): """ Reset the task status. Mainly used if we made a silly mistake in the initial setup of the queue manager and we want to fix it and rerun the task. Returns: 0 on success, 1 if reset failed. """ # Can only reset tasks that are done. ...
Lock the task source is the: class: Node that applies the lock.
def lock(self, source_node): """Lock the task, source is the :class:`Node` that applies the lock.""" if self.status != self.S_INIT: raise ValueError("Trying to lock a task with status %s" % self.status) self._status = self.S_LOCKED self.history.info("Locked by node %s", sour...
Unlock the task set its status to S_READY so that the scheduler can submit it. source_node is the: class: Node that removed the lock Call task. check_status if check_status is True.
def unlock(self, source_node, check_status=True): """ Unlock the task, set its status to `S_READY` so that the scheduler can submit it. source_node is the :class:`Node` that removed the lock Call task.check_status if check_status is True. """ if self.status != self.S_LOCK...
Set and return the status of the task.
def set_status(self, status, msg): """ Set and return the status of the task. Args: status: Status object or string representation of the status msg: string with human-readable message used in the case of errors. """ # truncate string if it's long. msg wi...
This function checks the status of the task by inspecting the output and the error files produced by the application and by the queue manager.
def check_status(self): """ This function checks the status of the task by inspecting the output and the error files produced by the application and by the queue manager. """ # 1) see it the job is blocked # 2) see if an error occured at submitting the job the job was sub...
Move an output file to the output data directory of the Task and rename the file so that ABINIT will read it as an input data file.
def out_to_in(self, out_file): """ Move an output file to the output data directory of the `Task` and rename the file so that ABINIT will read it as an input data file. Returns: The absolute path of the new file in the indata directory. """ in_file = os.path....
Create a symbolic link to the specified file in the directory containing the input files of the task.
def inlink_file(self, filepath): """ Create a symbolic link to the specified file in the directory containing the input files of the task. """ if not os.path.exists(filepath): logger.debug("Creating symbolic link to not existent file %s" % filepath) # Extract...
Create symbolic links to the output files produced by the other tasks.
def make_links(self): """ Create symbolic links to the output files produced by the other tasks. .. warning:: This method should be called only when the calculation is READY because it uses a heuristic approach to find the file to link. """ for dep in se...
Analyzes the main logfile of the calculation for possible Errors or Warnings. If the ABINIT abort file is found the error found in this file are added to the output report.
def get_event_report(self, source="log"): """ Analyzes the main logfile of the calculation for possible Errors or Warnings. If the ABINIT abort file is found, the error found in this file are added to the output report. Args: source: "output" for the main output file...
Returns: class: NodeResults instance. Subclasses should extend this method ( if needed ) by adding specialized code that performs some kind of post - processing.
def get_results(self, **kwargs): """ Returns :class:`NodeResults` instance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing. """ # Check whether the process completed. if self.returncode is Non...
Rename a file located in datadir.
def rename(self, src_basename, dest_basename, datadir="outdir"): """ Rename a file located in datadir. src_basename and dest_basename are the basename of the source file and of the destination file, respectively. """ directory = { "indir": self.indir, ...
Creates the working directory and the input files of the: class: Task. It does not overwrite files if they already exist.
def build(self, *args, **kwargs): """ Creates the working directory and the input files of the :class:`Task`. It does not overwrite files if they already exist. """ # Create dirs for input, output and tmp data. self.indir.makedirs() self.outdir.makedirs() ...
Remove all the files listed in filenames.
def remove_files(self, *filenames): """Remove all the files listed in filenames.""" filenames = list_strings(filenames) for dirpath, dirnames, fnames in os.walk(self.workdir): for fname in fnames: if fname in filenames: filepath = os.path.join(dir...
This method is called when the task reaches S_OK. It removes all the output files produced by the task that are not needed by its children as well as the output files produced by its parents if no other node needs them.
def clean_output_files(self, follow_parents=True): """ This method is called when the task reaches S_OK. It removes all the output files produced by the task that are not needed by its children as well as the output files produced by its parents if no other node needs them. Args...
Starts the calculation by performing the following steps:
def start(self, **kwargs): """ Starts the calculation by performing the following steps: - build dirs and files - call the _setup method - execute the job file by executing/submitting the job script. Main entry point for the `Launcher`. ============...
Helper method to start the task and wait for completion.
def start_and_wait(self, *args, **kwargs): """ Helper method to start the task and wait for completion. Mainly used when we are submitting the task via the shell without passing through a queue manager. """ self.start(*args, **kwargs) retcode = self.wait() return...
Generate task graph in the DOT language ( only parents and children of this task ).
def get_graphviz(self, engine="automatic", graph_attr=None, node_attr=None, edge_attr=None): """ Generate task graph in the DOT language (only parents and children of this task). Args: engine: ['dot', 'neato', 'twopi', 'circo', 'fdp', 'sfdp', 'patchwork', 'osage'] graph_...
Create an instance of AbinitTask from an ABINIT input.
def from_input(cls, input, workdir=None, manager=None): """ Create an instance of `AbinitTask` from an ABINIT input. Args: ainput: `AbinitInput` object. workdir: Path to the working directory. manager: :class:`TaskManager` object. """ return c...
Build a Task with a temporary workdir. The task is executed via the shell with 1 MPI proc. Mainly used for invoking Abinit to get important parameters needed to prepare the real task.
def temp_shell_task(cls, inp, mpi_procs=1, workdir=None, manager=None): """ Build a Task with a temporary workdir. The task is executed via the shell with 1 MPI proc. Mainly used for invoking Abinit to get important parameters needed to prepare the real task. Args: mpi_procs...
Abinit has the very * bad * habit of changing the file extension by appending the characters in [ A B... Z ] to the output file and this breaks a lot of code that relies of the use of a unique file extension. Here we fix this issue by renaming run. abo to run. abo_ [ number ] if the output file run. abo already exists....
def setup(self): """ Abinit has the very *bad* habit of changing the file extension by appending the characters in [A,B ..., Z] to the output file, and this breaks a lot of code that relies of the use of a unique file extension. Here we fix this issue by renaming run.abo to run.abo_[numb...
Return the subclass of ScfCycle associated to the task or None if no SCF algorithm if associated to the task.
def cycle_class(self): """ Return the subclass of ScfCycle associated to the task or None if no SCF algorithm if associated to the task. """ if isinstance(self, RelaxTask): return abiinspect.Relaxation elif isinstance(self, GsTask): return abiinspe...
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 input file app(self.output_file.path) # Path to t...
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 == value and isinstance(self, GsTask)
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 old_lattice = old_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.
def autoparal_run(self): """ 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:`Paral...
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.select_qadapter(pconfs) return optcon...
Helper function used to select the files of a task.
def select_files(self, what="o"): """ 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, ...
method to fix crashes/ error caused by abinit
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 if not event_handlers: self.set_status(status=self.S_ERROR, msg='Empty list of event han...
This function tries to fix critical events originating from the queue submission system.
def fix_queue_critical(self): """ 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 deman...
Parse the timer data in the main output file of Abinit. Requires timopt/ = 0 in the input file ( usually timopt = - 1 )
def parse_timing(self): """ 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. """ from .abitimer import AbinitTimerParser parser = Abini...
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: path = self.outdir.has_abiext("HIST") if path: sel...
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 file is not readable. """ if not self.hist_path: if self.status == self.S_OK: logger.critical("%s reached S_...
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: path = self.outdir.has_abiext("GSR") if path: self._g...
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 not readable. """ gsr_path = self.gsr_path if not gsr_path: if self.status == self.S_OK: logger...
Plot the SCF cycle results with matplotlib.
def inspect(self, **kwargs): """ Plot the SCF cycle results with matplotlib. Returns `matplotlib` figure, None if some error occurred. """ try: scf_cycle = abiinspect.GroundStateScfCycle.from_file(self.output_file.path) except IOError: ...
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 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. """ ...
Restart the structural relaxation.
def restart(self): """ 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 ...
Plot the evolution of the structural relaxation with matplotlib.
def inspect(self, **kwargs): """ 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, forc...
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
def fix_ofiles(self): """ 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 havin...
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: path = self.outdir.has_abiext("DDB") if path: self._d...
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 Abinit have a file extensi...
def make_links(self): """ 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 fac...
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 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. """ # Abinit adds the idir-...
Plot the Phonon SCF cycle results with matplotlib.
def inspect(self, **kwargs): """ Plot the Phonon SCF cycle results with matplotlib. Returns: `matplotlib` figure, None if some error occurred. """ scf_cycle = abiinspect.PhononScfCycle.from_file(self.output_file.path) if scf_cycle is not None: if ...
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. Returns True in case of success, False in case of Failure. """ # The first digit governs the storage of W(q), the second digit the storage of u(r) ...
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: path = self.outdir.has_abiext("SCR.nc") if path: self...