autojob.calculation package

Store the results of a Task representing a calculation.

autojob.calculation.copy_atom_metadata(input_atoms: Atoms | None, output_atoms: Atoms) None[source]

Copy tags, constraints, and info from the input to output atoms.

This function modifies output_atoms in place.

Parameters:

Subpackages

Submodules

autojob.calculation.calculation module

Store the results of a calculation.

This module defines the autojob.calculation.calculation.Calculation, autojob.calculation.calculation.CalculationInputs, and autojob.calculation.calculation.CalculationOutputs classes. Instances of these classes represent the results of a calculation, its inputs, and its outputs, respectively.

For building the respective documents from a folder, each class exposes a from_directory() method.

Example

from autojob.calculation.calculation import Calculation

dir_name = "path/to/calculation/directory"
results = Calculation.from_directory(dir_name)
class autojob.calculation.calculation.Analysis(*, delta_volume: float | None = None, delta_volume_percent: float | None = None, max_force: float | None = None, warnings: list[str] | None = None, errors: list[str] | None = None)[source]

Bases: BaseModel

Analysis from a calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

delta_volume: float | None
delta_volume_percent: float | None
errors: list[str] | None
max_force: float | None
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'delta_volume': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, title='Volume Change', description='Volume change for the calculation.'), 'delta_volume_percent': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, title='Volume Change Percent', description='Percent volume change for the calculation.'), 'errors': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=None, title='Calculation Errors', description='Errors issued after analysis.'), 'max_force': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, title='Max Force', description='Maximum force on any atom at the end of the calculation.'), 'warnings': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=None, title='Calculation Warnings', description='Warnings issued after analysis.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

warnings: list[str] | None
class autojob.calculation.calculation.Calculation(*, task_metadata: TaskMetadata, task_inputs: TaskInputs, task_outputs: TaskOutputs | None = None, calculation_inputs: CalculationInputs, calculation_outputs: CalculationOutputs | None = None, scheduler_inputs: SchedulerInputs, scheduler_outputs: SchedulerOutputs | None = None, **extra_data: Any)[source]

Bases: Task

A record representing a calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

calculation_inputs: CalculationInputs
calculation_outputs: CalculationOutputs | None
static create_shell(context: dict[str, Any] | None = None) Calculation[source]

Creates a minimal Calculation with defaults set.

Parameters:

context – A dictionary to be used to seed values in the shell. Defaults to None.

Returns:

A new Calculation with no outputs.

classmethod from_directory(dir_name: str | Path, *, strict_mode: bool = True, magic_mode: bool = False, calculator_type: CalculatorType | None = None, task: Task | None = None) Self[source]

Generate a Calculation document from a calculation directory.

Parameters:
  • dir_name – The directory of a calculation.

  • strict_mode – Whether to raise an error if no output atoms found. Defaults to SETTINGS.STRICT_MODE.

  • magic_mode – Whether to defer the final object creation. If True, the final object will be an instance of the class specified by the _build_class attribute of the TaskMetadata object created. Otherwise, a Calculation object will be returned. Defaults to False.

  • calculator_type – The type of calculation run. Must correspond to an ASE calculator.

  • task – A task.Task from which to build the Calculation.

    Deprecated since version 0.12.0: This parameter is ignored since task metadata, inputs, and outputs are now always loaded using super().from_directory().

Returns:

A Calculation object.

static get_files_to_carryover(calculator_type: CalculatorType) list[str][source]

Returns a list of strings representing the files to be carried over.

Parameters:

calculator_type – The type of calculator used in the calculation.

static get_output_atoms(dir_name: str | Path, input_atoms: Atoms, calculator_type: CalculatorType, *, strict_mode: Literal[True]) Atoms[source]
static get_output_atoms(dir_name: str | Path, input_atoms: Atoms, calculator_type: CalculatorType, *, strict_mode: Literal[False]) Atoms | None

Retrieve output Atoms from a Calculation.

Parameters:
  • dir_name – The directory of a calculation.

  • calculator_type – The type of calculation run. Must correspond to an ASE calculator.

  • input_atoms – An Atoms object representing the corresponding input structure.

  • strict_mode – Whether to raise an error if no output atoms found. Defaults to SETTINGS.STRICT_MODE.

Raises:

FileNotFoundError – Unable to find output atoms file.

Returns:

An Atoms object representing the output structure.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'calculation_inputs': FieldInfo(annotation=CalculationInputs, required=True), 'calculation_outputs': FieldInfo(annotation=Union[CalculationOutputs, NoneType], required=False, default=None), 'scheduler_inputs': FieldInfo(annotation=SchedulerInputs, required=True), 'scheduler_outputs': FieldInfo(annotation=Union[SchedulerOutputs, NoneType], required=False, default=None), 'task_inputs': FieldInfo(annotation=TaskInputs, required=True, description='Task inputs'), 'task_metadata': FieldInfo(annotation=TaskMetadata, required=True), 'task_outputs': FieldInfo(annotation=Union[TaskOutputs, NoneType], required=False, default=None, description='Task outputs')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

scheduler_inputs: hpc.SchedulerInputs
scheduler_outputs: hpc.SchedulerOutputs | None
write_inputs(dir_name: str | Path, *, run_script_template: str = 'run.sh.j2', **kwargs) list[Path][source]

Write the required inputs for a Calculation to a directory.

Parameters:
  • dir_name – The directory in which to write the inputs.

  • run_script_template – The template file to use. Defaults to SETTINGS.SLURM_TEMPLATE.

  • **kwargs – additional keyword arguments to be used to render the script template.

Returns:

A list of Path objects where each Path represents the filename of an input written to dir_name.

write_python_script(dst: Path, *, template: str = 'run.py.j2', structure_name: str | None = None) Path[source]

Write the Python script used to run the Calculation.

Parameters:
  • dst – The directory in which to write the Python script.

  • template – The name of the template to use to write the Python script.

  • structure_name – The filename of the input structure to be read to load the Atoms object for the calculation. Defaults to the value of the "filename" key in the input Atoms object, if present. Defaults to the value of SETTINGS.INPUT_ATOMS otherwise. Take care to ensure that this matches the name of the file to which the structure is written.

Returns:

A Path object representing the filename of the written Python script.

write_script(dst: Path, *, run_script_template: str = 'run.sh.j2', **kwargs) Path[source]

Write the SLURM input script using the template given.

Parameters:
  • dst – The directory in which to write the SLURM file.

  • run_script_template – The template file to use. Defaults to SETTINGS.SLURM_TEMPLATE.

  • **kwargs – additional keyword arguments to be used to render the script template.

Returns:

A Path representing the filename of the written SLURM script.

class autojob.calculation.calculation.CalculationInputs(*, ase_calculator: ImportString = 'ase.calculators.vasp.Vasp', parameters: dict[str, Any] = {}, kpoints: Kpoints | Sequence[int] | None = None, xc_override: str | None = None, is_lasph: bool | None = None, is_hubbard: bool = False, hubbards: dict[str, Any] | None = None, pseudopotentials: Pseudopotential | None = None, calculation_objects: dict[str, Any] | None = None, run_bader: bool = False, run_chargemol: bool = False, **extra_data: Any)[source]

Bases: BaseModel

The inputs for the calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

ase_calculator: ImportString
calculation_objects: dict[str, Any] | None
check_inputs() list[str][source]

Verify the input parameters.

static extract_calculation_parameters(stream: TextIO) tuple[list[Any], dict[str, Any]][source]

Extract parameters used to configure ASE calculator.

All imports with ASE calculators must use fully qualified module names. All calculator configuration arguments must be passed by keyword in order to be recognized.

Parameters:

stream – a TextIO containing the lines of code.

Raises:

RuntimeError – Unable to extract calculation parameters.

Returns:

A list and dictionary. This list contains positional arguments used to configure the calculator while the dictionary maps calculator parameters to their values.

static extract_imported_ase_calculators(stream: TextIO) list[tuple[str, str | None]][source]

Determine which ASE calculators a script imports.

Parameters:

stream – A TextIO containing the script.

Returns:

A list of strings tuples (calculator, alias) where calculator and alias are the class and alias (“as name”) of an imported ASE calculator, respectively.

Warning

This is only tests for imports of the sort:

from ase.calculator.module import Calculator

or

import ase.calculator.module.Calculator as Calculator

It has not expected to behave well when the calculator is imported like:

import ase.calculator.module.Calculator
classmethod from_directory(*, dir_name: str | Path, calculator_type: CalculatorType | None = None) CalculationInputs[source]

Generate a CalculationInputs document from a calculation’s directory.

Parameters:
  • dir_name – The directory of a calculation.

  • calculator_type – The calculator type. Must correspond to an ASE calculator

Returns:

A CalculationInputs object with the calculator parameters and ASE calculator used to perform the calculation.

hubbards: dict[str, Any] | None
is_hubbard: bool
is_lasph: bool | None
kpoints: Kpoints | Sequence[int] | None
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'ase_calculator': FieldInfo(annotation=ImportString, required=False, default='ase.calculators.vasp.Vasp', description='The ASE Calculator used to perform this calculation'), 'calculation_objects': FieldInfo(annotation=Union[dict[str, Any], NoneType], required=False, default=None, description='Calculation objects provided as inputs to this calculation'), 'hubbards': FieldInfo(annotation=Union[dict[str, Any], NoneType], required=False, default=None, description='The hubbard parameters used'), 'is_hubbard': FieldInfo(annotation=bool, required=False, default=False, description='Is this a Hubbard+U calculation'), 'is_lasph': FieldInfo(annotation=Union[bool, NoneType], required=False, default=None, description='Whether the calculation was run with aspherical corrections'), 'kpoints': FieldInfo(annotation=Union[Kpoints, Sequence[int], NoneType], required=False, default=None, description='Pymatgen object representing the KPOINTS file'), 'parameters': FieldInfo(annotation=dict[str, Any], required=False, default={}, description='The parameters used to configure the ASE calculator'), 'pseudopotentials': FieldInfo(annotation=Union[Pseudopotential, NoneType], required=False, default=None, description='Summary of the pseudopotentials used in this calculation'), 'run_bader': FieldInfo(annotation=bool, required=False, default=False, description='Whether or not to run Bader charge analysis'), 'run_chargemol': FieldInfo(annotation=bool, required=False, default=False, description='Whether or not to run Chargemol charge analysis'), 'xc_override': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description='Exchange-correlation functional used if not the default')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

parameters: dict[str, Any]
pseudopotentials: Pseudopotential | None
run_bader: bool
run_chargemol: bool
classmethod validate_ase_class(v: Any) Any[source]

Validate an instance of calculator.Calculator.

Parameters:

v – A value to be validated.

Raises:

ValueError – Unable to validate the value.

Returns:

_description_

xc_override: str | None
class autojob.calculation.calculation.CalculationOutputs(*, density: float | None = None, energy: float | None = None, forces: list[list[float]] | None = None, stress: list[list[float]] | None = None, energy_per_atom: float | None = None, bandgap: float | None = None, converged: bool = False, analysis: Analysis | None = None, calculation_objects: dict[str, Any] | None = None, bader_analysis: BaderAnalysis | None = None, ddec6_analysis: DDEC6Analysis | None = None, **extra_data: Any)[source]

Bases: BaseModel

The outputs of a calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

analysis: Analysis | None
bader_analysis: BaderAnalysis | None
bandgap: float | None
calculation_objects: dict[str, Any] | None
converged: bool
ddec6_analysis: DDEC6Analysis | None
density: float | None
energy: float | None
energy_per_atom: float | None
forces: list[list[float]] | None
classmethod from_directory(*, dir_name: str | Path, calculator_type: CalculatorType | None = None, strict_mode: bool = True) CalculationOutputs[source]

Generate a CalculationOutputs document from a calculation directory.

Parameters:
  • dir_name – The directory of a calculation.

  • calculator_type – The type of calculation run. Must correspond to an ASE calculator.

  • strict_mode – Whether or not to require all outputs. If True, errors will be thrown on missing outputs.

Returns:

A CalculationOutputs object.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'analysis': FieldInfo(annotation=Union[Analysis, NoneType], required=False, default=None, title='Calculation Analysis', description='Some analysis of calculation data after collection.'), 'bader_analysis': FieldInfo(annotation=Union[BaderAnalysis, NoneType], required=False, default=None, description='A Bader charge analysis document'), 'bandgap': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The DFT bandgap for the last calculation'), 'calculation_objects': FieldInfo(annotation=Union[dict[str, Any], NoneType], required=False, default=None, description='Calculation objects returned as outputs of this calculation'), 'converged': FieldInfo(annotation=bool, required=False, default=False, description='Whether or not the calculaton has converged'), 'ddec6_analysis': FieldInfo(annotation=Union[DDEC6Analysis, NoneType], required=False, default=None, description='A DDEC6 charge analysis document'), 'density': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='Density of in units of g/cc.'), 'energy': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='Total Energy in units of eV.'), 'energy_per_atom': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The final DFT energy per atom for the last calculation'), 'forces': FieldInfo(annotation=Union[list[list[float]], NoneType], required=False, default=None, description='The force on each atom in units of eV/Å.'), 'stress': FieldInfo(annotation=Union[list[list[float]], NoneType], required=False, default=None, description='The stress on the cell in units of kB.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

stress: list[list[float]] | None
class autojob.calculation.calculation.Pseudopotential(*, pot_type: str | None = None, functional: str | None = None, symbols: list[str] | None = None)[source]

Bases: BaseModel

A pseudopotential.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

functional: str | None
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'functional': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description='Functional type use in the calculation.'), 'pot_type': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, description='Pseudo-potential type, e.g. PAW'), 'symbols': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=None, description='List of VASP potcar symbols used in the calculation.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

pot_type: str | None
symbols: list[str] | None
autojob.calculation.calculation.check_bader(parameters: dict[str, Any]) list[str][source]

Peform parameter checks for Bader analysis.

autojob.calculation.calculation.read_energy(dir_name: Path, *, strict_mode: Literal[False]) float | None[source]
autojob.calculation.calculation.read_energy(dir_name: Path, *, strict_mode: Literal[True]) float

Read the final energy from the output atoms.

Parameters:
  • dir_name – The path to the calculation directory.

  • strict_mode – Whether or not to raise an error if unable to retrieve the energy. If True, one of FileNotFound, PropertyNotImplemented, or RuntimeError will be raised if unable to retrieve the energy.

Returns:

A float representing the energy. If unable to read the energy and strict_mode is disable, this function will return None.

autojob.calculation.calculation.read_forces(dir_name: Path, *, strict_mode: Literal[False]) list[list[float]] | None[source]
autojob.calculation.calculation.read_forces(dir_name: Path, *, strict_mode: Literal[True]) list[list[float]]

Read the final forces from the output atoms.

Parameters:
  • dir_name – The path to the calculation directory.

  • strict_mode – Whether or not to raise an error if unable to retrieve the forces. If True, one of FileNotFound, PropertyNotImplemented, or RuntimeError will be raised if unable to retrieve the forces. Defaults to SETTINGS.STRICT_MODE.

Returns:

A list of lists of floats representing the forces. If unable to read the energy and strict_mode is disable, this function will return None.

autojob.calculation.calculators module

Specify the configurable parameters for a calculator.

class autojob.calculation.calculators.CalculatorConfiguration(calculator_parameters: Iterable[parameters.CalculatorParameter], values: Iterable | None = None)[source]

Bases: MutableMapping, MSONable

A set of calculator parameters.

Create a CalculatorConfiguration from parameters and values.

Parameters:
as_dict() dict[str, Any][source]

Convert the CalculatorConfiguration to a dictionary.

The parameters.CalculatorParameter s are stored as dictionaries, and the underlying dictionary is stored as a list of 2-tuples where the first element corresponds to the CalculatorParameter and the second element corresponds to the value.

classmethod from_dict(d) CalculatorConfiguration[source]

Return a CalculatorConfiguration from a dictionary.

This method is implemented to enable round-trips from calculators.CalculatorConfiguration.as_dict() and calculators.CalculatorConfiguration.from_dict().

static initialize_values(calculator_parameters: Iterable[parameters.CalculatorParameter]) dict[parameters.CalculatorParameter, Any][source]

Initialize the values of a CalculatorConfiguration.

Parameters:

calculator_parameters – An iterable of parameters.CalculatorParameter s for which from which to initialize the CalculatorConfiguration.

Returns:

A dictionary mapping parameters.CalculatorParameter s to their value in the configuration.

autojob.calculation.charge module

Harvest charge analysis results from completed task directory.

class autojob.calculation.charge.BaderAnalysis[source]

Bases: TypedDict

Bader change analysis data.

atomic_densities: list[BaderDensity]
chgcar: Chgcar
data: BaderData
nelectrons: int
vacuum_charge: float
vacuum_volume: float
class autojob.calculation.charge.BaderData[source]

Bases: TypedDict

Bader change analysis data.

atomic_vol: float
charge: float
min_dist: float
x: float
y: float
z: float
class autojob.calculation.charge.BaderDensity[source]

Bases: TypedDict

Bader density data.

data: list[list[float]]
dim: list[float]
shift: list[float]
class autojob.calculation.charge.DDEC6Analysis[source]

Bases: TypedDict

DDEC6 analysis data.

bond_order_dict: dict[int, _BondOrders]
dipoles: list[float]
partial_charges: list[float]
rcubed_moments: list[float]
rfourth_moments: list[float]
rsquared_moments: list[float]
spin_moments: list[float]
autojob.calculation.charge.get_ddec6_index_map(dir_name: str | Path) list[int][source]

Return a list of integers mapping DDEC6 indices to ASE indices.

The ASE index of the atom at index i in the DDEC6 structure can be found as follows:

index_map = get_ddec6_index_map(dir_name) index = index_map[i]

Parameters:

dir_name – The directory containing a calculation.

autojob.calculation.charge.load_ddec6_data(dir_name: str | Path) DDEC6Analysis[source]

Extract the DDEC6 data from the job directory.

Parameters:

dir_name – The directory of the completed calculation.

Returns:

The DDEC6 data. If no data is found, every value will be None.

autojob.calculation.espresso module

Read and standardize Quantum Espresso outputs.

autojob.calculation.espresso.get_output_atoms(dir_name: str | Path, alt_filename_index: int | None = None, input_atoms: Atoms | None = None) Atoms[source]

Retrieve an Atoms object representing the output structure.

This function also copies tags and constraints from the input structure in the case that the output structure must be read from a non-ASE file (e.g., pwscf.save).

Parameters:
  • dir_name – The directory from which to retrieve the output structure.

  • alt_filename_index – An integer pointing to which alternative structure file should be used. This number will be used to index ALTERNATE_OUTPUT_STRUCTURES.

  • input_atoms – An Atoms object representing the corresponding input structure.

Returns:

An Atoms object representing the output structure.

autojob.calculation.espresso.load_calculation_outputs(dir_name: str | Path) dict[str, Any][source]

Load calculation outputs for a Quantum Espresso calculation.

Note that all quantities other than the final energy are reported in atomic units (Hartree/Bohr).

Parameters:

dir_name – The directory containing the Espresso (PWscf) output files.

Returns:

A dictionary containing Espresso calculation outputs.

Warning

That a calculation has converged must be confirmed manually as the value of the "converged" key is always set to False.

autojob.calculation.gaussian module

Read and standardize Gaussian outputs.

class autojob.calculation.gaussian.GaussianParameters[source]

Bases: TypedDict

WIP.

autojob.calculation.gaussian.get_output_atoms(dir_name: str | Path, alt_filename_index: int | None = None, input_atoms: Atoms | None = None) Atoms[source]

Retrieve an Atoms object representing the output structure.

This function also copies tags and constraints from the input structure in the case that the output structure must be read from a non-ASE file (e.g., Gaussian.log).

Parameters:
  • dir_name – The directory from which to retrieve the output structure.

  • alt_filename_index – An integer pointing to which alternative structure file should be used. This number will be used to index ALTERNATE_OUTPUT_STRUCTURES.

  • input_atoms – An Atoms object representing the corresponding input structure.

Returns:

An Atoms object representing the output structure.

autojob.calculation.gaussian.load_calculation_outputs(dir_name: str | Path) dict[str, Any][source]

Load calculation outputs for a Gaussian calculation.

Note that all quantities other than the final energy are reported in atomic units (Hartree/Bohr).

Parameters:

dir_name – The directory containing the Gaussian output files.

Returns:

A dictionary containing Gaussian calculation outputs.

autojob.calculation.infrared module

Retrieve outputs from an infrared calculation.

This module provides the InfraredOutputs and Infrared classes. The results from infrared calculations can be retrieve using the InfraredOutputs.from_directory() and Infrared.from_directory() methods.

Example

from pathlib import Path
from autojob.calculation.infrared import Infrared

task = Infrared.from_directory(Path.cwd())
class autojob.calculation.infrared.Infrared(*, task_metadata: TaskMetadata, task_inputs: TaskInputs, task_outputs: TaskOutputs | None = None, calculation_inputs: CalculationInputs, calculation_outputs: CalculationOutputs | None = None, scheduler_inputs: SchedulerInputs, scheduler_outputs: SchedulerOutputs | None = None, vibration_inputs: VibrationInputs, vibration_outputs: VibrationOutputs | None = None, infrared_outputs: InfraredOutputs | None = None, **extra_data: Any)[source]

Bases: Vibration

An infrared calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

static create_shell(context: dict[str, Any] | None = None) Infrared[source]

Create a minimal Infrared shell.

Parameters:

context – A dictionary mapping attribute paths to their values. For example, the "infrared_outputs" key will be used to set the infrared_outputs attribute in the returned object.

Returns:

An Infrared object initialized with the values in context.

classmethod from_directory(dir_name: str | Path, *, strict_mode: bool = True, magic_mode: bool = False, calculator_type: CalculatorType | None = None, task: Task | None = None) Self[source]

Generate a Infrared document from a calculation directory.

Parameters:
  • dir_name – The directory of a infrared calculation.

  • strict_mode – Whether to raise an error if no output atoms found. Defaults to SETTINGS.STRICT_MODE.

  • magic_mode – Whether to defer the final object creation. If True, the final object will be an instance of the class specified by the _build_class attribute of the TaskMetadata object created. Otherwise, a Infrared object will be returned. Defaults to False.

  • calculator_type – The type of calculation run. Must correspond to an ASE calculator.

  • task – A Task from which to build the Infrared.

    Deprecated since version 0.12.0: This parameter is ignored since task metadata, inputs, and outputs are now always loaded using super().from_directory().

Returns:

A Vibration object.

infrared_outputs: InfraredOutputs | None
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'calculation_inputs': FieldInfo(annotation=CalculationInputs, required=True), 'calculation_outputs': FieldInfo(annotation=Union[CalculationOutputs, NoneType], required=False, default=None), 'infrared_outputs': FieldInfo(annotation=Union[InfraredOutputs, NoneType], required=False, default=None), 'scheduler_inputs': FieldInfo(annotation=SchedulerInputs, required=True), 'scheduler_outputs': FieldInfo(annotation=Union[SchedulerOutputs, NoneType], required=False, default=None), 'task_inputs': FieldInfo(annotation=TaskInputs, required=True, description='Task inputs'), 'task_metadata': FieldInfo(annotation=TaskMetadata, required=True), 'task_outputs': FieldInfo(annotation=Union[TaskOutputs, NoneType], required=False, default=None, description='Task outputs'), 'vibration_inputs': FieldInfo(annotation=VibrationInputs, required=True), 'vibration_outputs': FieldInfo(annotation=Union[VibrationOutputs, NoneType], required=False, default=None)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

write_python_script(dst: Path, *, template: str = 'infrared.py.j2', structure_name: str | None = 'in.traj') Path[source]

Write the Python script for the IR calcuation.

Parameters:
  • dst – A Path indicating to where the script will be written.

  • template – The template to use to write the script. Defaults to "infrared.py.j2".

  • structure_name – The filename of the input structure to be read to load the Atoms object for the calculation. Defaults to the value of the "filename" key in the input Atoms object, if present. Defaults to the value of SETTINGS.INPUT_ATOMS otherwise. Take care to ensure that this matches the name of the file to which the structure is written.

Returns:

A Path object representing the filename of the written Python script.

class autojob.calculation.infrared.InfraredOutputs(*, ir_frequencies: list[complex] | None = None, ir_intensities: list[float] | None = None, ir_absorbance: list[float] | None = None)[source]

Bases: BaseModel

The outputs of an infrared calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

classmethod from_directory(dir_name: str | Path, *, out: str = 'ir-spectra.dat', strict_mode: bool = True) InfraredOutputs[source]

Extract infrared data from the input structure of the directory.

Parameters:
  • dir_name – The directory of the completed calculation.

  • out – The name of the file from which to read the IR data. Defaults to "ir-spectra.dat".

  • strict_mode – Whether or not to require all outputs. If True, errors will be thrown on missing outputs. Defaults to SETTINGS.STRICT_MODE.

Returns:

The infrared data as InfraredOutputs. If no data is found, and strict_mode = False every value will be None.

ir_absorbance: list[float] | None
ir_frequencies: list[complex] | None
ir_intensities: list[float] | None
model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'populate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'ir_absorbance': FieldInfo(annotation=Union[list[float], NoneType], required=False, default=None, alias='IR Absorbance', alias_priority=2), 'ir_frequencies': FieldInfo(annotation=Union[list[complex], NoneType], required=False, default=None, alias='IR Frequencies', alias_priority=2), 'ir_intensities': FieldInfo(annotation=Union[list[float], NoneType], required=False, default=None, alias='IR Intensities', alias_priority=2)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

autojob.calculation.parameters module

Define calculator parameters.

class autojob.calculation.parameters.CalculatorParameter(name: str = '', allowed_types: tuple[type] = (typing.Any,), special_values: Iterable | None = None, default: Any = None, description: str = '')[source]

Bases: MSONable

Abstraction of an calculator parameter for a supported ASE calculator.

Variables:
  • name (str; defaults to '') – The name of the CalculatorParameter.

  • allowed_types (Iterable[Type]; defaults to (Any,)) – The allowed types for the CalculatorParameter. For validation and displaying (in the GUI application) purposes, if there exists special values for the CalculatorParameter (e.g., string values that correspond to particular values), the allowed types should not be designated so as to include these special values.

  • integer (For example, say that a particular CalculatorParameter accepts)

  • particular (values, but that the string 'normal' corresponds to a)

  • be (value. The allowed types for the CalculatorParameter should)

  • as (specified)

  • special_values (Iterable; defaults to tuple()) – A tuple indicating the

  • whose (special values of a CalculatorParameter. These may be values)

  • attribute (types do not conform to the types specified in the)

  • 'allowed_types'.

  • _default (Any; defaults to None) – A default value for the

  • CalculatorParameter.

  • description (str; defaults to '') – Returns a description of the

  • tooltips. (CalculatorParameter to be used for displaying)

Initialize a CalculatorParameter.

Parameters:
  • name – The name of the CalculatorParameter. Defaults to “”.

  • allowed_types – An iterable of the allowed types for the parameter. Defaults to (Any,).

  • special_values – An iterable of the special values for the parameter. Defaults to None.

  • default – The default value for the parameter. Defaults to None.

  • description – A description of the parameter. Defaults to “”.

property allowed_types: tuple

The allowed types for the parameter.

property default: Any

The default value of the parameter.

property special_values: tuple

The special values of the parameter.

validate(val: Any) bool[source]

Validate a parameter value.

class autojob.calculation.parameters.CalculatorType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

A type of ASE calculator.

ABINIT = 'abinit'
ACE = 'ace'
AIMS = 'aims'
AMBER = 'amber'
ASAP = 'asap'
CASTEP = 'castep'
CP2K = 'cp2k'
CRYSTAL = 'crystal'
DEFAULT = 'vasp'
DEMON = 'demon'
DEMON_NANO = 'demonnano'
DFTB = 'dftb'
DFTD3 = 'dftd3'
DMOL3 = 'dmol'
EAM = 'eam'
ELK = 'elk'
EMT = 'emt'
ESPRESSO = 'espresso'
EXCITING = 'exciting'
FLEUR = 'fleur'
FORCE_FIELD = 'ff'
GAMESS_US = 'gamess_us'
GAUSSIAN = 'gaussian'
GPAW = 'gpaw'
GROMACS = 'gromacs'
GULP = 'gulp'
HOTBIT = 'hotbit'
KIM = 'kim'
LAMMPS = 'lammpsrun'
LAMMPS_LIB = 'lammpslib'
LENNARD_JONES = 'lj'
MOPAC = 'mopac'
MORSE_POTENTIAL = 'morse'
NWCHEM = 'nwchem'
OCTOPUS = 'octopus'
ONETEP = 'onetep'
OPENMX = 'openmx'
ORCA = 'orca'
PSI4 = 'psi4'
QCHEM = 'qchem'
SIESTA = 'siesta'
TIP3P = 'tip3p'
TIP4P = 'tip4p'
TURBOMOLE = 'turbomole'
VASP = 'vasp'
is_implemented() bool[source]

Return whether the CalculatorType is implemented or not.

class autojob.calculation.parameters.MappingParameter(*, member_types: Iterable[type], name: str = '', special_values: Iterable | None = None, default: Any = None, description: str = '')[source]

Bases: CalculatorParameter

A parameter that can be a mapping.

Initialize a MappingParameter.

Parameters:
  • name – The name of the MappingParameter. Defaults to “”.

  • member_types – The allowed types of the items in the sequence.

  • special_values – An iterable of the special values for the parameter. Defaults to None.

  • default – The default value for the parameter. Defaults to None.

  • description – A description of the parameter. Defaults to “”.

as_dict() dict[source]

Return the MappingParameter as a dictionary.

classmethod from_dict(d) MappingParameter[source]

Initiate a MappingParameter from a dictionary.

property member_types: Iterable

The allowed member types of the parameter.

validate(val: Any) bool[source]

Validate a value.

class autojob.calculation.parameters.NumberMappingParameter(*, name: str = '', allow_floats: bool = False, special_values: Iterable | None = None, default: Any = None, description: str = '', number_range: NumberRange = None)[source]

Bases: MappingParameter

A parameter that can be a mapping to numbers.

Initialize a NumberMappingParameter.

Parameters:
  • name – The name of the NumberMappingParameter. Defaults to “”.

  • allow_floats – Whether to allow floats. Defaults to False.

  • special_values – An iterable of the special values for the parameter. Defaults to None.

  • default – The default value for the parameter. Defaults to None.

  • description – A description of the parameter. Defaults to “”.

  • number_range – A NumberRange to use to limit the parameter. Defaults to None.

as_dict() dict[source]

Return the NumberMappingParameter as a dictionary.

classmethod from_dict(d) NumberMappingParameter[source]

Initiate a NumberMappingParameter from a dictionary.

validate(val: Any) bool[source]

Validate a value.

class autojob.calculation.parameters.NumberParameter(*, name: str = '', allow_floats: bool = False, special_values: Iterable[type] | None = None, default: Any = None, description: str = '', number_range: NumberRange = None)[source]

Bases: CalculatorParameter

A parameter that can be a number.

Initialize a NumberParameter.

Parameters:
  • name – The name of the NumberParameter. Defaults to “”.

  • allow_floats – Whether to allow floats. Defaults to False.

  • special_values – An iterable of the special values for the parameter. Defaults to None.

  • default – The default value for the parameter. Defaults to None.

  • description – A description of the parameter. Defaults to “”.

  • number_range – A NumberRange to use to limit the parameter. Defaults to None.

as_dict() dict[source]

Return the NumberParameter as a dictionary.

classmethod from_dict(d) NumberParameter[source]

Initiate a NumberParameter from a dictionary.

property number_range: NumberRange

The number range of the parameter.

validate(val: Any) bool[source]

Validate a value.

class autojob.calculation.parameters.NumberRange(*, lower_bound: int | float = -inf, lower_bound_exclusive: bool = True, upper_bound: int | float = inf, upper_bound_exclusive: bool = True)[source]

Bases: MSONable

A range of numbers.

Initialize a NumberRange.

Parameters:
  • lower_bound – The lower bound for the range.

  • lower_bound_exclusive – Whether the lower bound is excluded from the range.

  • upper_bound – The upper bound for the range.

  • upper_bound_exclusive – Whether the upper bound is excluded from the range.

validate_number(number: int | float) bool[source]

Returns True if a number is within the range. False, otherwise.

Parameters:

number – A number to check.

class autojob.calculation.parameters.NumberSequenceParameter(*, name: str = '', allow_floats: bool = False, special_values: Iterable | None = None, default: Any = None, description: str = '', number_range: NumberRange = None)[source]

Bases: SequenceParameter

A parameter that can be a sequence of numbers.

Initialize a NumberSequenceParameter.

Parameters:
  • name – The name of the NumberSequenceParameter. Defaults to “”.

  • allow_floats – Whether to allow floats. Defaults to False.

  • special_values – An iterable of the special values for the parameter. Defaults to None.

  • default – The default value for the parameter. Defaults to None.

  • description – A description of the parameter. Defaults to “”.

  • number_range – A NumberRange to use to limit the parameter. Defaults to None.

as_dict() dict[source]

Return the NumberSequenceParameter as a dictionary.

classmethod from_dict(d) NumberSequenceParameter[source]

Initiate a SequenceParameter from a dictionary.

validate(val: Any) bool[source]

Validate a value.

class autojob.calculation.parameters.SequenceParameter(member_types: Iterable[type], name: str = '', special_values: Iterable | None = None, default: Any = None, description: str = '')[source]

Bases: CalculatorParameter

A parameter that can be a sequence.

Initialize a SequenceParameter.

Parameters:
  • name – The name of the SequenceParameter. Defaults to “”.

  • member_types – The allowed types of the items in the sequence.

  • special_values – An iterable of the special values for the parameter. Defaults to None.

  • default – The default value for the parameter. Defaults to None.

  • description – A description of the parameter. Defaults to “”.

as_dict() dict[source]

Return the SequenceParameter as a dictionary.

classmethod from_dict(d) SequenceParameter[source]

Initiate a SequenceParameter from a dictionary.

property member_types: Iterable

The allowed member types of the parameter.

validate(val: Any) bool[source]

Validate a value.

autojob.calculation.vibration module

Retrieve the results of a vibrational calculation.

This module provides utilities from retrieving the inputs and outputs of a vibrational (frequency) calculation from a directory.

Example

from pathlib import Path

from autojob.calculation.vibration import Vibration

task = Vibration.from_directory(Path.cwd())

class autojob.calculation.vibration.Vibration(*, task_metadata: TaskMetadata, task_inputs: TaskInputs, task_outputs: TaskOutputs | None = None, calculation_inputs: CalculationInputs, calculation_outputs: CalculationOutputs | None = None, scheduler_inputs: SchedulerInputs, scheduler_outputs: SchedulerOutputs | None = None, vibration_inputs: VibrationInputs, vibration_outputs: VibrationOutputs | None = None, **extra_data: Any)[source]

Bases: Calculation

A vibrational calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

static create_shell(context: dict[str, Any] | None = None) Vibration[source]

Create a minimal Vibration shell.

Parameters:

context – A dictionary mapping attribute paths to their values. For example, the "vibration_outputs" key will be used to set the vibration_outputs attribute in the returned object.

Returns:

An Infrared object initialized with the values in context.

freeze_catalyst_atoms(tags_to_unfreeze: list[int] | None = None) None[source]

Freeze the catalyst atoms of an input structure.

Parameters:

tags_to_unfreeze – A list of tags indicating which atoms to unfreeze. Defaults to [-99].

Raises:

RuntimeError – No input atoms to freeze in task.

Warns:

UserWarning – Every atom in the Atoms object will be frozen.

classmethod from_directory(dir_name: str | Path, *, strict_mode: bool = True, magic_mode: bool = False, calculator_type: CalculatorType | None = None, task: Task | None = None) Self[source]

Generate a Vibration document from a calculation directory.

Parameters:
  • dir_name – The directory of a vibrational calculation.

  • strict_mode – Whether to raise an error if no output atoms found. Defaults to SETTINGS.STRICT_MODE.

  • magic_mode – Whether to defer the final object creation. If True, the final object will be an instance of the class specified by the _build_class attribute of the TaskMetadata object created. Otherwise, a Vibration object will be returned. Defaults to False.

  • calculator_type – The type of calculation run. Must correspond to an ASE calculator.

  • task – A Task from which to build the Vibration.

    Deprecated since version 0.12.0: This parameter is ignored since task metadata, inputs, and outputs are now always loaded using super().from_directory().

Returns:

A Vibration object.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'extra': 'allow'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'calculation_inputs': FieldInfo(annotation=CalculationInputs, required=True), 'calculation_outputs': FieldInfo(annotation=Union[CalculationOutputs, NoneType], required=False, default=None), 'scheduler_inputs': FieldInfo(annotation=SchedulerInputs, required=True), 'scheduler_outputs': FieldInfo(annotation=Union[SchedulerOutputs, NoneType], required=False, default=None), 'task_inputs': FieldInfo(annotation=TaskInputs, required=True, description='Task inputs'), 'task_metadata': FieldInfo(annotation=TaskMetadata, required=True), 'task_outputs': FieldInfo(annotation=Union[TaskOutputs, NoneType], required=False, default=None, description='Task outputs'), 'vibration_inputs': FieldInfo(annotation=VibrationInputs, required=True), 'vibration_outputs': FieldInfo(annotation=Union[VibrationOutputs, NoneType], required=False, default=None)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

prepare_input_atoms() None[source]

Prepare the input atoms for the calculation.

vibration_inputs: VibrationInputs
vibration_outputs: VibrationOutputs | None
write_python_script(dst: Path, *, template: str = 'vibration.py.j2', structure_name: str | None = 'in.traj') Path[source]

Write the Python script for the vibrational calculation.

Parameters:
  • dst – The directory in which to write the Python script.

  • template – The name of the template to use to write the Python script.

  • structure_name – The filename of the input structure to be read to load the Atoms object for the calculation. Defaults to the value of the "filename" key in the input Atoms object, if present. Defaults to the value of SETTINGS.INPUT_ATOMS otherwise. Take care to ensure that this matches the name of the file to which the structure is written.

Returns:

A Path object representing the filename of the written Python script.

class autojob.calculation.vibration.VibrationInputs[source]

Bases: BaseModel

The inputs of a vibrational calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

class autojob.calculation.vibration.VibrationOutputs(*, entropic_correction: float | None = None, Frequencies: list[float] | None = None, zero_point_energy: float | None = None)[source]

Bases: BaseModel

The outputs of a vibrational calculation.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

entropic_correction: float | None
classmethod from_directory(dir_name: str | Path, *, strict_mode: bool = True) VibrationOutputs[source]

Extract thermo data from the input structure of the directory.

Parameters:
  • dir_name – The directory of the completed calculation.

  • strict_mode – Whether or not to require all outputs. If True, errors will be thrown on missing outputs.

Returns:

The thermodynamic data as VibrationOutputs. If no data is found, and strict_mode = False every value will be None.

model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {'populate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[Dict[str, FieldInfo]] = {'entropic_correction': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, alias='TS Correction', alias_priority=2), 'vibrational_frequencies': FieldInfo(annotation=Union[list[float], NoneType], required=False, default=None, alias='Frequencies', alias_priority=2), 'zero_point_energy': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, alias='Zero-Point Energy', alias_priority=2)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

This replaces Model.__fields__ from Pydantic V1.

vibrational_frequencies: list[float] | None
zero_point_energy: float | None