janus_core package

Module contents

Tools for machine learnt interatomic potentials.

Submodules

janus_core.calculations.base module

Prepare structures for MLIP calculations.

class janus_core.calculations.base.BaseCalculation(*, calc_name='base', struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, sequence_allowed=True, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, file_prefix=None, additional_prefix=None, param_prefix=None)[source]

Bases: FileNameMixin

Prepare structures for MLIP calculations.

Parameters:
  • calc_name (str) – Name of calculation being run, used for name of logger. Default is “base”.

  • struct (Atoms | Sequence[Atoms] | None) – ASE Atoms structure(s) to simulate. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to simulate. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. Default is {}.

  • sequence_allowed (bool) – Whether a sequence of Atoms objects is allowed. Default is True.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is None.

  • additional_prefix (str | None) – Component to add to default file_prefix (joined by hyphens). Default is None.

  • param_prefix (str | None) – Additional parameters to add to default file_prefix. Default is None.

logger

Logger if log file has been specified.

Type:

logging.Logger | None

tracker

Tracker if logging is enabled.

Type:

OfflineEmissionsTracker | None

__abstractmethods__ = frozenset({})
__init__(*, calc_name='base', struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, sequence_allowed=True, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, file_prefix=None, additional_prefix=None, param_prefix=None)[source]

Read the structure being simulated and attach an MLIP calculator.

Parameters:
  • calc_name (str) – Name of calculation being run, used for name of logger. Default is “base”.

  • struct (Atoms | Sequence[Atoms] | None) – ASE Atoms structure(s) to simulate. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to simulate. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. Default is {}.

  • sequence_allowed (bool) – Whether a sequence of Atoms objects is allowed. Default is True.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is None.

  • additional_prefix (str | None) – Component to add to default file_prefix (joined by hyphens). Default is None.

  • param_prefix (str | None) – Additional parameters to add to default file_prefix. Default is None.

__module__ = 'janus_core.calculations.base'
_abc_impl = <_abc._abc_data object>
_set_info_units(keys=('energy', 'forces', 'stress'))[source]

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

janus_core.calculations.descriptors module

Calculate MLIP descriptors for structures.

class janus_core.calculations.descriptors.Descriptors(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, invariants_only=True, calc_per_element=False, calc_per_atom=False, write_results=False, write_kwargs=None)[source]

Bases: BaseCalculation

Prepare and calculate MLIP descriptors for structures.

Parameters:
  • struct (Atoms | Sequence[Atoms] | None) – ASE Atoms structure(s) to calculate descriptors for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to calculate descriptors for. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • invariants_only (bool) – Whether only the invariant descriptors should be returned. Default is True.

  • calc_per_element (bool) – Whether to calculate mean descriptors for each element. Default is False.

  • calc_per_atom (bool) – Whether to calculate descriptors for each atom. Default is False.

  • write_results (bool) – True to write out structure with results of calculations. Default is False.

  • write_kwargs (ASEWriteArgs | None) – Keyword arguments to pass to ase.io.write if saving structure with results of calculations. Default is {}.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__init__(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, invariants_only=True, calc_per_element=False, calc_per_atom=False, write_results=False, write_kwargs=None)[source]

Initialise class.

Parameters:
  • struct (Atoms | Sequence[Atoms] | None) – ASE Atoms structure(s) to calculate descriptors for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to calculate descriptors for. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • invariants_only (bool) – Whether only the invariant descriptors should be returned. Default is True.

  • calc_per_element (bool) – Whether to calculate mean descriptors for each element. Default is False.

  • calc_per_atom (bool) – Whether to calculate descriptors for each atom. Default is False.

  • write_results (bool) – True to write out structure with results of calculations. Default is False.

  • write_kwargs (ASEWriteArgs | None) – Keyword arguments to pass to ase.io.write if saving structure with results of calculations. Default is {}.

__module__ = 'janus_core.calculations.descriptors'
_abc_impl = <_abc._abc_data object>
_calc_descriptors(struct)[source]

Calculate MLIP descriptors a given structure.

Parameters:

struct (Atoms) – Structure to calculate descriptors for.

Return type:

None

run()[source]

Calculate descriptors for structure(s).

Return type:

None

janus_core.calculations.eos module

Equation of State.

class janus_core.calculations.eos.EoS(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, min_volume=0.95, max_volume=1.05, n_volumes=7, eos_type='birchmurnaghan', minimize=True, minimize_all=False, minimize_kwargs=None, write_results=True, write_structures=False, write_kwargs=None, plot_to_file=False, plot_kwargs=None, file_prefix=None)[source]

Bases: BaseCalculation

Prepare and calculate equation of state of a structure.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to calculate equation of state for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to calculate equation of state for. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • min_volume (float) – Minimum volume scale factor. Default is 0.95.

  • max_volume (float) – Maximum volume scale factor. Default is 1.05.

  • n_volumes (int) – Number of volumes to use. Default is 7.

  • eos_type (Literal['sj', 'taylor', 'murnaghan', 'birch', 'birchmurnaghan', 'pouriertarantola', 'vinet', 'antonschmidt', 'p3']) – Type of fit for equation of state. Default is “birchmurnaghan”.

  • minimize (bool) – Whether to minimize initial structure before calculations. Default is True.

  • minimize_all (bool) – Whether to optimize geometry for all generated structures. Default is False.

  • minimize_kwargs (dict[str, Any] | None) – Keyword arguments to pass to optimize. Default is None.

  • write_results (bool) – True to write out results of equation of state calculations. Default is True.

  • write_structures (bool) – True to write out all genereated structures. Default is False.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write to save generated structures. Default is {}.

  • plot_to_file (bool) – Whether to save plot equation of state to svg. Default is False.

  • plot_kwargs (dict[str, Any] | None) – Keyword arguments to pass to EquationOfState.plot. Default is {}.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure name, or chemical formula of the structure.

results

Dictionary containing equation of state ASE object, and the fitted minimum bulk modulus, volume, and energy.

Type:

EoSResults

volumes

List of volumes of generated structures.

Type:

list[float]

energies

List of energies of generated structures.

Type:

list[float]

lattice_scalars

Lattice scalars of generated structures.

Type:

NDArray[float64]

__abstractmethods__ = frozenset({})
__annotations__ = {}
__init__(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, min_volume=0.95, max_volume=1.05, n_volumes=7, eos_type='birchmurnaghan', minimize=True, minimize_all=False, minimize_kwargs=None, write_results=True, write_structures=False, write_kwargs=None, plot_to_file=False, plot_kwargs=None, file_prefix=None)[source]

Initialise class.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to optimize geometry for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to optimize. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for optimization. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • min_volume (float) – Minimum volume scale factor. Default is 0.95.

  • max_volume (float) – Maximum volume scale factor. Default is 1.05.

  • n_volumes (int) – Number of volumes to use. Default is 7.

  • eos_type (Literal['sj', 'taylor', 'murnaghan', 'birch', 'birchmurnaghan', 'pouriertarantola', 'vinet', 'antonschmidt', 'p3']) – Type of fit for equation of state. Default is “birchmurnaghan”.

  • minimize (bool) – Whether to minimize initial structure before calculations. Default is True.

  • minimize_all (bool) – Whether to optimize geometry for all generated structures. Default is False.

  • minimize_kwargs (dict[str, Any] | None) – Keyword arguments to pass to optimize. Default is None.

  • write_results (bool) – True to write out results of equation of state calculations. Default is True.

  • write_structures (bool) – True to write out all genereated structures. Default is False.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write to save generated structures. Default is {}.

  • plot_to_file (bool) – Whether to save plot equation of state to svg. Default is False.

  • plot_kwargs (dict[str, Any] | None) – Keyword arguments to pass to EquationOfState.plot. Default is {}.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure name, or chemical formula of the structure.

__module__ = 'janus_core.calculations.eos'
_abc_impl = <_abc._abc_data object>
_calc_volumes_energies()[source]

Calculate volumes and energies for all lattice constants.

Return type:

None

run()[source]

Calculate equation of state.

Returns:

Dictionary containing equation of state ASE object, and the fitted minimum bulk modulus, volume, and energy.

Return type:

EoSResults

janus_core.calculations.geom_opt module

Prepare and run geometry optimization.

class janus_core.calculations.geom_opt.GeomOpt(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, fmax=0.1, steps=1000, symmetrize=False, symmetry_tolerance=0.001, angle_tolerance=-1.0, filter_func=<class 'ase.filters.FrechetCellFilter'>, filter_kwargs=None, optimizer=<class 'ase.optimize.lbfgs.LBFGS'>, opt_kwargs=None, write_results=False, write_kwargs=None, traj_kwargs=None)[source]

Bases: BaseCalculation

Prepare and run geometry optimization.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to optimize geometry for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to optimize. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for optimization. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • fmax (float) – Set force convergence criteria for optimizer in units eV/Å. Default is 0.1.

  • steps (int) – Set maximum number of optimization steps to run. Default is 1000.

  • symmetrize (bool) – Whether to refine symmetry after geometry optimization. Default is False.

  • symmetry_tolerance (float) – Atom displacement tolerance for spglib symmetry determination, in Å. Default is 0.001.

  • angle_tolerance (float) – Angle precision for spglib symmetry determination, in degrees. Default is -1.0, which means an internally optimized routine is used to judge symmetry.

  • filter_func (Callable | str | None) – Filter function, or name of function from ase.filters to apply constraints to atoms. Default is FrechetCellFilter.

  • filter_kwargs (dict[str, Any] | None) – Keyword arguments to pass to filter_func. Default is {}.

  • optimizer (Callable | str) – Optimization function, or name of function from ase.optimize. Default is LBFGS.

  • opt_kwargs (ASEOptArgs | None) – Keyword arguments to pass to optimizer. Default is {}.

  • write_results (bool) – True to write out optimized structure. Default is False.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write to save optimized structure. Default is {}.

  • traj_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write to save optimization trajectory. Must include “filename” keyword. Default is {}.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__init__(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, fmax=0.1, steps=1000, symmetrize=False, symmetry_tolerance=0.001, angle_tolerance=-1.0, filter_func=<class 'ase.filters.FrechetCellFilter'>, filter_kwargs=None, optimizer=<class 'ase.optimize.lbfgs.LBFGS'>, opt_kwargs=None, write_results=False, write_kwargs=None, traj_kwargs=None)[source]

Initialise GeomOpt class.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to optimize geometry for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to optimize. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for optimization. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • fmax (float) – Set force convergence criteria for optimizer in units eV/Å. Default is 0.1.

  • steps (int) – Set maximum number of optimization steps to run. Default is 1000.

  • symmetrize (bool) – Whether to refine symmetry after geometry optimization. Default is False.

  • symmetry_tolerance (float) – Atom displacement tolerance for spglib symmetry determination, in Å. Default is 0.001.

  • angle_tolerance (float) – Angle precision for spglib symmetry determination, in degrees. Default is -1.0, which means an internally optimized routine is used to judge symmetry.

  • filter_func (Callable | str | None) – Filter function, or name of function from ase.filters to apply constraints to atoms. Default is FrechetCellFilter.

  • filter_kwargs (dict[str, Any] | None) – Keyword arguments to pass to filter_func. Default is {}.

  • optimizer (Callable | str) – Optimization function, or name of function from ase.optimize. Default is LBFGS.

  • opt_kwargs (ASEOptArgs | None) – Keyword arguments to pass to optimizer. Default is {}.

  • write_results (bool) – True to write out optimized structure. Default is False.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write to save optimized structure. Default is {}.

  • traj_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write to save optimization trajectory. Must include “filename” keyword. Default is {}.

__module__ = 'janus_core.calculations.geom_opt'
_abc_impl = <_abc._abc_data object>
_set_functions()[source]

Set optimizer and filter functions.

Return type:

None

run()[source]

Run geometry optimization.

Return type:

None

set_optimizer()[source]

Set optimizer for geometry optimization.

Return type:

None

janus_core.calculations.md module

Run molecular dynamics simulations.

class janus_core.calculations.md.MolecularDynamics(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, ensemble=None, steps=0, timestep=1.0, temp=300, equil_steps=0, minimize=False, minimize_every=-1, minimize_kwargs=None, rescale_velocities=False, remove_rot=False, rescale_every=10, file_prefix=None, restart=False, restart_auto=True, restart_stem=None, restart_every=1000, rotate_restart=False, restarts_to_keep=4, final_file=None, stats_file=None, stats_every=100, traj_file=None, traj_append=False, traj_start=0, traj_every=100, temp_start=None, temp_end=None, temp_step=None, temp_time=None, write_kwargs=None, post_process_kwargs=None, correlation_kwargs=None, seed=None)[source]

Bases: BaseCalculation

Configure shared molecular dynamics simulation options.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to simulate. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to simulate. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for simulation. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • struct – Structure to simulate.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr'] | None) – Name for thermodynamic ensemble. Default is None.

  • steps (int) – Number of steps in simulation. Default is 0.

  • timestep (float) – Timestep for integrator, in fs. Default is 1.0.

  • temp (float) – Temperature, in K. Default is 300.

  • equil_steps (int) – Maximum number of steps at which to perform optimization and reset velocities. Default is 0.

  • minimize (bool) – Whether to minimize structure during equilibration. Default is False.

  • minimize_every (int) – Frequency of minimizations. Default is -1, which disables minimization after beginning dynamics.

  • minimize_kwargs (dict[str, Any] | None) – Keyword arguments to pass to geometry optimizer. Default is {}.

  • rescale_velocities (bool) – Whether to rescale velocities. Default is False.

  • remove_rot (bool) – Whether to remove rotation. Default is False.

  • rescale_every (int) – Frequency to rescale velocities. Default is 10.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure, ensemble, and temperature.

  • restart (bool) – Whether restarting dynamics. Default is False.

  • restart_auto (bool) – Whether to infer restart file name if restarting dynamics. Default is True.

  • restart_stem (str | Path | None) – Stem for restart file name. Default inferred from file_prefix.

  • restart_every (int) – Frequency of steps to save restart info. Default is 1000.

  • rotate_restart (bool) – Whether to rotate restart files. Default is False.

  • restarts_to_keep (int) – Restart files to keep if rotating. Default is 4.

  • final_file (str | Path | None) – File to save final configuration at each temperature of similation. Default inferred from file_prefix.

  • stats_file (str | Path | None) – File to save thermodynamical statistics. Default inferred from file_prefix.

  • stats_every (int) – Frequency to output statistics. Default is 100.

  • traj_file (str | Path | None) – Trajectory file to save. Default inferred from file_prefix.

  • traj_append (bool) – Whether to append trajectory. Default is False.

  • traj_start (int) – Step to start saving trajectory. Default is 0.

  • traj_every (int) – Frequency of steps to save trajectory. Default is 100.

  • temp_start (float | None) – Temperature to start heating, in K. Default is None, which disables heating.

  • temp_end (float | None) – Maximum temperature for heating, in K. Default is None, which disables heating.

  • temp_step (float | None) – Size of temperature steps when heating, in K. Default is None, which disables heating.

  • temp_time (float | None) – Time between heating steps, in fs. Default is None, which disables heating.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to output_structs when saving trajectory and final files. Default is {}.

  • post_process_kwargs (PostProcessKwargs | None) – Keyword arguments to control post-processing operations.

  • correlation_kwargs (list[CorrelationKwargs] | None) – Keyword arguments to control on-the-fly correlations.

  • seed (int | None) – Random seed used by numpy.random and random functions, such as in Langevin. Default is None.

dyn

Dynamics object to run simulation.

Type:

Dynamics

n_atoms

Number of atoms in structure being simulated.

Type:

int

restart_files

List of files saved to restart dynamics.

Type:

list[PathLike]

offset

Number of previous steps if restarting simulation.

Type:

int

created_final

Whether the final structure file has been created.

Type:

bool

__abstractmethods__ = frozenset({})
__annotations__ = {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.md', '__doc__': '\n    Configure shared molecular dynamics simulation options.\n\n    Parameters\n    ----------\n    struct\n        ASE Atoms structure to simulate. Required if `struct_path` is None. Default is\n        None.\n    struct_path\n        Path of structure to simulate. Required if `struct` is None. Default is None.\n    arch\n        MLIP architecture to use for simulation. Default is "mace_mp".\n    device\n        Device to run MLIP model on. Default is "cpu".\n    model_path\n        Path to MLIP model. Default is `None`.\n    read_kwargs\n        Keyword arguments to pass to ase.io.read. By default,\n        read_kwargs["index"] is -1.\n    calc_kwargs\n        Keyword arguments to pass to the selected calculator. Default is {}.\n    set_calc\n        Whether to set (new) calculators for structures. Default is None.\n    attach_logger\n        Whether to attach a logger. Default is True if "filename" is passed in\n        log_kwargs, else False.\n    log_kwargs\n        Keyword arguments to pass to `config_logger`. Default is {}.\n    track_carbon\n        Whether to track carbon emissions of calculation. Requires attach_logger.\n        Default is True if attach_logger is True, else False.\n    tracker_kwargs\n        Keyword arguments to pass to `config_tracker`. Default is {}.\n    struct\n        Structure to simulate.\n    ensemble\n        Name for thermodynamic ensemble. Default is None.\n    steps\n        Number of steps in simulation. Default is 0.\n    timestep\n        Timestep for integrator, in fs. Default is 1.0.\n    temp\n        Temperature, in K. Default is 300.\n    equil_steps\n        Maximum number of steps at which to perform optimization and reset velocities.\n        Default is 0.\n    minimize\n        Whether to minimize structure during equilibration. Default is False.\n    minimize_every\n        Frequency of minimizations. Default is -1, which disables minimization after\n        beginning dynamics.\n    minimize_kwargs\n        Keyword arguments to pass to geometry optimizer. Default is {}.\n    rescale_velocities\n        Whether to rescale velocities. Default is False.\n    remove_rot\n        Whether to remove rotation. Default is False.\n    rescale_every\n        Frequency to rescale velocities. Default is 10.\n    file_prefix\n        Prefix for output filenames. Default is inferred from structure, ensemble,\n        and temperature.\n    restart\n        Whether restarting dynamics. Default is False.\n    restart_auto\n        Whether to infer restart file name if restarting dynamics. Default is True.\n    restart_stem\n        Stem for restart file name. Default inferred from `file_prefix`.\n    restart_every\n        Frequency of steps to save restart info. Default is 1000.\n    rotate_restart\n        Whether to rotate restart files. Default is False.\n    restarts_to_keep\n        Restart files to keep if rotating. Default is 4.\n    final_file\n        File to save final configuration at each temperature of similation. Default\n        inferred from `file_prefix`.\n    stats_file\n        File to save thermodynamical statistics. Default inferred from `file_prefix`.\n    stats_every\n        Frequency to output statistics. Default is 100.\n    traj_file\n        Trajectory file to save. Default inferred from `file_prefix`.\n    traj_append\n        Whether to append trajectory. Default is False.\n    traj_start\n        Step to start saving trajectory. Default is 0.\n    traj_every\n        Frequency of steps to save trajectory. Default is 100.\n    temp_start\n        Temperature to start heating, in K. Default is None, which disables heating.\n    temp_end\n        Maximum temperature for heating, in K. Default is None, which disables heating.\n    temp_step\n        Size of temperature steps when heating, in K. Default is None, which disables\n        heating.\n    temp_time\n        Time between heating steps, in fs. Default is None, which disables heating.\n    write_kwargs\n        Keyword arguments to pass to `output_structs` when saving trajectory and final\n        files. Default is {}.\n    post_process_kwargs\n        Keyword arguments to control post-processing operations.\n    correlation_kwargs\n        Keyword arguments to control on-the-fly correlations.\n    seed\n        Random seed used by numpy.random and random functions, such as in Langevin.\n        Default is None.\n\n    Attributes\n    ----------\n    dyn : Dynamics\n        Dynamics object to run simulation.\n    n_atoms : int\n        Number of atoms in structure being simulated.\n    restart_files : list[PathLike]\n        List of files saved to restart dynamics.\n    offset : int\n        Number of previous steps if restarting simulation.\n    created_final : bool\n        Whether the final structure file has been created.\n    ', '__init__': <function MolecularDynamics.__init__>, '_set_info': <function MolecularDynamics._set_info>, '_prepare_restart': <function MolecularDynamics._prepare_restart>, '_rotate_restart_files': <function MolecularDynamics._rotate_restart_files>, '_set_velocity_distribution': <function MolecularDynamics._set_velocity_distribution>, '_reset_velocities': <function MolecularDynamics._reset_velocities>, '_optimize_structure': <function MolecularDynamics._optimize_structure>, '_set_param_prefix': <function MolecularDynamics._set_param_prefix>, '_restart_stem': <property object>, '_restart_file': <property object>, '_parse_correlations': <function MolecularDynamics._parse_correlations>, '_attach_correlations': <function MolecularDynamics._attach_correlations>, '_write_correlations': <function MolecularDynamics._write_correlations>, 'get_stats': <function MolecularDynamics.get_stats>, 'unit_info': <property object>, 'default_formats': <property object>, '_write_header': <function MolecularDynamics._write_header>, '_write_stats_file': <function MolecularDynamics._write_stats_file>, '_write_traj': <function MolecularDynamics._write_traj>, '_write_final_state': <function MolecularDynamics._write_final_state>, '_post_process': <function MolecularDynamics._post_process>, '_write_restart': <function MolecularDynamics._write_restart>, 'run': <function MolecularDynamics.run>, '_run_dynamics': <function MolecularDynamics._run_dynamics>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}})
__init__(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, ensemble=None, steps=0, timestep=1.0, temp=300, equil_steps=0, minimize=False, minimize_every=-1, minimize_kwargs=None, rescale_velocities=False, remove_rot=False, rescale_every=10, file_prefix=None, restart=False, restart_auto=True, restart_stem=None, restart_every=1000, rotate_restart=False, restarts_to_keep=4, final_file=None, stats_file=None, stats_every=100, traj_file=None, traj_append=False, traj_start=0, traj_every=100, temp_start=None, temp_end=None, temp_step=None, temp_time=None, write_kwargs=None, post_process_kwargs=None, correlation_kwargs=None, seed=None)[source]

Initialise molecular dynamics simulation configuration.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to simulate. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to simulate. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for simulation. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr'] | None) – Name for thermodynamic ensemble. Default is None.

  • steps (int) – Number of steps in simulation. Default is 0.

  • timestep (float) – Timestep for integrator, in fs. Default is 1.0.

  • temp (float) – Temperature, in K. Default is 300.

  • equil_steps (int) – Maximum number of steps at which to perform optimization and reset velocities. Default is 0.

  • minimize (bool) – Whether to minimize structure during equilibration. Default is False.

  • minimize_every (int) – Frequency of minimizations. Default is -1, which disables minimization after beginning dynamics.

  • minimize_kwargs (dict[str, Any] | None) – Keyword arguments to pass to geometry optimizer. Default is {}.

  • rescale_velocities (bool) – Whether to rescale velocities. Default is False.

  • remove_rot (bool) – Whether to remove rotation. Default is False.

  • rescale_every (int) – Frequency to rescale velocities. Default is 10.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure, ensemble, and temperature.

  • restart (bool) – Whether restarting dynamics. Default is False.

  • restart_auto (bool) – Whether to infer restart file name if restarting dynamics. Default is True.

  • restart_stem (str | Path | None) – Stem for restart file name. Default inferred from file_prefix.

  • restart_every (int) – Frequency of steps to save restart info. Default is 1000.

  • rotate_restart (bool) – Whether to rotate restart files. Default is False.

  • restarts_to_keep (int) – Restart files to keep if rotating. Default is 4.

  • final_file (str | Path | None) – File to save final configuration at each temperature of similation. Default inferred from file_prefix.

  • stats_file (str | Path | None) – File to save thermodynamical statistics. Default inferred from file_prefix.

  • stats_every (int) – Frequency to output statistics. Default is 100.

  • traj_file (str | Path | None) – Trajectory file to save. Default inferred from file_prefix.

  • traj_append (bool) – Whether to append trajectory. Default is False.

  • traj_start (int) – Step to start saving trajectory. Default is 0.

  • traj_every (int) – Frequency of steps to save trajectory. Default is 100.

  • temp_start (float | None) – Temperature to start heating, in K. Default is None, which disables heating.

  • temp_end (float | None) – Maximum temperature for heating, in K. Default is None, which disables heating.

  • temp_step (float | None) – Size of temperature steps when heating, in K. Default is None, which disables heating.

  • temp_time (float | None) – Time between heating steps, in fs. Default is None, which disables heating.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to output_structs when saving trajectory and final files. Default is {}.

  • post_process_kwargs (PostProcessKwargs | None) – Keyword arguments to control post-processing operations.

  • correlation_kwargs (list[CorrelationKwargs] | None) – Keyword arguments to control on-the-fly correlations.

  • seed (int | None) – Random seed used by numpy.random and random functions, such as in Langevin. Default is None.

__module__ = 'janus_core.calculations.md'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_attach_correlations()[source]

Attach all correlations to self.dyn.

Return type:

None

_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_optimize_structure()[source]

Perform geometry optimization.

Return type:

None

_parse_correlations()[source]

Parse correlation kwargs into Correlations.

Return type:

None

_post_process()[source]

Compute properties after MD run.

Return type:

None

_prepare_restart()[source]

Prepare restart files, structure and offset.

Return type:

None

_reset_velocities()[source]

Reset velocities and (optionally) rotation of system while equilibrating.

Return type:

None

property _restart_file: str

Restart file name.

Returns:

File name for restart files.

Return type:

str

property _restart_stem: str

Stem for restart files.

Restart files will be named {restart_stem}-{step}.extxyz. If file_prefix is specified, restart_stem will be of the form {file_prefix}-{param_prefix}-res.

Returns:

Stem for restart files.

Return type:

str

_rotate_restart_files()[source]

Rotate restart files.

Return type:

None

_run_dynamics()[source]

Run dynamics and/or temperature ramp.

Return type:

None

_set_info()[source]

Set time in fs, current dynamics step, and density to info.

Return type:

None

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

_set_param_prefix(file_prefix=None)[source]

Set ensemble parameters for output files.

Parameters:

file_prefix (str | Path | None) – Prefix for output filenames on class init. If not None, param_prefix = “”.

Returns:

Formatted ensemble parameters, including temp ramp range and/or and MD temp.

Return type:

str

_set_velocity_distribution()[source]

Set velocities to current target temperature.

Sets Maxwell-Boltzmann velocity distribution, as well as removing centre-of-mass momentum, and (optionally) total angular momentum.

Return type:

None

_write_correlations()[source]

Write out the correlations.

Return type:

None

_write_final_state()[source]

Write the final system state.

Return type:

None

_write_header()[source]

Write header for stats file.

Return type:

None

_write_restart()[source]

Write restart file and (optionally) rotate files saved.

Return type:

None

_write_stats_file()[source]

Write molecular dynamics statistics.

Return type:

None

_write_traj()[source]

Write current structure to trajectory file.

Return type:

None

property default_formats: dict[str, str]

Default format of returned statistics.

Returns:

Default formats attached to statistical properties.

Return type:

dict[str, str]

get_stats()[source]

Get thermodynamical statistics to be written to file.

Returns:

Thermodynamical statistics to be written out.

Return type:

dict[str, float]

run()[source]

Run molecular dynamics simulation and/or temperature ramp.

Return type:

None

property unit_info: dict[str, str]

Get units of returned statistics.

Returns:

Units attached to statistical properties.

Return type:

dict[str, str]

class janus_core.calculations.md.NPH(*args, thermostat_time=50.0, bulk_modulus=2.0, pressure=0.0, ensemble='nph', file_prefix=None, ensemble_kwargs=None, **kwargs)[source]

Bases: NPT

Configure NPH simulation.

Parameters:
  • *args – Additional arguments.

  • thermostat_time (float) – Thermostat time, in fs. Default is 50.0.

  • bulk_modulus (float) – Bulk modulus, in GPa. Default is 2.0.

  • pressure (float) – Pressure, in GPa. Default is 0.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nph”.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure, ensemble, temperature, and pressure.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__abstractmethods__ = frozenset({})
__annotations__ = {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.md', '__doc__': '\n    Configure NPH simulation.\n\n    Parameters\n    ----------\n    *args\n        Additional arguments.\n    thermostat_time\n        Thermostat time, in fs. Default is 50.0.\n    bulk_modulus\n        Bulk modulus, in GPa. Default is 2.0.\n    pressure\n        Pressure, in GPa. Default is 0.0.\n    ensemble\n        Name for thermodynamic ensemble. Default is "nph".\n    file_prefix\n        Prefix for output filenames. Default is inferred from structure, ensemble,\n        temperature, and pressure.\n    ensemble_kwargs\n        Keyword arguments to pass to ensemble initialization. Default is {}.\n    **kwargs\n        Additional keyword arguments.\n    ', '__init__': <function NPH.__init__>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}})
__init__(*args, thermostat_time=50.0, bulk_modulus=2.0, pressure=0.0, ensemble='nph', file_prefix=None, ensemble_kwargs=None, **kwargs)[source]

Initialise dynamics for NPH simulation.

Parameters:
  • *args – Additional arguments.

  • thermostat_time (float) – Thermostat time, in fs. Default is 50.0.

  • bulk_modulus (float) – Bulk modulus, in GPa. Default is 2.0.

  • pressure (float) – Pressure, in GPa. Default is 0.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nph”.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure, ensemble, temperature, and pressure.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__module__ = 'janus_core.calculations.md'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_attach_correlations()

Attach all correlations to self.dyn.

Return type:

None

_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_optimize_structure()

Perform geometry optimization.

Return type:

None

_parse_correlations()

Parse correlation kwargs into Correlations.

Return type:

None

_post_process()

Compute properties after MD run.

Return type:

None

_prepare_restart()

Prepare restart files, structure and offset.

Return type:

None

_reset_velocities()

Reset velocities and (optionally) rotation of system while equilibrating.

Return type:

None

property _restart_file: str

Restart file name.

Returns:

File name for restart files.

Return type:

str

property _restart_stem: str

Stem for restart files.

Restart files will be named {restart_stem}-{step}.extxyz. If file_prefix is specified, restart_stem will be of the form {file_prefix}-{param_prefix}-res.

Returns:

Stem for restart files.

Return type:

str

_rotate_restart_files()

Rotate restart files.

Return type:

None

_run_dynamics()

Run dynamics and/or temperature ramp.

Return type:

None

_set_info()

Set time in fs, current dynamics step, and density to info.

Return type:

None

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

_set_param_prefix(file_prefix=None)

Set ensemble parameters for output files.

Parameters:

file_prefix (str | Path | None) – Prefix for output filenames on class init. If not None, param_prefix = “”.

Returns:

Formatted ensemble parameters, including pressure and temperature(s).

Return type:

str

_set_velocity_distribution()

Set velocities to current target temperature.

Sets Maxwell-Boltzmann velocity distribution, as well as removing centre-of-mass momentum, and (optionally) total angular momentum.

Return type:

None

_write_correlations()

Write out the correlations.

Return type:

None

_write_final_state()

Write the final system state.

Return type:

None

_write_header()

Write header for stats file.

Return type:

None

_write_restart()

Write restart file and (optionally) rotate files saved.

Return type:

None

_write_stats_file()

Write molecular dynamics statistics.

Return type:

None

_write_traj()

Write current structure to trajectory file.

Return type:

None

property default_formats: dict[str, str]

Default format of returned statistics.

Returns:

Default formats attached to statistical properties.

Return type:

dict[str, str]

dyn: Langevin | VelocityVerlet | NPT
get_stats()

Get thermodynamical statistics to be written to file.

Returns:

Thermodynamical statistics to be written out.

Return type:

dict[str, float]

run()

Run molecular dynamics simulation and/or temperature ramp.

Return type:

None

property unit_info: dict[str, str]

Get units of returned statistics.

Returns:

Units attached to statistical properties.

Return type:

dict[str, str]

class janus_core.calculations.md.NPT(*args, thermostat_time=50.0, barostat_time=75.0, bulk_modulus=2.0, pressure=0.0, ensemble='npt', file_prefix=None, ensemble_kwargs=None, **kwargs)[source]

Bases: MolecularDynamics

Configure NPT dynamics.

Parameters:
  • *args – Additional arguments.

  • thermostat_time (float) – Thermostat time, in fs. Default is 50.0.

  • barostat_time (float) – Barostat time, in fs. Default is 75.0.

  • bulk_modulus (float) – Bulk modulus, in GPa. Default is 2.0.

  • pressure (float) – Pressure, in GPa. Default is 0.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “npt”.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure, ensemble, temperature, and pressure.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__abstractmethods__ = frozenset({})
__annotations__ = {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.md', '__doc__': '\n    Configure NPT dynamics.\n\n    Parameters\n    ----------\n    *args\n        Additional arguments.\n    thermostat_time\n        Thermostat time, in fs. Default is 50.0.\n    barostat_time\n        Barostat time, in fs. Default is 75.0.\n    bulk_modulus\n        Bulk modulus, in GPa. Default is 2.0.\n    pressure\n        Pressure, in GPa. Default is 0.0.\n    ensemble\n        Name for thermodynamic ensemble. Default is "npt".\n    file_prefix\n        Prefix for output filenames. Default is inferred from structure, ensemble,\n        temperature, and pressure.\n    ensemble_kwargs\n        Keyword arguments to pass to ensemble initialization. Default is {}.\n    **kwargs\n        Additional keyword arguments.\n    ', '__init__': <function NPT.__init__>, '_set_param_prefix': <function NPT._set_param_prefix>, 'get_stats': <function NPT.get_stats>, 'unit_info': <property object>, 'default_formats': <property object>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}})
__init__(*args, thermostat_time=50.0, barostat_time=75.0, bulk_modulus=2.0, pressure=0.0, ensemble='npt', file_prefix=None, ensemble_kwargs=None, **kwargs)[source]

Initialise dynamics for NPT simulation.

Parameters:
  • *args – Additional arguments.

  • thermostat_time (float) – Thermostat time, in fs. Default is 50.0.

  • barostat_time (float) – Barostat time, in fs. Default is 75.0.

  • bulk_modulus (float) – Bulk modulus, in GPa. Default is 2.0.

  • pressure (float) – Pressure, in GPa. Default is 0.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “npt”.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure, ensemble, temperature, and pressure.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__module__ = 'janus_core.calculations.md'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_attach_correlations()

Attach all correlations to self.dyn.

Return type:

None

_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_optimize_structure()

Perform geometry optimization.

Return type:

None

_parse_correlations()

Parse correlation kwargs into Correlations.

Return type:

None

_post_process()

Compute properties after MD run.

Return type:

None

_prepare_restart()

Prepare restart files, structure and offset.

Return type:

None

_reset_velocities()

Reset velocities and (optionally) rotation of system while equilibrating.

Return type:

None

property _restart_file: str

Restart file name.

Returns:

File name for restart files.

Return type:

str

property _restart_stem: str

Stem for restart files.

Restart files will be named {restart_stem}-{step}.extxyz. If file_prefix is specified, restart_stem will be of the form {file_prefix}-{param_prefix}-res.

Returns:

Stem for restart files.

Return type:

str

_rotate_restart_files()

Rotate restart files.

Return type:

None

_run_dynamics()

Run dynamics and/or temperature ramp.

Return type:

None

_set_info()

Set time in fs, current dynamics step, and density to info.

Return type:

None

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

_set_param_prefix(file_prefix=None)[source]

Set ensemble parameters for output files.

Parameters:

file_prefix (str | Path | None) – Prefix for output filenames on class init. If not None, param_prefix = “”.

Returns:

Formatted ensemble parameters, including pressure and temperature(s).

Return type:

str

_set_velocity_distribution()

Set velocities to current target temperature.

Sets Maxwell-Boltzmann velocity distribution, as well as removing centre-of-mass momentum, and (optionally) total angular momentum.

Return type:

None

_write_correlations()

Write out the correlations.

Return type:

None

_write_final_state()

Write the final system state.

Return type:

None

_write_header()

Write header for stats file.

Return type:

None

_write_restart()

Write restart file and (optionally) rotate files saved.

Return type:

None

_write_stats_file()

Write molecular dynamics statistics.

Return type:

None

_write_traj()

Write current structure to trajectory file.

Return type:

None

property default_formats: dict[str, str]

Default format of returned statistics.

Returns:

Default formats attached to statistical properties.

Return type:

dict[str, str]

dyn: Langevin | VelocityVerlet | NPT
get_stats()[source]

Get thermodynamical statistics to be written to file.

Returns:

Thermodynamical statistics to be written out.

Return type:

dict[str, float]

run()

Run molecular dynamics simulation and/or temperature ramp.

Return type:

None

property unit_info: dict[str, str]

Get units of returned statistics.

Returns:

Units attached to statistical properties.

Return type:

dict[str, str]

class janus_core.calculations.md.NVE(*args, ensemble='nve', ensemble_kwargs=None, **kwargs)[source]

Bases: MolecularDynamics

Configure NVE simulation.

Parameters:
  • *args – Additional arguments.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nve”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__abstractmethods__ = frozenset({})
__annotations__ = {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.md', '__doc__': '\n    Configure NVE simulation.\n\n    Parameters\n    ----------\n    *args\n        Additional arguments.\n    ensemble\n        Name for thermodynamic ensemble. Default is "nve".\n    ensemble_kwargs\n        Keyword arguments to pass to ensemble initialization. Default is {}.\n    **kwargs\n        Additional keyword arguments.\n    ', '__init__': <function NVE.__init__>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}})
__init__(*args, ensemble='nve', ensemble_kwargs=None, **kwargs)[source]

Initialise dynamics for NVE simulation.

Parameters:
  • *args – Additional arguments.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nve”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__module__ = 'janus_core.calculations.md'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_attach_correlations()

Attach all correlations to self.dyn.

Return type:

None

_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_optimize_structure()

Perform geometry optimization.

Return type:

None

_parse_correlations()

Parse correlation kwargs into Correlations.

Return type:

None

_post_process()

Compute properties after MD run.

Return type:

None

_prepare_restart()

Prepare restart files, structure and offset.

Return type:

None

_reset_velocities()

Reset velocities and (optionally) rotation of system while equilibrating.

Return type:

None

property _restart_file: str

Restart file name.

Returns:

File name for restart files.

Return type:

str

property _restart_stem: str

Stem for restart files.

Restart files will be named {restart_stem}-{step}.extxyz. If file_prefix is specified, restart_stem will be of the form {file_prefix}-{param_prefix}-res.

Returns:

Stem for restart files.

Return type:

str

_rotate_restart_files()

Rotate restart files.

Return type:

None

_run_dynamics()

Run dynamics and/or temperature ramp.

Return type:

None

_set_info()

Set time in fs, current dynamics step, and density to info.

Return type:

None

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

_set_param_prefix(file_prefix=None)

Set ensemble parameters for output files.

Parameters:

file_prefix (str | Path | None) – Prefix for output filenames on class init. If not None, param_prefix = “”.

Returns:

Formatted ensemble parameters, including temp ramp range and/or and MD temp.

Return type:

str

_set_velocity_distribution()

Set velocities to current target temperature.

Sets Maxwell-Boltzmann velocity distribution, as well as removing centre-of-mass momentum, and (optionally) total angular momentum.

Return type:

None

_write_correlations()

Write out the correlations.

Return type:

None

_write_final_state()

Write the final system state.

Return type:

None

_write_header()

Write header for stats file.

Return type:

None

_write_restart()

Write restart file and (optionally) rotate files saved.

Return type:

None

_write_stats_file()

Write molecular dynamics statistics.

Return type:

None

_write_traj()

Write current structure to trajectory file.

Return type:

None

property default_formats: dict[str, str]

Default format of returned statistics.

Returns:

Default formats attached to statistical properties.

Return type:

dict[str, str]

dyn: Langevin | VelocityVerlet | NPT
get_stats()

Get thermodynamical statistics to be written to file.

Returns:

Thermodynamical statistics to be written out.

Return type:

dict[str, float]

run()

Run molecular dynamics simulation and/or temperature ramp.

Return type:

None

property unit_info: dict[str, str]

Get units of returned statistics.

Returns:

Units attached to statistical properties.

Return type:

dict[str, str]

class janus_core.calculations.md.NVT(*args, friction=0.005, ensemble='nvt', ensemble_kwargs=None, **kwargs)[source]

Bases: MolecularDynamics

Configure NVT simulation.

Parameters:
  • *args – Additional arguments.

  • friction (float) – Friction coefficient in fs^-1. Default is 0.005.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nvt”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__abstractmethods__ = frozenset({})
__annotations__ = {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.md', '__doc__': '\n    Configure NVT simulation.\n\n    Parameters\n    ----------\n    *args\n        Additional arguments.\n    friction\n        Friction coefficient in fs^-1. Default is 0.005.\n    ensemble\n        Name for thermodynamic ensemble. Default is "nvt".\n    ensemble_kwargs\n        Keyword arguments to pass to ensemble initialization. Default is {}.\n    **kwargs\n        Additional keyword arguments.\n    ', '__init__': <function NVT.__init__>, 'get_stats': <function NVT.get_stats>, 'unit_info': <property object>, 'default_formats': <property object>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}})
__init__(*args, friction=0.005, ensemble='nvt', ensemble_kwargs=None, **kwargs)[source]

Initialise dynamics for NVT simulation.

Parameters:
  • *args – Additional arguments.

  • friction (float) – Friction coefficient in fs^-1. Default is 0.005.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nvt”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__module__ = 'janus_core.calculations.md'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_attach_correlations()

Attach all correlations to self.dyn.

Return type:

None

_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_optimize_structure()

Perform geometry optimization.

Return type:

None

_parse_correlations()

Parse correlation kwargs into Correlations.

Return type:

None

_post_process()

Compute properties after MD run.

Return type:

None

_prepare_restart()

Prepare restart files, structure and offset.

Return type:

None

_reset_velocities()

Reset velocities and (optionally) rotation of system while equilibrating.

Return type:

None

property _restart_file: str

Restart file name.

Returns:

File name for restart files.

Return type:

str

property _restart_stem: str

Stem for restart files.

Restart files will be named {restart_stem}-{step}.extxyz. If file_prefix is specified, restart_stem will be of the form {file_prefix}-{param_prefix}-res.

Returns:

Stem for restart files.

Return type:

str

_rotate_restart_files()

Rotate restart files.

Return type:

None

_run_dynamics()

Run dynamics and/or temperature ramp.

Return type:

None

_set_info()

Set time in fs, current dynamics step, and density to info.

Return type:

None

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

_set_param_prefix(file_prefix=None)

Set ensemble parameters for output files.

Parameters:

file_prefix (str | Path | None) – Prefix for output filenames on class init. If not None, param_prefix = “”.

Returns:

Formatted ensemble parameters, including temp ramp range and/or and MD temp.

Return type:

str

_set_velocity_distribution()

Set velocities to current target temperature.

Sets Maxwell-Boltzmann velocity distribution, as well as removing centre-of-mass momentum, and (optionally) total angular momentum.

Return type:

None

_write_correlations()

Write out the correlations.

Return type:

None

_write_final_state()

Write the final system state.

Return type:

None

_write_header()

Write header for stats file.

Return type:

None

_write_restart()

Write restart file and (optionally) rotate files saved.

Return type:

None

_write_stats_file()

Write molecular dynamics statistics.

Return type:

None

_write_traj()

Write current structure to trajectory file.

Return type:

None

property default_formats: dict[str, str]

Default format of returned statistics.

Returns:

Default formats attached to statistical properties.

Return type:

dict[str, str]

dyn: Langevin | VelocityVerlet | NPT
get_stats()[source]

Get thermodynamical statistics to be written to file.

Returns:

Thermodynamical statistics to be written out.

Return type:

dict[str, float]

run()

Run molecular dynamics simulation and/or temperature ramp.

Return type:

None

property unit_info: dict[str, str]

Get units of returned statistics.

Returns:

Units attached to statistical properties.

Return type:

dict[str, str]

class janus_core.calculations.md.NVT_CSVR(*args, taut=100.0, ensemble='nvt-csvr', ensemble_kwargs=None, **kwargs)[source]

Bases: NVT

Configure NVT simulation using CSVR thermostat proposed by Bussi et al.

Parameters:
  • *args – Additional arguments.

  • taut (float) – Time constant for CSVR thermostat coupling, in fs. Default is 100.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nvt-csvr”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__abstractmethods__ = frozenset({})
__annotations__ = {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.md', '__doc__': '\n    Configure NVT simulation using CSVR thermostat proposed by Bussi et al.\n\n    Parameters\n    ----------\n    *args\n        Additional arguments.\n    taut\n        Time constant for CSVR thermostat coupling, in fs. Default is 100.0.\n    ensemble\n        Name for thermodynamic ensemble. Default is "nvt-csvr".\n    ensemble_kwargs\n        Keyword arguments to pass to ensemble initialization. Default is {}.\n    **kwargs\n        Additional keyword arguments.\n    ', '__init__': <function NVT_CSVR.__init__>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}})
__init__(*args, taut=100.0, ensemble='nvt-csvr', ensemble_kwargs=None, **kwargs)[source]

Initialise dynamics for NVT simulation using CSVR thermostat.

Parameters:
  • *args – Additional arguments.

  • taut (float) – Time constant for CSVR thermostat coupling, in fs. Defaylt is 100.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nvt-csvr”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__module__ = 'janus_core.calculations.md'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_attach_correlations()

Attach all correlations to self.dyn.

Return type:

None

_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_optimize_structure()

Perform geometry optimization.

Return type:

None

_parse_correlations()

Parse correlation kwargs into Correlations.

Return type:

None

_post_process()

Compute properties after MD run.

Return type:

None

_prepare_restart()

Prepare restart files, structure and offset.

Return type:

None

_reset_velocities()

Reset velocities and (optionally) rotation of system while equilibrating.

Return type:

None

property _restart_file: str

Restart file name.

Returns:

File name for restart files.

Return type:

str

property _restart_stem: str

Stem for restart files.

Restart files will be named {restart_stem}-{step}.extxyz. If file_prefix is specified, restart_stem will be of the form {file_prefix}-{param_prefix}-res.

Returns:

Stem for restart files.

Return type:

str

_rotate_restart_files()

Rotate restart files.

Return type:

None

_run_dynamics()

Run dynamics and/or temperature ramp.

Return type:

None

_set_info()

Set time in fs, current dynamics step, and density to info.

Return type:

None

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

_set_param_prefix(file_prefix=None)

Set ensemble parameters for output files.

Parameters:

file_prefix (str | Path | None) – Prefix for output filenames on class init. If not None, param_prefix = “”.

Returns:

Formatted ensemble parameters, including temp ramp range and/or and MD temp.

Return type:

str

_set_velocity_distribution()

Set velocities to current target temperature.

Sets Maxwell-Boltzmann velocity distribution, as well as removing centre-of-mass momentum, and (optionally) total angular momentum.

Return type:

None

_write_correlations()

Write out the correlations.

Return type:

None

_write_final_state()

Write the final system state.

Return type:

None

_write_header()

Write header for stats file.

Return type:

None

_write_restart()

Write restart file and (optionally) rotate files saved.

Return type:

None

_write_stats_file()

Write molecular dynamics statistics.

Return type:

None

_write_traj()

Write current structure to trajectory file.

Return type:

None

property default_formats: dict[str, str]

Default format of returned statistics.

Returns:

Default formats attached to statistical properties.

Return type:

dict[str, str]

dyn: Langevin | VelocityVerlet | NPT
get_stats()

Get thermodynamical statistics to be written to file.

Returns:

Thermodynamical statistics to be written out.

Return type:

dict[str, float]

run()

Run molecular dynamics simulation and/or temperature ramp.

Return type:

None

property unit_info: dict[str, str]

Get units of returned statistics.

Returns:

Units attached to statistical properties.

Return type:

dict[str, str]

class janus_core.calculations.md.NVT_NH(*args, thermostat_time=50.0, ensemble='nvt-nh', ensemble_kwargs=None, **kwargs)[source]

Bases: NPT

Configure NVT Nosé-Hoover simulation.

Parameters:
  • *args – Additional arguments.

  • thermostat_time (float) – Thermostat time, in fs. Default is 50.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nvt-nh”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__abstractmethods__ = frozenset({})
__annotations__ = {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.md', '__doc__': '\n    Configure NVT Nosé-Hoover simulation.\n\n    Parameters\n    ----------\n    *args\n        Additional arguments.\n    thermostat_time\n        Thermostat time, in fs. Default is 50.0.\n    ensemble\n        Name for thermodynamic ensemble. Default is "nvt-nh".\n    ensemble_kwargs\n        Keyword arguments to pass to ensemble initialization. Default is {}.\n    **kwargs\n        Additional keyword arguments.\n    ', '__init__': <function NVT_NH.__init__>, 'get_stats': <function NVT_NH.get_stats>, 'unit_info': <property object>, 'default_formats': <property object>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {'dyn': 'Langevin | VelocityVerlet | ASE_NPT'}})
__init__(*args, thermostat_time=50.0, ensemble='nvt-nh', ensemble_kwargs=None, **kwargs)[source]

Initialise dynamics for NVT Nosé-Hoover simulation.

Parameters:
  • *args – Additional arguments.

  • thermostat_time (float) – Thermostat time, in fs. Default is 50.0.

  • ensemble (Literal['nph', 'npt', 'nve', 'nvt', 'nvt-nh', 'nvt-csvr']) – Name for thermodynamic ensemble. Default is “nvt-nh”.

  • ensemble_kwargs (dict[str, Any] | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • **kwargs – Additional keyword arguments.

__module__ = 'janus_core.calculations.md'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_attach_correlations()

Attach all correlations to self.dyn.

Return type:

None

_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_optimize_structure()

Perform geometry optimization.

Return type:

None

_parse_correlations()

Parse correlation kwargs into Correlations.

Return type:

None

_post_process()

Compute properties after MD run.

Return type:

None

_prepare_restart()

Prepare restart files, structure and offset.

Return type:

None

_reset_velocities()

Reset velocities and (optionally) rotation of system while equilibrating.

Return type:

None

property _restart_file: str

Restart file name.

Returns:

File name for restart files.

Return type:

str

property _restart_stem: str

Stem for restart files.

Restart files will be named {restart_stem}-{step}.extxyz. If file_prefix is specified, restart_stem will be of the form {file_prefix}-{param_prefix}-res.

Returns:

Stem for restart files.

Return type:

str

_rotate_restart_files()

Rotate restart files.

Return type:

None

_run_dynamics()

Run dynamics and/or temperature ramp.

Return type:

None

_set_info()

Set time in fs, current dynamics step, and density to info.

Return type:

None

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

_set_param_prefix(file_prefix=None)

Set ensemble parameters for output files.

Parameters:

file_prefix (str | Path | None) – Prefix for output filenames on class init. If not None, param_prefix = “”.

Returns:

Formatted ensemble parameters, including pressure and temperature(s).

Return type:

str

_set_velocity_distribution()

Set velocities to current target temperature.

Sets Maxwell-Boltzmann velocity distribution, as well as removing centre-of-mass momentum, and (optionally) total angular momentum.

Return type:

None

_write_correlations()

Write out the correlations.

Return type:

None

_write_final_state()

Write the final system state.

Return type:

None

_write_header()

Write header for stats file.

Return type:

None

_write_restart()

Write restart file and (optionally) rotate files saved.

Return type:

None

_write_stats_file()

Write molecular dynamics statistics.

Return type:

None

_write_traj()

Write current structure to trajectory file.

Return type:

None

property default_formats: dict[str, str]

Default format of returned statistics.

Returns:

Default formats attached to statistical properties.

Return type:

dict[str, str]

dyn: Langevin | VelocityVerlet | NPT
get_stats()[source]

Get thermodynamical statistics to be written to file.

Returns:

Thermodynamical statistics to be written out.

Return type:

dict[str, float]

run()

Run molecular dynamics simulation and/or temperature ramp.

Return type:

None

property unit_info: dict[str, str]

Get units of returned statistics.

Returns:

Units attached to statistical properties.

Return type:

dict[str, str]

janus_core.calculations.phonons module

Phonon calculations.

class janus_core.calculations.phonons.Phonons(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, calcs=(), supercell=2, displacement=0.01, displacement_kwargs=None, mesh=(10, 10, 10), symmetrize=False, minimize=False, minimize_kwargs=None, n_qpoints=51, qpoint_file=None, dos_kwargs=None, pdos_kwargs=None, temp_min=0.0, temp_max=1000.0, temp_step=50.0, force_consts_to_hdf5=True, plot_to_file=False, write_results=True, write_full=True, file_prefix=None, enable_progress_bar=False)[source]

Bases: BaseCalculation

Configure, perform phonon calculations and write out results.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to calculate phonons for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to calculate phonons for. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • calcs (Literal['bands', 'dos', 'pdos', 'thermal'] | Sequence[Literal['bands', 'dos', 'pdos', 'thermal']]) – Phonon calculations to run. Default calculates force constants only.

  • supercell (int | list[int]) – The size of a supercell for calculation, or the supercell itself. If a single number is provided, it is interpreted as the size, so a diagonal supercell of that size in all dimensions is constructed. If three values are provided, they are interpreted as the diagonal values of a diagonal supercell. If nine values are provided, they are assumed to be the full supercell matrix in the style of Phonopy, so the first three values will be used as the first row, the second three as the second row, etc. Default is 2.

  • displacement (float) – Displacement for force constants calculation, in A. Default is 0.01.

  • displacement_kwargs (dict[str, Any] | None) – Keyword arguments to pass to generate_displacements. Default is {}.

  • mesh (tuple[int, int, int]) – Mesh for sampling. Default is (10, 10, 10).

  • symmetrize (bool) – Whether to symmetrize structure and force constants after calculation. Default is False.

  • minimize (bool) – Whether to perform geometry optimisation before calculating phonons. Default is False.

  • minimize_kwargs (dict[str, Any] | None) – Keyword arguments to pass to geometry optimizer. Default is {}.

  • n_qpoints (int) – Number of q-points to sample along generated path, including end points. Unused if qpoint_file is specified. Default is 51.

  • qpoint_file (str | Path | None) – Path to yaml file with info to generate a path of q-points for band structure. Default is None.

  • dos_kwargs (dict[str, Any] | None) – Keyword arguments to pass to run_total_dos. Default is {}.

  • pdos_kwargs (dict[str, Any] | None) – Keyword arguments to pass to run_projected_dos. Default is {}.

  • temp_min (float) – Start temperature for thermal properties calculations, in K. Default is 0.0.

  • temp_max (float) – End temperature for thermal properties calculations, in K. Default is 1000.0.

  • temp_step (float) – Temperature step for thermal properties calculations, in K. Default is 50.0.

  • force_consts_to_hdf5 (bool) – Whether to write force constants in hdf format or not. Default is True.

  • plot_to_file (bool) – Whether to plot various graphs as band stuctures, dos/pdos in svg. Default is False.

  • write_results (bool) – Default for whether to write out results to file. Default is True.

  • write_full (bool) – Whether to maximize information written in various output files. Default is True.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from chemical formula of the structure.

  • enable_progress_bar (bool) – Whether to show a progress bar during phonon calculations. Default is False.

calc

ASE Calculator attached to structure.

Type:

ase.calculators.calculator.Calculator

results

Results of phonon calculations.

Type:

dict

_ASE_to_PhonopyAtoms(struct)[source]

Convert ASE Atoms structure to Phonopy Atoms structure.

Parameters:

struct (Atoms) – ASE Atoms structure to be converted.

Returns:

Converted PhonopyAtoms structure.

Return type:

PhonopyAtoms

_Phonopy_to_ASEAtoms(struct)[source]

Convert Phonopy Atoms structure to ASE Atoms structure.

Parameters:

struct (PhonopyAtoms) – PhonopyAtoms structure to be converted.

Returns:

Converted ASE Atoms structure.

Return type:

Atoms

__abstractmethods__ = frozenset({})
__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'janus_core.calculations.phonons', '__doc__': '\n    Configure, perform phonon calculations and write out results.\n\n    Parameters\n    ----------\n    struct\n        ASE Atoms structure to calculate phonons for. Required if `struct_path` is\n        None. Default is None.\n    struct_path\n        Path of structure to calculate phonons for. Required if `struct` is None.\n        Default is None.\n    arch\n        MLIP architecture to use for calculations. Default is "mace_mp".\n    device\n        Device to run MLIP model on. Default is "cpu".\n    model_path\n        Path to MLIP model. Default is `None`.\n    read_kwargs\n        Keyword arguments to pass to ase.io.read. By default,\n        read_kwargs["index"] is -1.\n    calc_kwargs\n        Keyword arguments to pass to the selected calculator. Default is {}.\n    set_calc\n        Whether to set (new) calculators for structures. Default is None.\n    attach_logger\n        Whether to attach a logger. Default is True if "filename" is passed in\n        log_kwargs, else False.\n    log_kwargs\n        Keyword arguments to pass to `config_logger`. Default is {}.\n    track_carbon\n        Whether to track carbon emissions of calculation. Requires attach_logger.\n        Default is True if attach_logger is True, else False.\n    tracker_kwargs\n        Keyword arguments to pass to `config_tracker`. Default is {}.\n    calcs\n        Phonon calculations to run. Default calculates force constants only.\n    supercell\n        The size of a supercell for calculation, or the supercell itself.\n        If a single number is provided, it is interpreted as the size, so a\n        diagonal supercell of that size in all dimensions is constructed.\n        If three values are provided, they are interpreted as the diagonal\n        values of a diagonal supercell. If nine values are provided, they\n        are assumed to be the full supercell matrix in the style of Phonopy,\n        so the first three values will be used as the first row, the second\n        three as the second row, etc. Default is 2.\n    displacement\n        Displacement for force constants calculation, in A. Default is 0.01.\n    displacement_kwargs\n        Keyword arguments to pass to generate_displacements. Default is {}.\n    mesh\n        Mesh for sampling. Default is (10, 10, 10).\n    symmetrize\n        Whether to symmetrize structure and force constants after calculation.\n        Default is False.\n    minimize\n        Whether to perform geometry optimisation before calculating phonons.\n        Default is False.\n    minimize_kwargs\n        Keyword arguments to pass to geometry optimizer. Default is {}.\n    n_qpoints\n        Number of q-points to sample along generated path, including end points.\n        Unused if `qpoint_file` is specified. Default is 51.\n    qpoint_file\n        Path to yaml file with info to generate a path of q-points for band structure.\n        Default is None.\n    dos_kwargs\n        Keyword arguments to pass to run_total_dos. Default is {}.\n    pdos_kwargs\n        Keyword arguments to pass to run_projected_dos. Default is {}.\n    temp_min\n        Start temperature for thermal properties calculations, in K. Default is 0.0.\n    temp_max\n        End temperature for thermal properties calculations, in K. Default is 1000.0.\n    temp_step\n        Temperature step for thermal properties calculations, in K. Default is 50.0.\n    force_consts_to_hdf5\n        Whether to write force constants in hdf format or not. Default is True.\n    plot_to_file\n        Whether to plot various graphs as band stuctures, dos/pdos in svg.\n        Default is False.\n    write_results\n        Default for whether to write out results to file. Default is True.\n    write_full\n        Whether to maximize information written in various output files.\n        Default is True.\n    file_prefix\n        Prefix for output filenames. Default is inferred from chemical formula of the\n        structure.\n    enable_progress_bar\n        Whether to show a progress bar during phonon calculations. Default is False.\n\n    Attributes\n    ----------\n    calc : ase.calculators.calculator.Calculator\n        ASE Calculator attached to structure.\n    results : dict\n        Results of phonon calculations.\n    ', '__init__': <function Phonons.__init__>, 'calcs': <property object>, 'calc_force_constants': <function Phonons.calc_force_constants>, 'write_force_constants': <function Phonons.write_force_constants>, 'calc_bands': <function Phonons.calc_bands>, 'write_bands': <function Phonons.write_bands>, 'calc_thermal_props': <function Phonons.calc_thermal_props>, 'write_thermal_props': <function Phonons.write_thermal_props>, 'calc_dos': <function Phonons.calc_dos>, 'write_dos': <function Phonons.write_dos>, 'calc_pdos': <function Phonons.calc_pdos>, 'write_pdos': <function Phonons.write_pdos>, '_Phonopy_to_ASEAtoms': <function Phonons._Phonopy_to_ASEAtoms>, '_ASE_to_PhonopyAtoms': <function Phonons._ASE_to_PhonopyAtoms>, '_calc_forces': <function Phonons._calc_forces>, 'run': <function Phonons.run>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {}})
__init__(struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, calcs=(), supercell=2, displacement=0.01, displacement_kwargs=None, mesh=(10, 10, 10), symmetrize=False, minimize=False, minimize_kwargs=None, n_qpoints=51, qpoint_file=None, dos_kwargs=None, pdos_kwargs=None, temp_min=0.0, temp_max=1000.0, temp_step=50.0, force_consts_to_hdf5=True, plot_to_file=False, write_results=True, write_full=True, file_prefix=None, enable_progress_bar=False)[source]

Initialise Phonons class.

Parameters:
  • struct (Atoms | None) – ASE Atoms structure to calculate phonons for. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to calculate phonons for. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is -1.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • calcs (Literal['bands', 'dos', 'pdos', 'thermal'] | Sequence[Literal['bands', 'dos', 'pdos', 'thermal']]) – Phonon calculations to run. Default calculates force constants only.

  • supercell (int | list[int]) – The size of a supercell for calculation, or the supercell itself. If a single number is provided, it is interpreted as the size, so a diagonal supercell of that size in all dimensions is constructed. If three values are provided, they are interpreted as the diagonal values of a diagonal supercell. If nine values are provided, they are assumed to be the full supercell matrix in the style of Phonopy, so the first three values will be used as the first row, the second three as the second row, etc. Default is 2.

  • displacement (float) – Displacement for force constants calculation, in A. Default is 0.01.

  • displacement_kwargs (dict[str, Any] | None) – Keyword arguments to pass to generate_displacements. Default is {}.

  • mesh (tuple[int, int, int]) – Mesh for sampling. Default is (10, 10, 10).

  • symmetrize (bool) – Whether to symmetrize structure and force constants after calculation. Default is False.

  • minimize (bool) – Whether to perform geometry optimisation before calculating phonons. Default is False.

  • minimize_kwargs (dict[str, Any] | None) – Keyword arguments to pass to geometry optimizer. Default is {}.

  • n_qpoints (int) – Number of q-points to sample along generated path, including end points. Unused if qpoint_file is specified. Default is 51.

  • qpoint_file (str | Path | None) – Path to yaml file with info to generate a path of q-points for band structure. Default is None.

  • dos_kwargs (dict[str, Any] | None) – Keyword arguments to pass to run_total_dos. Default is {}.

  • pdos_kwargs (dict[str, Any] | None) – Keyword arguments to pass to run_projected_dos. Default is {}.

  • temp_min (float) – Start temperature for thermal calculations, in K. Default is 0.0.

  • temp_max (float) – End temperature for thermal calculations, in K. Default is 1000.0.

  • temp_step (float) – Temperature step for thermal calculations, in K. Default is 50.0.

  • force_consts_to_hdf5 (bool) – Whether to write force constants in hdf format or not. Default is True.

  • plot_to_file (bool) – Whether to plot various graphs as band stuctures, dos/pdos in svg. Default is False.

  • write_results (bool) – Default for whether to write out results to file. Default is True.

  • write_full (bool) – Whether to maximize information written in various output files. Default is True.

  • file_prefix (str | Path | None) – Prefix for output filenames. Default is inferred from structure name, or chemical formula of the structure.

  • enable_progress_bar (bool) – Whether to show a progress bar during phonon calculations. Default is False.

__module__ = 'janus_core.calculations.phonons'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_build_filename(suffix, *additional, filename=None, prefix_override=None)

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

_calc_forces(struct)[source]

Calculate forces on PhonopyAtoms structure.

Parameters:

struct (PhonopyAtoms) – Structure to calculate forces on.

Returns:

Forces on the structure.

Return type:

ndarray

static _get_default_prefix(file_prefix, struct, struct_path, *additional)

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

_set_info_units(keys=('energy', 'forces', 'stress'))

Save units to structure info.

Parameters:

keys (Sequence[str]) – Keys for which to add units to structure info. Default is (“energy”, “forces”, “stress”).

Return type:

None

calc_bands(write_bands=None, **kwargs)[source]

Calculate band structure and optionally write and plot results.

Parameters:
  • write_bands (bool | None) – Whether to write out results to file. Default is self.write_results.

  • **kwargs – Additional keyword arguments to pass to write_bands.

Return type:

None

calc_dos(*, mesh=None, write_dos=None, **kwargs)[source]

Calculate density of states and optionally write results.

Parameters:
  • mesh (tuple[int, int, int] | None) – Mesh for sampling. Default is self.mesh.

  • write_dos (bool | None) – Whether to write out results to file. Default is True.

  • **kwargs – Additional keyword arguments to pass to write_dos.

Return type:

None

calc_force_constants(write_force_consts=None, **kwargs)[source]

Calculate force constants and optionally write results.

Parameters:
  • write_force_consts (bool | None) – Whether to write out results to file. Default is self.write_results.

  • **kwargs – Additional keyword arguments to pass to write_force_constants.

Return type:

None

calc_pdos(*, mesh=None, write_pdos=None, **kwargs)[source]

Calculate projected density of states and optionally write results.

Parameters:
  • mesh (tuple[int, int, int] | None) – Mesh for sampling. Default is self.mesh.

  • write_pdos (bool | None) – Whether to write out results to file. Default is self.write_results.

  • **kwargs – Additional keyword arguments to pass to write_pdos.

Return type:

None

calc_thermal_props(mesh=None, write_thermal=None, **kwargs)[source]

Calculate thermal properties and optionally write results.

Parameters:
  • mesh (tuple[int, int, int] | None) – Mesh for sampling. Default is self.mesh.

  • write_thermal (bool | None) – Whether to write out thermal properties to file. Default is self.write_results.

  • **kwargs – Additional keyword arguments to pass to write_thermal_props.

Return type:

None

property calcs: Sequence[Literal['bands', 'dos', 'pdos', 'thermal']]

Phonon calculations to be run.

Returns:

Phonon calculations.

Return type:

Sequence[PhononCalcs]

run()[source]

Run phonon calculations.

Return type:

None

write_bands(*, bands_file=None, save_plots=None, plot_file=None)[source]

Write results of band structure calculations.

Parameters:
  • bands_file (str | Path | None) – Name of yaml file to save band structure. Default is inferred from file_prefix.

  • save_plots (bool | None) – Whether to save plot to file. Default is self.plot_to_file.

  • plot_file (str | Path | None) – Name of svg file if saving band structure plot. Default is inferred from file_prefix.

Return type:

None

write_dos(*, dos_file=None, plot_to_file=None, plot_file=None, plot_bands=False, plot_bands_file=None)[source]

Write results of DOS calculation.

Parameters:
  • dos_file (str | Path | None) – Name of data file to save the calculated DOS. Default is inferred from file_prefix.

  • plot_to_file (bool | None) – Whether to save plot to file. Default is self.plot_to_file.

  • plot_file (str | Path | None) – Name of svg file if saving plot of the DOS. Default is inferred from file_prefix.

  • plot_bands (bool) – Whether to plot the band structure and DOS together. Default is True.

  • plot_bands_file (str | Path | None) – Name of svg file if saving plot of the band structure and DOS. Default is inferred from file_prefix.

Return type:

None

write_force_constants(*, phonopy_file=None, force_consts_to_hdf5=None, force_consts_file=None)[source]

Write results of force constants calculations.

Parameters:
  • phonopy_file (str | Path | None) – Name of yaml file to save params of phonopy and optionally force constants. Default is inferred from file_prefix.

  • force_consts_to_hdf5 (bool | None) – Whether to save the force constants separately to an hdf5 file. Default is self.force_consts_to_hdf5.

  • force_consts_file (str | Path | None) – Name of hdf5 file to save force constants. Unused if force_consts_to_hdf5 is False. Default is inferred from file_prefix.

Return type:

None

write_pdos(*, pdos_file=None, plot_to_file=None, plot_file=None)[source]

Write results of PDOS calculation.

Parameters:
  • pdos_file (str | Path | None) – Name of file to save the calculated PDOS. Default is inferred from file_prefix.

  • plot_to_file (bool | None) – Whether to save plot to file. Default is self.plot_to_file.

  • plot_file (str | Path | None) – Name of svg file if saving plot of the calculated PDOS. Default is inferred from file_prefix.

Return type:

None

write_thermal_props(thermal_file=None)[source]

Write results of thermal properties calculations.

Parameters:

thermal_file (str | Path | None) – Name of data file to save thermal properties. Default is inferred from file_prefix.

Return type:

None

janus_core.calculations.single_point module

Prepare and perform single point calculations.

class janus_core.calculations.single_point.SinglePoint(*, struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, properties=(), write_results=False, write_kwargs=None)[source]

Bases: BaseCalculation

Prepare and perform single point calculations.

Parameters:
  • struct (Atoms | Sequence[Atoms] | None) – ASE Atoms structure(s) to simulate. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to simulate. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for single point calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is “:”.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • properties (Literal['energy', 'stress', 'forces', 'hessian'] | Sequence[Literal['energy', 'stress', 'forces', 'hessian']]) – Physical properties to calculate. If not specified, “energy”, “forces”, and “stress” will be returned.

  • write_results (bool) – True to write out structure with results of calculations. Default is False.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write if saving structure with results of calculations. Default is {}.

results

Dictionary of calculated results, with keys from properties.

Type:

CalcResults

__abstractmethods__ = frozenset({})
__annotations__ = {}
__init__(*, struct=None, struct_path=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, set_calc=None, attach_logger=None, log_kwargs=None, track_carbon=None, tracker_kwargs=None, properties=(), write_results=False, write_kwargs=None)[source]

Read the structure being simulated and attach an MLIP calculator.

Parameters:
  • struct (Atoms | Sequence[Atoms] | None) – ASE Atoms structure(s) to simulate. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to simulate. Required if struct is None. Default is None.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for single point calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run MLIP model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. By default, read_kwargs[“index”] is “:”.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is None.

  • attach_logger (bool | None) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

  • properties (Literal['energy', 'stress', 'forces', 'hessian'] | Sequence[Literal['energy', 'stress', 'forces', 'hessian']]) – Physical properties to calculate. If not specified, “energy”, “forces”, and “stress” will be returned.

  • write_results (bool) – True to write out structure with results of calculations. Default is False.

  • write_kwargs (OutputKwargs | None) – Keyword arguments to pass to ase.io.write if saving structure with results of calculations. Default is {}.

__module__ = 'janus_core.calculations.single_point'
_abc_impl = <_abc._abc_data object>
_calc_hessian(struct)[source]

Calculate analytical Hessian for a given structure.

Parameters:

struct (Atoms) – Structure to calculate Hessian for.

Returns:

Analytical Hessian.

Return type:

ndarray

_get_forces()[source]

Calculate forces using MLIP.

Returns:

Forces of structure(s).

Return type:

MaybeList[ndarray]

_get_hessian()[source]

Calculate hessian using MLIP.

Returns:

Hessian of structure(s).

Return type:

MaybeList[ndarray]

_get_potential_energy()[source]

Calculate potential energy using MLIP.

Returns:

Potential energy of structure(s).

Return type:

MaybeList[float]

_get_stress()[source]

Calculate stress using MLIP.

Returns:

Stress of structure(s).

Return type:

MaybeList[ndarray]

property properties: Sequence[Literal['energy', 'stress', 'forces', 'hessian']]

Physical properties to be calculated.

Returns:

Physical properties.

Return type:

Sequence[Properties]

run()[source]

Run single point calculations.

Returns:

Dictionary of calculated results, with keys from properties.

Return type:

CalcResults

janus_core.cli.descriptors module

Set up MLIP descriptors commandline interface.

janus_core.cli.descriptors.descriptors(ctx, struct, invariants_only=True, calc_per_element=False, calc_per_atom=False, arch='mace_mp', device='cpu', model_path=None, out=None, read_kwargs=None, calc_kwargs=None, write_kwargs=None, log=None, tracker=True, summary=None)[source]

Calculate MLIP descriptors for the given structure(s).

Parameters:
  • ctx (Context) – Typer (Click) Context. Automatically set.

  • struct (Path) – Path of structure to simulate.

  • invariants_only (bool) – Whether only the invariant descriptors should be returned. Default is True.

  • calc_per_element (bool) – Whether to calculate mean descriptors for each element. Default is False.

  • calc_per_atom (bool) – Whether to calculate descriptors for each atom. Default is False.

  • arch (str | None) – MLIP architecture to use for single point calculations. Default is “mace_mp”.

  • device (str | None) – Device to run model on. Default is “cpu”.

  • model_path (str | None) – Path to MLIP model. Default is None.

  • out (Path | None) – Path to save structure with calculated results. Default is inferred from name of the structure file.

  • read_kwargs (TyperDict | None) –

    Keyword arguments to pass to ase.io.read. By default,

    read_kwargs[“index”] is “:”.

  • calc_kwargs (TyperDict | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • write_kwargs (TyperDict | None) – Keyword arguments to pass to ase.io.write when saving results. Default is {}.

  • log (Path | None) – Path to write logs to. Default is inferred from the name of the structure file.

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path | None) – Path to save summary of inputs, start/end time, and carbon emissions. Default is inferred from the name of the structure file.

  • config – Path to yaml configuration file to define the above options. Default is None.

Return type:

None

janus_core.cli.eos module

Set up eos commandline interface.

janus_core.cli.eos.eos(ctx, struct, min_volume=0.95, max_volume=1.05, n_volumes=7, eos_type='birchmurnaghan', minimize=True, minimize_all=False, fmax=0.1, minimize_kwargs=None, write_structures=False, write_kwargs=None, plot_to_file=False, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, file_prefix=None, log=None, tracker=True, summary=None)[source]

Calculate equation of state and write out results.

Parameters:
  • ctx (Context) – Typer (Click) Context. Automatically set.

  • struct (Path) – Path of structure to simulate.

  • min_volume (float) – Minimum volume scale factor. Default is 0.95.

  • max_volume (float) – Maximum volume scale factor. Default is 1.05.

  • n_volumes (int) – Number of volumes to use. Default is 7.

  • eos_type (str) – Type of fit for equation of state. Default is “birchmurnaghan”.

  • minimize (bool) – Whether to minimize initial structure before calculations. Default is True.

  • minimize_all (bool) – Whether to optimize geometry for all generated structures. Default is False.

  • fmax (float) – Set force convergence criteria for optimizer in units eV/Å. Default is 0.1.

  • minimize_kwargs (TyperDict | None) – Other keyword arguments to pass to geometry optimizer. Default is {}.

  • write_structures (bool) – True to write out all genereated structures. Default is False.

  • write_kwargs (TyperDict | None) – Keyword arguments to pass to ase.io.write to save generated structures. Default is {}.

  • plot_to_file (bool) – Whether to save plot equation of state to svg. Default is False.

  • arch (str | None) – MLIP architecture to use for geometry optimization. Default is “mace_mp”.

  • device (str | None) – Device to run model on. Default is “cpu”.

  • model_path (str | None) – Path to MLIP model. Default is None.

  • read_kwargs (TyperDict | None) –

    Keyword arguments to pass to ase.io.read. By default,

    read_kwargs[“index”] is -1.

  • calc_kwargs (TyperDict | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • file_prefix (Path | None) – Prefix for output filenames. Default is inferred from structure name, or chemical formula.

  • log (Path | None) – Path to write logs to. Default is inferred from the name of the structure file.

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path | None) – Path to save summary of inputs, start/end time, and carbon emissions. Default is inferred from the name of the structure file.

  • config – Path to yaml configuration file to define the above options. Default is None.

Return type:

None

janus_core.cli.geomopt module

Set up geomopt commandline interface.

janus_core.cli.geomopt._set_minimize_kwargs(minimize_kwargs, traj, opt_cell_lengths, pressure)[source]

Set minimize_kwargs dictionary values.

Parameters:
  • minimize_kwargs (dict[str, Any]) – Other keyword arguments to pass to geometry optimizer.

  • traj (str | None) – Path if saving optimization frames.

  • opt_cell_lengths (bool) – Whether to optimize cell vectors, as well as atomic positions, by setting hydrostatic_strain in the filter function.

  • pressure (float) – Scalar pressure when optimizing cell geometry, in GPa. Passed to the filter function if either opt_cell_lengths or opt_cell_fully is True.

Return type:

None

janus_core.cli.geomopt.geomopt(ctx, struct, optimizer='LBFGS', fmax=0.1, steps=1000, arch='mace_mp', device='cpu', model_path=None, opt_cell_lengths=False, opt_cell_fully=False, filter_func=None, pressure=0.0, symmetrize=False, symmetry_tolerance=0.001, out=None, traj=None, read_kwargs=None, calc_kwargs=None, minimize_kwargs=None, write_kwargs=None, log=None, tracker=True, summary=None)[source]

Perform geometry optimization and save optimized structure to file.

Parameters:
  • ctx (Context) – Typer (Click) Context. Automatically set.

  • struct (Path) – Path of structure to simulate.

  • optimizer (str | None) – Name of optimization function from ase.optimize. Default is LBFGS.

  • fmax (float) – Set force convergence criteria for optimizer, in eV/Å. Default is 0.1.

  • steps (int) – Set maximum number of optimization steps to run. Default is 1000.

  • arch (str | None) – MLIP architecture to use for geometry optimization. Default is “mace_mp”.

  • device (str | None) – Device to run model on. Default is “cpu”.

  • model_path (str | None) – Path to MLIP model. Default is None.

  • opt_cell_lengths (bool) – Whether to optimize cell vectors, as well as atomic positions, by setting hydrostatic_strain in the filter function. Default is False.

  • opt_cell_fully (bool) – Whether to fully optimize the cell vectors, angles, and atomic positions. Default is False.

  • filter_func (str | None) – Name of filter function from ase.filters or ase.constraints, to apply constraints to atoms. If using –opt-cell-lengths or –opt-cell-fully, defaults to FrechetCellFilter if available, otherwise ExpCellFilter.

  • pressure (float) – Scalar pressure when optimizing cell geometry, in GPa. Passed to the filter function if either opt_cell_lengths or opt_cell_fully is True. Default is 0.0.

  • symmetrize (bool) – Whether to refine symmetry after geometry optimization. Default is False.

  • symmetry_tolerance (float) – Atom displacement tolerance for spglib symmetry determination, in Å. Default is 0.001.

  • out (Path | None) – Path to save optimized structure, or last structure if optimization did not converge. Default is inferred from name of structure file.

  • traj (str) – Path if saving optimization frames. Default is None.

  • read_kwargs (TyperDict | None) –

    Keyword arguments to pass to ase.io.read. By default,

    read_kwargs[“index”] is -1.

  • calc_kwargs (TyperDict | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • minimize_kwargs (TyperDict | None) – Other keyword arguments to pass to geometry optimizer. Default is {}.

  • write_kwargs (TyperDict | None) – Keyword arguments to pass to ase.io.write when saving optimized structure. Default is {}.

  • log (Path | None) – Path to write logs to. Default is inferred from the name of the structure file.

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path | None) – Path to save summary of inputs, start/end time, and carbon emissions. Default is inferred from the name of the structure file.

  • config – Path to yaml configuration file to define the above options. Default is None.

Return type:

None

janus_core.cli.janus module

Set up commandline interface.

janus_core.cli.janus.print_version(version=None)[source]

Print current janus-core version and exit.

Parameters:

version (bool) – Whether to print the current janus-core version.

Return type:

None

janus_core.cli.md module

Set up md commandline interface.

janus_core.cli.md.md(ctx, ensemble, struct, steps=0, timestep=1.0, temp=300.0, thermostat_time=50.0, barostat_time=75.0, bulk_modulus=2.0, pressure=0.0, friction=0.005, taut=100.0, ensemble_kwargs=None, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, equil_steps=0, minimize=False, minimize_every=-1, minimize_kwargs=None, rescale_velocities=False, remove_rot=False, rescale_every=10, file_prefix=None, restart=False, restart_auto=True, restart_stem=None, restart_every=1000, rotate_restart=False, restarts_to_keep=4, final_file=None, stats_file=None, stats_every=100, traj_file=None, traj_append=False, traj_start=0, traj_every=100, temp_start=None, temp_end=None, temp_step=None, temp_time=None, write_kwargs=None, post_process_kwargs=None, seed=None, log=None, tracker=True, summary=None)[source]

Run molecular dynamics simulation, and save trajectory and statistics.

Parameters:
  • ctx (Context) – Typer (Click) Context. Automatically set.

  • ensemble (str) – Name of thermodynamic ensemble.

  • struct (Path) – Path of structure to simulate.

  • steps (int) – Number of steps in simulation. Default is 0.

  • timestep (float) – Timestep for integrator, in fs. Default is 1.0.

  • temp (float) – Temperature, in K. Default is 300.

  • thermostat_time (float) – Thermostat time, in fs. Default is 50.0.

  • barostat_time (float) – Barostat time, in fs. Default is 75.0.

  • bulk_modulus (float) – Bulk modulus, in GPa. Default is 2.0.

  • pressure (float) – Pressure, in GPa. Default is 0.0.

  • friction (float) – Friction coefficient in fs^-1. Default is 0.005.

  • taut (float) – Time constant for CSVR thermostat coupling, in fs. Default is 100.0.

  • ensemble_kwargs (TyperDict | None) – Keyword arguments to pass to ensemble initialization. Default is {}.

  • arch (str | None) – MLIP architecture to use for molecular dynamics. Default is “mace_mp”.

  • device (str | None) – Device to run model on. Default is “cpu”.

  • model_path (str | None) – Path to MLIP model. Default is None.

  • read_kwargs (TyperDict | None) –

    Keyword arguments to pass to ase.io.read. By default,

    read_kwargs[“index”] is -1.

  • calc_kwargs (TyperDict | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • equil_steps (int) – Maximum number of steps at which to perform optimization and reset velocities. Default is 0.

  • minimize (bool) – Whether to minimize structure during equilibration. Default is False.

  • minimize_every (int) – Frequency of minimizations. Default is -1, which disables minimization after beginning dynamics.

  • minimize_kwargs (TyperDict | None) – Keyword arguments to pass to geometry optimizer. Default is {}.

  • rescale_velocities (bool) – Whether to rescale velocities. Default is False.

  • remove_rot (bool) – Whether to remove rotation. Default is False.

  • rescale_every (int) – Frequency to rescale velocities. Default is 10.

  • file_prefix (Path | None) – Prefix for output filenames. Default is inferred from structure, ensemble, and temperature.

  • restart (bool) – Whether restarting dynamics. Default is False.

  • restart_auto (bool) – Whether to infer restart file name if restarting dynamics. Default is True.

  • restart_stem (Path | None) – Stem for restart file name. Default inferred from file_prefix.

  • restart_every (int) – Frequency of steps to save restart info. Default is 1000.

  • rotate_restart (bool) – Whether to rotate restart files. Default is False.

  • restarts_to_keep (int) – Restart files to keep if rotating. Default is 4.

  • final_file (Path | None) – File to save final configuration at each temperature of similation. Default inferred from file_prefix.

  • stats_file (Path | None) – File to save thermodynamical statistics. Default inferred from file_prefix.

  • stats_every (int) – Frequency to output statistics. Default is 100.

  • traj_file (Path | None) – Trajectory file to save. Default inferred from file_prefix.

  • traj_append (bool) – Whether to append trajectory. Default is False.

  • traj_start (int) – Step to start saving trajectory. Default is 0.

  • traj_every (int) – Frequency of steps to save trajectory. Default is 100.

  • temp_start (float | None) – Temperature to start heating, in K. Default is None, which disables heating.

  • temp_end (float | None) – Maximum temperature for heating, in K. Default is None, which disables heating.

  • temp_step (float | None) – Size of temperature steps when heating, in K. Default is None, which disables heating.

  • temp_time (float | None) – Time between heating steps, in fs. Default is None, which disables heating.

  • write_kwargs (TyperDict | None) – Keyword arguments to pass to output_structs when saving trajectory and final files. Default is {}.

  • post_process_kwargs (TyperDict | None) – Kwargs to pass to post-processing.

  • seed (int | None) – Random seed used by numpy.random and random functions, such as in Langevin. Default is None.

  • log (Path | None) – Path to write logs to. Default is inferred from the name of the structure file.

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path | None) – Path to save summary of inputs, start/end time, and carbon emissions. Default is inferred from the name of the structure file.

  • config – Path to yaml configuration file to define the above options. Default is None.

Return type:

None

janus_core.cli.phonons module

Set up phonons commandline interface.

janus_core.cli.phonons.phonons(ctx, struct, supercell='2 2 2', displacement=0.01, displacement_kwargs=None, mesh=(10, 10, 10), bands=False, n_qpoints=51, qpoint_file=None, dos=False, dos_kwargs=None, pdos=False, pdos_kwargs=None, thermal=False, temp_min=0.0, temp_max=1000.0, temp_step=50, symmetrize=False, minimize=False, fmax=0.1, minimize_kwargs=None, hdf5=True, plot_to_file=False, write_full=True, arch='mace_mp', device='cpu', model_path=None, read_kwargs=None, calc_kwargs=None, file_prefix=None, log=None, tracker=True, summary=None)[source]

Perform phonon calculations and write out results.

Parameters:
  • ctx (Context) – Typer (Click) Context. Automatically set.

  • struct (Path) – Path of structure to simulate.

  • supercell (str) – Supercell matrix, in the Phonopy style. Must be passed as a string in one of three forms: single integer (‘2’), which specifies all diagonal elements; three integers (‘1 2 3’), which specifies each individual diagonal element; or nine values (‘1 2 3 4 5 6 7 8 9’), which specifies all elements, filling the matrix row-wise.

  • displacement (float) – Displacement for force constants calculation, in A. Default is 0.01.

  • displacement_kwargs (TyperDict | None) – Keyword arguments to pass to generate_displacements. Default is {}.

  • mesh (tuple[int, int, int]) – Mesh for sampling. Default is (10, 10, 10).

  • bands (bool) – Whether to calculate and save the band structure. Default is False.

  • n_qpoints (int) – Number of q-points to sample along generated path, including end points. Unused if qpoint_file is specified. Default is 51.

  • qpoint_file (Path | None) – Path to yaml file with info to generate a path of q-points for band structure. Default is None.

  • dos (bool) – Whether to calculate and save the DOS. Default is False.

  • dos_kwargs (TyperDict | None) – Other keyword arguments to pass to run_total_dos. Default is {}.

  • pdos (bool) – Whether to calculate and save the PDOS. Default is False.

  • pdos_kwargs (TyperDict | None) – Other keyword arguments to pass to run_projected_dos. Default is {}.

  • thermal (bool) – Whether to calculate thermal properties. Default is False.

  • temp_min (float) – Start temperature for thermal calculations, in K. Unused if thermal is False. Default is 0.0.

  • temp_max (float) – End temperature for thermal calculations, in K. Unused if thermal is False. Default is 1000.0.

  • temp_step (float) – Temperature step for thermal calculations, in K. Unused if thermal is False. Default is 50.0.

  • symmetrize (bool) – Whether to symmetrize force constants. Default is False.

  • minimize (bool) – Whether to minimize structure before calculations. Default is False.

  • fmax (float) – Set force convergence criteria for optimizer in units eV/Å. Default is 0.1.

  • minimize_kwargs (TyperDict | None) – Other keyword arguments to pass to geometry optimizer. Default is {}.

  • hdf5 (bool) – Whether to save force constants in hdf5 format. Default is True.

  • plot_to_file (bool) – Whether to plot. Default is False.

  • write_full (bool) – Whether to maximize information written in various output files. Default is True.

  • arch (str | None) – MLIP architecture to use for geometry optimization. Default is “mace_mp”.

  • device (str | None) – Device to run model on. Default is “cpu”.

  • model_path (str | None) – Path to MLIP model. Default is None.

  • read_kwargs (TyperDict | None) –

    Keyword arguments to pass to ase.io.read. By default,

    read_kwargs[“index”] is 0.

  • calc_kwargs (TyperDict | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • file_prefix (Path | None) – Prefix for output filenames. Default is inferred from structure name, or chemical formula.

  • log (Path | None) – Path to write logs to. Default is inferred from the name of the structure file.

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path | None) – Path to save summary of inputs, start/end time, and carbon emissions. Default is inferred from the name of the structure file.

  • config – Path to yaml configuration file to define the above options. Default is None.

Return type:

None

janus_core.cli.preprocess module

Set up MLIP preprocessing commandline interface.

janus_core.cli.preprocess.preprocess(mlip_config, log=PosixPath('preprocess-log.yml'), tracker=True, summary=PosixPath('preprocess-summary.yml'))[source]

Convert training data to hdf5 by passing a configuration file to the MLIP’s CLI.

Parameters:
  • mlip_config (Path) – Configuration file to pass to MLIP CLI.

  • log (Path) – Path to write logs to. Default is Path(“preprocess-log.yml”).

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path) – Path to save summary of inputs, start/end time, and carbon emissions. Default is Path(“preprocess-summary.yml”).

janus_core.cli.singlepoint module

Set up singlepoint commandline interface.

janus_core.cli.singlepoint.singlepoint(ctx, struct, arch='mace_mp', device='cpu', model_path=None, properties=None, out=None, read_kwargs=None, calc_kwargs=None, write_kwargs=None, log=None, tracker=True, summary=None)[source]

Perform single point calculations and save to file.

Parameters:
  • ctx (Context) – Typer (Click) Context. Automatically set.

  • struct (Path) – Path of structure to simulate.

  • arch (str | None) – MLIP architecture to use for single point calculations. Default is “mace_mp”.

  • device (str | None) – Device to run model on. Default is “cpu”.

  • model_path (str | None) – Path to MLIP model. Default is None.

  • properties (list[str] | None) – Physical properties to calculate. Default is (“energy”, “forces”, “stress”).

  • out (Path | None) – Path to save structure with calculated results. Default is inferred from name of the structure file.

  • read_kwargs (TyperDict | None) –

    Keyword arguments to pass to ase.io.read. By default,

    read_kwargs[“index”] is “:”.

  • calc_kwargs (TyperDict | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • write_kwargs (TyperDict | None) – Keyword arguments to pass to ase.io.write when saving results. Default is {}.

  • log (Path | None) – Path to write logs to. Default is inferred from the name of the structure file.

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path | None) – Path to save summary of inputs, start/end time, and carbon emissions. Default is inferred from the name of the structure file.

  • config – Path to yaml configuration file to define the above options. Default is None.

Return type:

None

janus_core.cli.train module

Set up MLIP training commandline interface.

janus_core.cli.train.train(mlip_config, fine_tune=False, log=PosixPath('train-log.yml'), tracker=True, summary=PosixPath('train-summary.yml'))[source]

Run training for MLIP by passing a configuration file to the MLIP’s CLI.

Parameters:
  • mlip_config (Path) – Configuration file to pass to MLIP CLI.

  • fine_tune (bool) – Whether to fine-tune a foundational model. Default is False.

  • log (Path) – Path to write logs to. Default is Path(“train-log.yml”).

  • tracker (bool) – Whether to save carbon emissions of calculation in log file and summary. Default is True.

  • summary (Path) – Path to save summary of inputs, start/end time, and carbon emissions. Default is Path(“train-summary.yml”).

Return type:

None

janus_core.cli.types module

Module containing types used for Janus-Core CLI.

class janus_core.cli.types.TyperDict(value)[source]

Bases: object

Custom dictionary for typer.

Parameters:

value (str) – Value of string representing a dictionary.

__dict__ = mappingproxy({'__module__': 'janus_core.cli.types', '__doc__': '\n    Custom dictionary for typer.\n\n    Parameters\n    ----------\n    value\n        Value of string representing a dictionary.\n    ', '__init__': <function TyperDict.__init__>, '__str__': <function TyperDict.__str__>, '__dict__': <attribute '__dict__' of 'TyperDict' objects>, '__weakref__': <attribute '__weakref__' of 'TyperDict' objects>, '__annotations__': {}})
__init__(value)[source]

Initialise class.

Parameters:

value (str) – Value of string representing a dictionary.

__module__ = 'janus_core.cli.types'
__str__()[source]

Return string representation of class.

Returns:

Class name and value of string representing a dictionary.

Return type:

str

__weakref__

list of weak references to the object

janus_core.cli.types.parse_dict_class(value)[source]

Convert string input into a dictionary.

Parameters:

value (str | ASEReadArgs) – String representing dictionary to be parsed.

Returns:

Parsed string as a dictionary.

Return type:

TyperDict

janus_core.cli.utils module

Utility functions for CLI.

janus_core.cli.utils.carbon_summary(*, summary, log)[source]

Calculate and write carbon tracking summary.

Parameters:
  • summary (Path) – Path to summary file being saved.

  • log (Path) – Path to log file with carbon emissions saved.

Return type:

None

janus_core.cli.utils.check_config(ctx)[source]

Check options in configuration file are valid options for CLI command.

Parameters:

ctx (Context) – Typer (Click) Context within command.

Return type:

None

janus_core.cli.utils.dict_paths_to_strs(dictionary)[source]

Recursively iterate over dictionary, converting Path values to strings.

Parameters:

dictionary (dict) – Dictionary to be converted.

Return type:

None

janus_core.cli.utils.dict_remove_hyphens(dictionary)[source]

Recursively iterate over dictionary, replacing hyphens with underscores in keys.

Parameters:

dictionary (dict) – Dictionary to be converted.

Returns:

Dictionary with hyphens in keys replaced with underscores.

Return type:

dict

janus_core.cli.utils.dict_tuples_to_lists(dictionary)[source]

Recursively iterate over dictionary, converting tuple values to lists.

Parameters:

dictionary (dict) – Dictionary to be converted.

Return type:

None

janus_core.cli.utils.end_summary(summary)[source]

Write final time to summary and close.

Parameters:

summary (Path) – Path to summary file being saved.

Return type:

None

janus_core.cli.utils.parse_typer_dicts(typer_dicts)[source]

Convert list of TyperDict objects to list of dictionaries.

Parameters:

typer_dicts (list[TyperDict]) – List of TyperDict objects to convert.

Returns:

List of converted dictionaries.

Return type:

list[dict]

Raises:

ValueError – If items in list are not converted to dicts.

janus_core.cli.utils.save_struct_calc(*, inputs, struct, struct_path, arch, device, model_path, read_kwargs, calc_kwargs, log)[source]

Add structure and calculator input information to a dictionary.

Parameters:
  • inputs (dict) – Inputs dictionary to add information to.

  • struct (Atoms | Sequence[Atoms]) – Structure to be simulated.

  • struct_path (Path) – Path of structure file.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run calculations on.

  • model_path (str) – Path to MLIP model.

  • read_kwargs (ASEReadArgs) – Keyword arguments to pass to ase.io.read.

  • calc_kwargs (dict[str, Any]) – Keyword arguments to pass to the calculator.

  • log (Path) – Path to log file.

Return type:

None

janus_core.cli.utils.set_read_kwargs_index(read_kwargs)[source]

Set default read_kwargs[“index”] to final image and check its value is an integer.

To ensure only a single Atoms object is read, slices such as “:” are forbidden.

Parameters:

read_kwargs (dict[str, Any]) – Keyword arguments to be passed to ase.io.read. If specified, read_kwargs[“index”] must be an integer, and if not, a default value of -1 is set.

Return type:

None

janus_core.cli.utils.start_summary(*, command, summary, inputs)[source]

Write initial summary contents.

Parameters:
  • command (str) – Name of CLI command being used.

  • summary (Path) – Path to summary file being saved.

  • inputs (dict) – Inputs to CLI command to save.

Return type:

None

janus_core.cli.utils.yaml_converter_loader(config_file)[source]

Load yaml configuration and replace hyphens with underscores.

Parameters:

config_file (str) – Yaml configuration file to read.

Returns:

Dictionary with loaded configuration.

Return type:

dict[str, Any]

janus_core.helpers.janus_types module

Module containing types used in Janus-Core.

class janus_core.helpers.janus_types.ASEOptArgs[source]

Bases: TypedDict

Main arguments for ase optimisers.

__annotations__ = {'logfile': ForwardRef('PathLike | None', module='janus_core.helpers.janus_types'), 'restart': ForwardRef('bool | None', module='janus_core.helpers.janus_types'), 'trajectory': ForwardRef('str | None', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'restart': ForwardRef('bool | None', module='janus_core.helpers.janus_types'), 'logfile': ForwardRef('PathLike | None', module='janus_core.helpers.janus_types'), 'trajectory': ForwardRef('str | None', module='janus_core.helpers.janus_types')}, '__doc__': 'Main arguments for ase optimisers.', '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of 'ASEOptArgs' objects>, '__weakref__': <attribute '__weakref__' of 'ASEOptArgs' objects>, '__required_keys__': frozenset(), '__optional_keys__': frozenset({'restart', 'logfile', 'trajectory'}), '__total__': False})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({'logfile', 'restart', 'trajectory'})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({})
__total__ = False
__weakref__

list of weak references to the object

logfile: str | Path | None
restart: bool | None
trajectory: str | None
class janus_core.helpers.janus_types.ASEReadArgs[source]

Bases: TypedDict

Main arguments for ase.io.read.

__annotations__ = {'do_not_split_by_at_sign': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'filename': ForwardRef('str | PurePath | IO', module='janus_core.helpers.janus_types'), 'format': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'index': ForwardRef('int | slice | str', module='janus_core.helpers.janus_types'), 'parallel': ForwardRef('bool', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'filename': ForwardRef('str | PurePath | IO', module='janus_core.helpers.janus_types'), 'index': ForwardRef('int | slice | str', module='janus_core.helpers.janus_types'), 'format': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'parallel': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'do_not_split_by_at_sign': ForwardRef('bool', module='janus_core.helpers.janus_types')}, '__doc__': 'Main arguments for ase.io.read.', '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of 'ASEReadArgs' objects>, '__weakref__': <attribute '__weakref__' of 'ASEReadArgs' objects>, '__required_keys__': frozenset(), '__optional_keys__': frozenset({'format', 'index', 'filename', 'do_not_split_by_at_sign', 'parallel'}), '__total__': False})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({'do_not_split_by_at_sign', 'filename', 'format', 'index', 'parallel'})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({})
__total__ = False
__weakref__

list of weak references to the object

do_not_split_by_at_sign: bool
filename: str | PurePath | IO
format: str | None
index: int | slice | str
parallel: bool
class janus_core.helpers.janus_types.ASEWriteArgs[source]

Bases: TypedDict

Main arguments for ase.io.write.

__annotations__ = {'append': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'filename': ForwardRef('str | PurePath | IO', module='janus_core.helpers.janus_types'), 'format': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'images': ForwardRef('MaybeSequence[Atoms]', module='janus_core.helpers.janus_types'), 'parallel': ForwardRef('bool', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'filename': ForwardRef('str | PurePath | IO', module='janus_core.helpers.janus_types'), 'images': ForwardRef('MaybeSequence[Atoms]', module='janus_core.helpers.janus_types'), 'format': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'parallel': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'append': ForwardRef('bool', module='janus_core.helpers.janus_types')}, '__doc__': 'Main arguments for ase.io.write.', '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of 'ASEWriteArgs' objects>, '__weakref__': <attribute '__weakref__' of 'ASEWriteArgs' objects>, '__required_keys__': frozenset(), '__optional_keys__': frozenset({'format', 'filename', 'parallel', 'append', 'images'}), '__total__': False})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({'append', 'filename', 'format', 'images', 'parallel'})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({})
__total__ = False
__weakref__

list of weak references to the object

append: bool
filename: str | PurePath | IO
format: str | None
images: Atoms | Sequence[Atoms]
parallel: bool
class janus_core.helpers.janus_types.CalcResults[source]

Bases: TypedDict

Return type from calculations.

__annotations__ = {'energy': ForwardRef('MaybeList[float]', module='janus_core.helpers.janus_types'), 'forces': ForwardRef('MaybeList[NDArray[np.float64]]', module='janus_core.helpers.janus_types'), 'stress': ForwardRef('MaybeList[NDArray[np.float64]]', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'energy': ForwardRef('MaybeList[float]', module='janus_core.helpers.janus_types'), 'forces': ForwardRef('MaybeList[NDArray[np.float64]]', module='janus_core.helpers.janus_types'), 'stress': ForwardRef('MaybeList[NDArray[np.float64]]', module='janus_core.helpers.janus_types')}, '__doc__': 'Return type from calculations.', '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of 'CalcResults' objects>, '__weakref__': <attribute '__weakref__' of 'CalcResults' objects>, '__required_keys__': frozenset(), '__optional_keys__': frozenset({'stress', 'forces', 'energy'}), '__total__': False})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({'energy', 'forces', 'stress'})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({})
__total__ = False
__weakref__

list of weak references to the object

energy: float | list[float]
forces: ndarray[Any, dtype[float64]] | list[ndarray[Any, dtype[float64]]]
stress: ndarray[Any, dtype[float64]] | list[ndarray[Any, dtype[float64]]]
class janus_core.helpers.janus_types.CorrelationKwargs[source]

Bases: TypedDict

Arguments for on-the-fly correlations <ab>.

__annotations__ = {'a': ForwardRef('Observable', module='janus_core.helpers.janus_types'), 'averaging': ForwardRef('int', module='janus_core.helpers.janus_types'), 'b': ForwardRef('Observable', module='janus_core.helpers.janus_types'), 'blocks': ForwardRef('int', module='janus_core.helpers.janus_types'), 'name': ForwardRef('str', module='janus_core.helpers.janus_types'), 'points': ForwardRef('int', module='janus_core.helpers.janus_types'), 'update_frequency': ForwardRef('int', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'a': ForwardRef('Observable', module='janus_core.helpers.janus_types'), 'b': ForwardRef('Observable', module='janus_core.helpers.janus_types'), 'name': ForwardRef('str', module='janus_core.helpers.janus_types'), 'blocks': ForwardRef('int', module='janus_core.helpers.janus_types'), 'points': ForwardRef('int', module='janus_core.helpers.janus_types'), 'averaging': ForwardRef('int', module='janus_core.helpers.janus_types'), 'update_frequency': ForwardRef('int', module='janus_core.helpers.janus_types')}, '__doc__': 'Arguments for on-the-fly correlations <ab>.', '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of 'CorrelationKwargs' objects>, '__weakref__': <attribute '__weakref__' of 'CorrelationKwargs' objects>, '__required_keys__': frozenset({'blocks', 'averaging', 'b', 'name', 'points', 'update_frequency', 'a'}), '__optional_keys__': frozenset(), '__total__': True})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({'a', 'averaging', 'b', 'blocks', 'name', 'points', 'update_frequency'})
__total__ = True
__weakref__

list of weak references to the object

a: Observable

observable a in <ab>, with optional args and kwargs

averaging: int

averaging between blocks

b: Observable

observable b in <ab>, with optional args and kwargs

blocks: int

blocks used in multi-tau algorithm

name: str

name used for correlation in output

points: int

points per block

update_frequency: int

frequency to update the correlation (steps)

class janus_core.helpers.janus_types.EoSResults[source]

Bases: TypedDict

Return type from calculations.

__annotations__ = {'bulk_modulus': ForwardRef('float', module='janus_core.helpers.janus_types'), 'e_0': ForwardRef('float', module='janus_core.helpers.janus_types'), 'eos': ForwardRef('EquationOfState', module='janus_core.helpers.janus_types'), 'v_0': ForwardRef('float', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'eos': ForwardRef('EquationOfState', module='janus_core.helpers.janus_types'), 'bulk_modulus': ForwardRef('float', module='janus_core.helpers.janus_types'), 'v_0': ForwardRef('float', module='janus_core.helpers.janus_types'), 'e_0': ForwardRef('float', module='janus_core.helpers.janus_types')}, '__doc__': 'Return type from calculations.', '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of 'EoSResults' objects>, '__weakref__': <attribute '__weakref__' of 'EoSResults' objects>, '__required_keys__': frozenset(), '__optional_keys__': frozenset({'e_0', 'v_0', 'eos', 'bulk_modulus'}), '__total__': False})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({'bulk_modulus', 'e_0', 'eos', 'v_0'})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({})
__total__ = False
__weakref__

list of weak references to the object

bulk_modulus: float
e_0: float
eos: EquationOfState
v_0: float
class janus_core.helpers.janus_types.LogLevel(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Supported options for logger levels.

DEBUG = 10
ERROR = 40
INFO = 20
WARNING = 30
__module__ = 'janus_core.helpers.janus_types'
class janus_core.helpers.janus_types.OutputKwargs[source]

Bases: ASEWriteArgs

Main keyword arguments for output_structs.

__annotations__ = {'append': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'filename': ForwardRef('str | PurePath | IO', module='janus_core.helpers.janus_types'), 'format': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'images': ForwardRef('MaybeSequence[Atoms]', module='janus_core.helpers.janus_types'), 'invalidate_calc': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'parallel': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'properties': ForwardRef('Collection[Properties]', module='janus_core.helpers.janus_types'), 'set_info': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'write_results': ForwardRef('bool', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'filename': ForwardRef('str | PurePath | IO', module='janus_core.helpers.janus_types'), 'images': ForwardRef('MaybeSequence[Atoms]', module='janus_core.helpers.janus_types'), 'format': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'parallel': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'append': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'set_info': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'write_results': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'properties': ForwardRef('Collection[Properties]', module='janus_core.helpers.janus_types'), 'invalidate_calc': ForwardRef('bool', module='janus_core.helpers.janus_types')}, '__doc__': 'Main keyword arguments for `output_structs`.', '__dict__': <attribute '__dict__' of 'OutputKwargs' objects>, '__weakref__': <attribute '__weakref__' of 'OutputKwargs' objects>, '__orig_bases__': (<class 'janus_core.helpers.janus_types.ASEWriteArgs'>,), '__required_keys__': frozenset(), '__optional_keys__': frozenset({'format', 'append', 'images', 'write_results', 'set_info', 'filename', 'parallel', 'invalidate_calc', 'properties'}), '__total__': False})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({'append', 'filename', 'format', 'images', 'invalidate_calc', 'parallel', 'properties', 'set_info', 'write_results'})
__orig_bases__ = (<class 'janus_core.helpers.janus_types.ASEWriteArgs'>,)
__required_keys__ = frozenset({})
__total__ = False
__weakref__

list of weak references to the object

append: bool
filename: str | PurePath | IO
format: str | None
images: Atoms | Sequence[Atoms]
invalidate_calc: bool
parallel: bool
properties: Collection[Literal['energy', 'stress', 'forces', 'hessian']]
set_info: bool
write_results: bool
class janus_core.helpers.janus_types.PostProcessKwargs[source]

Bases: TypedDict

Main arguments for MD post-processing.

__annotations__ = {'rdf_by_elements': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'rdf_compute': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'rdf_elements': ForwardRef('MaybeSequence[str | int]', module='janus_core.helpers.janus_types'), 'rdf_nbins': ForwardRef('int', module='janus_core.helpers.janus_types'), 'rdf_output_file': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'rdf_rmax': ForwardRef('float', module='janus_core.helpers.janus_types'), 'rdf_start': ForwardRef('int', module='janus_core.helpers.janus_types'), 'rdf_step': ForwardRef('int', module='janus_core.helpers.janus_types'), 'rdf_stop': ForwardRef('int | None', module='janus_core.helpers.janus_types'), 'vaf_atoms': ForwardRef('Sequence[Sequence[int]]', module='janus_core.helpers.janus_types'), 'vaf_compute': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'vaf_fft': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'vaf_output_file': ForwardRef('PathLike | None', module='janus_core.helpers.janus_types'), 'vaf_start': ForwardRef('int', module='janus_core.helpers.janus_types'), 'vaf_step': ForwardRef('int', module='janus_core.helpers.janus_types'), 'vaf_stop': ForwardRef('int | None', module='janus_core.helpers.janus_types'), 'vaf_velocities': ForwardRef('bool', module='janus_core.helpers.janus_types')}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.janus_types', '__annotations__': {'rdf_compute': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'rdf_rmax': ForwardRef('float', module='janus_core.helpers.janus_types'), 'rdf_nbins': ForwardRef('int', module='janus_core.helpers.janus_types'), 'rdf_elements': ForwardRef('MaybeSequence[str | int]', module='janus_core.helpers.janus_types'), 'rdf_by_elements': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'rdf_start': ForwardRef('int', module='janus_core.helpers.janus_types'), 'rdf_stop': ForwardRef('int | None', module='janus_core.helpers.janus_types'), 'rdf_step': ForwardRef('int', module='janus_core.helpers.janus_types'), 'rdf_output_file': ForwardRef('str | None', module='janus_core.helpers.janus_types'), 'vaf_compute': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'vaf_velocities': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'vaf_fft': ForwardRef('bool', module='janus_core.helpers.janus_types'), 'vaf_atoms': ForwardRef('Sequence[Sequence[int]]', module='janus_core.helpers.janus_types'), 'vaf_start': ForwardRef('int', module='janus_core.helpers.janus_types'), 'vaf_stop': ForwardRef('int | None', module='janus_core.helpers.janus_types'), 'vaf_step': ForwardRef('int', module='janus_core.helpers.janus_types'), 'vaf_output_file': ForwardRef('PathLike | None', module='janus_core.helpers.janus_types')}, '__doc__': 'Main arguments for MD post-processing.', '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of 'PostProcessKwargs' objects>, '__weakref__': <attribute '__weakref__' of 'PostProcessKwargs' objects>, '__required_keys__': frozenset(), '__optional_keys__': frozenset({'rdf_by_elements', 'rdf_compute', 'vaf_output_file', 'vaf_fft', 'vaf_atoms', 'vaf_velocities', 'rdf_stop', 'vaf_stop', 'vaf_step', 'rdf_start', 'vaf_compute', 'vaf_start', 'rdf_rmax', 'rdf_output_file', 'rdf_nbins', 'rdf_elements', 'rdf_step'}), '__total__': False})
__module__ = 'janus_core.helpers.janus_types'
__optional_keys__ = frozenset({'rdf_by_elements', 'rdf_compute', 'rdf_elements', 'rdf_nbins', 'rdf_output_file', 'rdf_rmax', 'rdf_start', 'rdf_step', 'rdf_stop', 'vaf_atoms', 'vaf_compute', 'vaf_fft', 'vaf_output_file', 'vaf_start', 'vaf_step', 'vaf_stop', 'vaf_velocities'})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({})
__total__ = False
__weakref__

list of weak references to the object

rdf_by_elements: bool
rdf_compute: bool
rdf_elements: str | int | Sequence[str | int]
rdf_nbins: int
rdf_output_file: str | None
rdf_rmax: float
rdf_start: int
rdf_step: int
rdf_stop: int | None
vaf_atoms: Sequence[Sequence[int]]
vaf_compute: bool
vaf_fft: bool
vaf_output_file: str | Path | None
vaf_start: int
vaf_step: int
vaf_stop: int | None
vaf_velocities: bool

janus_core.helpers.log module

Configure logger with yaml-styled format.

class janus_core.helpers.log.YamlFormatter(*args, **kwargs)[source]

Bases: Formatter

Custom formatter to convert multiline messages into yaml list.

Parameters:
  • fmt – A format string in the given style for the logged output as a whole. Default is defined by FORMAT.

  • datefmt – A format string in the given style for the date/time portion of the logged output. Default is taken from logging.Formatter.formatTime().

  • style – Determines how the format string will be merged with its data. Can be one of ‘%’, ‘{’ or ‘$’. Default is ‘%’.

  • validate – If True, incorrect or mismatched fmt and style will raise a ValueError. Default is True.

  • defaults – A dictionary with default values to use in custom fields. Default is None.

  • *args – Arguments to pass to logging.Formatter.__init__.

  • **kwargs – Keyword arguments to pass to logging.Formatter.__init__.

FORMAT = '\n- timestamp: %(asctime)s\n  level: %(levelname)s\n  message: %(message)s\n  trace: %(module)s\n  line: %(lineno)d\n'
__init__(*args, **kwargs)[source]

Set default string format to yaml style.

Parameters:
  • *args – Arguments to pass to logging.Formatter.__init__.

  • **kwargs – Keyword arguments to pass to logging.Formatter.__init__.

__module__ = 'janus_core.helpers.log'
format(record)[source]

Format log message to convert new lines into a yaml list.

Parameters:

record (LogRecord) – Log record to be formatted.

Returns:

Formatted log message.

Return type:

str

janus_core.helpers.log.config_logger(name, filename=None, level=20, capture_warnings=True, filemode='w', force=True)[source]

Configure logger with yaml-styled format.

Parameters:
  • name (str) – Name of logger. Default is None.

  • filename (str | None) – Name of log file if writing logs. Default is None.

  • level (LogLevel) – Threshold for logger. Default is logging.INFO.

  • capture_warnings (bool) – Whether to capture warnings in log. Default is True.

  • filemode (Literal['r', 'w', 'a', 'x', 'r+', 'w+', 'a+', 'x+']) – Mode of file to open. Default is “w”.

  • force (bool) – If true, remove and close existing handlers attached to the root logger before configuration. Default is True.

Returns:

Configured logger if filename has been specified.

Return type:

logging.Logger | None

janus_core.helpers.log.config_tracker(janus_logger, track_carbon=True, *, country_iso_code='GBR', save_to_file=False, log_level='critical', **kwargs)[source]

Configure codecarbon tracker to log outputs.

Parameters:
  • janus_logger (Logger | None) – Logger for codecarbon output.

  • track_carbon (bool) – Whether to track carbon emissions for calculation. Default is True.

  • country_iso_code (str) – 3 letter ISO Code of the country where the code is running. Default is “GBR”.

  • save_to_file (bool) – Whether to also output results to a csv file. Default is False.

  • log_level (Literal['debug', 'info', 'warning', 'error', 'critical']) – Log level of internal carbon tracker log. Default is “critical”.

  • **kwargs – Additional keyword arguments to pass to OfflineEmissionsTracker.

Returns:

Configured offline codecarbon tracker, if logger is specified.

Return type:

OfflineEmissionsTracker | None

janus_core.helpers.mlip_calculators module

Configure MLIP calculators.

Similar in spirit to matcalc and quacc approaches - https://github.com/materialsvirtuallab/matcalc - https://github.com/Quantum-Accelerators/quacc.git

janus_core.helpers.mlip_calculators._set_model_path(model_path=None, kwargs=None)[source]

Set model_path.

Parameters:
  • model_path (str | Path | None) – Path to MLIP file.

  • kwargs (dict[str, Any] | None) – Dictionary of additional keyword arguments passed to the selected calculator.

Returns:

Path to MLIP model file, loaded model, or None.

Return type:

PathLike | torch.nn.Module | None

janus_core.helpers.mlip_calculators.check_calculator(calc, attribute)[source]

Ensure calculator has ability to calculate properties.

If the calculator is a SumCalculator that inlcudes the TorchDFTD3Calculator, this also sets the relevant function so that the MLIP component of the calculator is used for properties unrelated to dispersion.

Parameters:
  • calc (Calculator) – ASE Calculator to check.

  • attribute (str) – Attribute to check calculator for.

Return type:

None

janus_core.helpers.mlip_calculators.choose_calculator(arch='mace', device='cpu', model_path=None, **kwargs)[source]

Choose MLIP calculator to configure.

Parameters:
  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture. Default is “mace”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run calculator on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP file.

  • **kwargs – Additional keyword arguments passed to the selected calculator.

Returns:

Configured MLIP calculator.

Return type:

Calculator

Raises:

janus_core.helpers.utils module

Utility functions for janus_core.

class janus_core.helpers.utils.FileNameMixin(struct, struct_path, file_prefix, *additional)[source]

Bases: ABC

Provide mixin functions for standard filename handling.

Parameters:
  • struct (Atoms | Sequence[Atoms]) – Structure from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • file_prefix (str | Path | None) – Default prefix to use.

  • *additional – Components to add to default file_prefix (joined by hyphens).

__abstractmethods__ = frozenset({})
__annotations__ = {}
__dict__ = mappingproxy({'__module__': 'janus_core.helpers.utils', '__doc__': '\n    Provide mixin functions for standard filename handling.\n\n    Parameters\n    ----------\n    struct\n        Structure from which to derive the default name. If `struct` is a sequence,\n        the first structure will be used.\n    struct_path\n        Path to file containing structures.\n    file_prefix\n        Default prefix to use.\n    *additional\n        Components to add to default file_prefix (joined by hyphens).\n    ', '__init__': <function FileNameMixin.__init__>, '_get_default_prefix': <staticmethod(<function FileNameMixin._get_default_prefix>)>, '_build_filename': <function FileNameMixin._build_filename>, '__dict__': <attribute '__dict__' of 'FileNameMixin' objects>, '__weakref__': <attribute '__weakref__' of 'FileNameMixin' objects>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {}})
__init__(struct, struct_path, file_prefix, *additional)[source]

Provide mixin functions for standard filename handling.

Parameters:
  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file structures were read from. Used as default prefix is not None.

  • file_prefix (str | Path | None) – Default prefix to use.

  • *additional – Components to add to default file_prefix (joined by hyphens).

__module__ = 'janus_core.helpers.utils'
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
_build_filename(suffix, *additional, filename=None, prefix_override=None)[source]

Set filename using the file prefix and suffix if not specified otherwise.

Parameters:
  • suffix (str) – Default suffix to use if filename is not specified.

  • *additional – Extra components to add to suffix (joined with hyphens).

  • filename (str | Path | None) – Filename to use, if specified. Default is None.

  • prefix_override (str | None) – Replace file_prefix if not None.

Returns:

Filename specified, or default filename.

Return type:

Path

static _get_default_prefix(file_prefix, struct, struct_path, *additional)[source]

Determine the default prefix from the structure or provided file_prefix.

Parameters:
  • file_prefix (str | Path | None) – Given file_prefix.

  • struct (Atoms | Sequence[Atoms]) – Structure(s) from which to derive the default name. If struct is a sequence, the first structure will be used.

  • struct_path (str | Path | None) – Path to file containing structures.

  • *additional – Components to add to default file_prefix (joined by hyphens).

Returns:

File prefix.

Return type:

str

janus_core.helpers.utils._dump_ascii(file, header, columns, formats)[source]

Dump data as an ASCII style table.

Parameters:
  • file (TextIO) – File to dump to.

  • header (list[str]) – Column name information.

  • columns (dict[str, Sequence[Any]]) – Column data by key (ordered with header info).

  • formats (Sequence[str]) – Python magic string formats to apply (must align with header info).

Return type:

None

See also

write_table

Main entry function.

janus_core.helpers.utils._dump_csv(file, header, columns, formats)[source]

Dump data as a csv style table.

Parameters:
  • file (TextIO) – File to dump to.

  • header (list[str]) – Column name information.

  • columns (dict[str, Sequence[Any]]) – Column data by key (ordered with header info).

  • formats (Sequence[str]) – Python magic string formats to apply (must align with header info).

Return type:

None

See also

write_table

Main entry function.

janus_core.helpers.utils.check_files_exist(config, req_file_keys)[source]

Check files specified in a dictionary read from a configuration file exist.

Parameters:
  • config (dict) – Dictionary read from configuration file.

  • req_file_keys (Sequence[str | Path]) – Files that must exist if defined in the configuration file.

Raises:

FileNotFoundError – If a key from req_file_keys is in the configuration file, but the file corresponding to the configuration value do not exist.

Return type:

None

janus_core.helpers.utils.none_to_dict(*dictionaries)[source]

Ensure dictionaries that may be None are dictionaries.

Parameters:

*dictionaries (Sequence[dict | None]) – Sequence of dictionaries that could be None.

Yields:

dict – Input dictionaries or {} if empty or None.

Return type:

Generator[dict, None, None]

janus_core.helpers.utils.selector_len(slc, selectable_length)[source]

Calculate the length of a selector applied to an indexable of a given length.

Parameters:
Returns:

Length of the result of applying slc.

Return type:

int

janus_core.helpers.utils.set_log_tracker(attach_logger, log_kwargs, track_carbon)[source]

Set attach_logger and track_carbon default values.

Parameters:
  • attach_logger (bool) – Whether to attach a logger.

  • log_kwargs (dict) – Keyword arguments to pass to config_logger.

  • track_carbon (bool) – Whether to track carbon emissions of calculation.

Returns:

Default values for attach_logger and track_carbon.

Return type:

tuple[bool, bool]

janus_core.helpers.utils.slicelike_to_startstopstep(index)[source]

Standarize SliceLike`s into tuple of `start, stop, step.

Parameters:

index (slice | range | int | tuple[int | None, int | None, int]) – SliceLike to standardize.

Returns:

Standardized SliceLike as start, stop, step triplet.

Return type:

StartStopStep

janus_core.helpers.utils.track_progress(sequence, description)[source]

Track the progress of iterating over a sequence.

This is done by displaying a progress bar in the console using the rich library. The function is an iterator over the sequence, updating the progress bar each iteration.

Parameters:
  • sequence (Sequence | Iterable) – The sequence to iterate over. Must support “len”.

  • description (str) – The text to display to the left of the progress bar.

Yields:

Iterable – An iterable of the values in the sequence.

Return type:

Iterable

janus_core.helpers.utils.validate_slicelike(maybe_slicelike)[source]

Raise an exception if slc is not a valid SliceLike.

Parameters:

maybe_slicelike (slice | range | int | tuple[int | None, int | None, int]) – Candidate to test.

Raises:

ValueError – If maybe_slicelike is not SliceLike.

Return type:

None

janus_core.helpers.utils.write_table(fmt, file=None, units=None, formats=None, *, print_header=True, **columns)[source]

Dump a table in a standard format.

Table columns are passed as kwargs, with the column header being the keyword name and data the value.

Each header also supports an optional “<header>_units” or “<header>_format” kwarg to define units and format for the column. These can also be passed explicitly through the respective dictionaries where the key is the “header”.

Parameters:
  • fmt (Literal['ascii', 'csv']) – Format to write table in.

  • file (TextIO | None) – File to dump to. If unspecified function returns io.StringIO object simulating file.

  • units (dict[str, str] | None) –

    Units as {key: unit}:

    key

    To align with those in columns.

    unit

    String defining unit.

    Units which do not match any columns in columns are ignored.

  • formats (dict[str, str]) –

    Output formats as {key: format}:

    key

    To align with those in columns.

    format

    Python magic format string to use.

  • print_header (bool) – Whether to print the header or just append formatted data.

  • **columns (dict[str, Any]) –

    Dictionary of columns names to data with optional “<header>_units”/”<header>_format” to define units/format.

    See: Examples.

Returns:

If no file given write columns to StringIO.

Return type:

StringIO | None

Notes

Passing “kwarg_units” or “kwarg_format” takes priority over those passed in the units/formats dicts.

Examples

>>> data = write_table(fmt="ascii", single=(1, 2, 3),
...                    double=(2,4,6), double_units="THz")
>>> print(*data, sep="", end="")
# single | double [THz]
1 2
2 4
3 6
>>> data = write_table(fmt="csv", a=(3., 5.), b=(11., 12.),
...                    units={'a': 'eV', 'b': 'Ha'})
>>> print(*data, sep="", end="")
a [eV],b [Ha]
3.0,11.0
5.0,12.0
>>> data = write_table(fmt="csv", a=(3., 5.), b=(11., 12.),
...                    formats={"a": ".3f"})
>>> print(*data, sep="", end="")
a,b
3.000,11.0
5.000,12.0
>>> data = write_table(fmt="ascii", single=(1, 2, 3),
...                    double=(2,4,6), double_units="THz",
...                    print_header=False)
>>> print(*data, sep="", end="")
1 2
2 4
3 6

janus_core.helpers.stats

Module that reads the md stats output timeseries.

class janus_core.helpers.stats.Stats(source)[source]

Bases: object

Configure shared molecular dynamics simulation options.

Parameters:

source (str | Path) – File that contains the stats of a molecular dynamics simulation.

_(ind)[source]
Return type:

ndarray[Any, dtype[float64]]

__dict__ = mappingproxy({'__module__': 'janus_core.helpers.stats', '__doc__': '\n    Configure shared molecular dynamics simulation options.\n\n    Parameters\n    ----------\n    source\n        File that contains the stats of a molecular dynamics simulation.\n    ', '__init__': <function Stats.__init__>, '_getind': <functools.singledispatchmethod object>, '_': <function Stats._>, '__getitem__': <functools.singledispatchmethod object>, 'rows': <property object>, 'columns': <property object>, 'source': <property object>, 'labels': <property object>, 'units': <property object>, 'data': <property object>, 'data_tags': <property object>, 'read': <function Stats.read>, '__repr__': <function Stats.__repr__>, '__dict__': <attribute '__dict__' of 'Stats' objects>, '__weakref__': <attribute '__weakref__' of 'Stats' objects>, '__annotations__': {}})
__getitem__(ind)[source]

Get member of stats data by label or index.

Parameters:

ind – Index or label to find.

Returns:

Columns of data by label.

Return type:

NDArray[float64]

Raises:

IndexError – Invalid index type or label not found in labels.

__init__(source)[source]

Initialise MD stats reader.

Parameters:

source (str | Path) – File that contains the stats of a molecular dynamics simulation.

__module__ = 'janus_core.helpers.stats'
__repr__()[source]

Summary of timeseries contained, units, headers.

Returns:

Summary of the data.

Return type:

str

__weakref__

list of weak references to the object

_getind(lab)[source]

Convert an index label from str to int if present in labels.

Otherwise return the input.

Parameters:

lab (TypeVar(T)) – Label to find.

Returns:

Index of label in self or input if not string.

Return type:

int

Raises:

IndexError – Label not found in labels.

property columns: int

Return number of columns.

Returns:

Number of columns in data.

Return type:

int

property data: ndarray[Any, dtype[float64]]

Return the timeseries data.

Returns:

Data for timeseries in data.

Return type:

NDArray[float64]

property data_tags: Iterator[tuple[str, str]]

Return the labels and their units together.

Returns:

Zipped labels and units.

Return type:

Iterator[tuple[str, str]]

property labels: tuple[str, ...]

Return a list of labels for the columns in data.

Returns:

List of labels for the columns in data.

Return type:

tuple[str, …]

read()[source]

Read MD stats and store them in data.

Return type:

None

property rows: int

Return number of rows.

Returns:

Number of rows in data.

Return type:

int

property source: str | Path

Return filename which is the source of data.

Returns:

Filename for the source of data.

Return type:

PathLike

property units: tuple[str, ...]

Return a list of units for the columns in data.

Returns:

List of units for the columns in data.

Return type:

tuple[str, …]

janus_core.helpers.struct_io

Module for functions for input and output of structures.

janus_core.helpers.struct_io.attach_calculator(struct, *, arch='mace_mp', device='cpu', model_path=None, calc_kwargs=None)[source]

Configure calculator and attach to structure(s).

Parameters:
  • struct (Atoms | Sequence[Atoms]) – ASE Atoms structure(s) to attach calculators to.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

Return type:

None

janus_core.helpers.struct_io.input_structs(struct=None, *, struct_path=None, read_kwargs=None, sequence_allowed=True, arch='mace_mp', device='cpu', model_path=None, calc_kwargs=None, set_calc=None, logger=None)[source]

Read input structures and/or attach MLIP calculators.

Parameters:
  • struct (Atoms | Sequence[Atoms] | None) – ASE Atoms structure(s) to simulate. Required if struct_path is None. Default is None.

  • struct_path (str | Path | None) – Path of structure to simulate. Required if struct is None. Default is None.

  • read_kwargs (ASEReadArgs | None) – Keyword arguments to pass to ase.io.read. Default is {}.

  • sequence_allowed (bool) – Whether a sequence of Atoms objects is allowed. Default is True.

  • arch (Literal['mace', 'mace_mp', 'mace_off', 'm3gnet', 'chgnet', 'alignn', 'sevennet']) – MLIP architecture to use for calculations. Default is “mace_mp”.

  • device (Literal['cpu', 'cuda', 'mps', 'xpu']) – Device to run model on. Default is “cpu”.

  • model_path (str | Path | None) – Path to MLIP model. Default is None.

  • calc_kwargs (dict[str, Any] | None) – Keyword arguments to pass to the selected calculator. Default is {}.

  • set_calc (bool | None) – Whether to set (new) calculators for structures. Default is True if struct_path is specified or struct is missing calculators, else default is False.

  • logger (Logger | None) – Logger if log file has been specified. Default is None.

Returns:

Structure(s) with attached MLIP calculators.

Return type:

MaybeSequence[Atoms]

janus_core.helpers.struct_io.output_structs(images, *, struct_path=None, set_info=True, write_results=False, properties=(), invalidate_calc=False, write_kwargs=None)[source]

Copy or move calculated results to Atoms.info dict and/or write structures to file.

Parameters:
  • images (Atoms | Sequence[Atoms]) – Atoms object or a list of Atoms objects to interact with.

  • struct_path (str | Path | None) – Path of structure being simulated. If specified, the file stem is added to the info dict under “system_name”. Default is None.

  • set_info (bool) – True to set info dict from calculated results. Default is True.

  • write_results (bool) – True to write out structure with results of calculations. Default is False.

  • properties (Collection[Literal['energy', 'stress', 'forces', 'hessian']]) – Properties to copy from calculated results to info dict. Default is ().

  • invalidate_calc (bool) – Whether to remove all calculator results after copying properties to info dict. Default is False.

  • write_kwargs (ASEWriteArgs | None) – Keyword arguments passed to ase.io.write. Default is {}.

Return type:

None

janus_core.helpers.struct_io.results_to_info(struct, *, properties=(), invalidate_calc=False)[source]

Copy or move MLIP calculated results to Atoms.info dict.

Parameters:
  • struct (Atoms) – Atoms object to copy or move calculated results to info dict.

  • properties (Collection[Literal['energy', 'stress', 'forces', 'hessian']]) – Properties to copy from results to info dict. Default is ().

  • invalidate_calc (bool) – Whether to remove all calculator results after copying properties to info dict. Default is False.

Return type:

None

janus_core.processing.correlator module

Module to correlate scalar data on-the-fly.

class janus_core.processing.correlator.Correlation(*, a, b, name, blocks, points, averaging, update_frequency)[source]

Bases: object

Represents a user correlation, <ab>.

Parameters:
  • a (Observable) – Observable for a.

  • b (Observable) – Observable for b.

  • name (str) – Name of correlation.

  • blocks (int) – Number of correlation blocks.

  • points (int) – Number of points per block.

  • averaging (int) – Averaging window per block level.

  • update_frequency (int) – Frequency to update the correlation, md steps.

__dict__ = mappingproxy({'__module__': 'janus_core.processing.correlator', '__doc__': '\n    Represents a user correlation, <ab>.\n\n    Parameters\n    ----------\n    a\n        Observable for a.\n    b\n        Observable for b.\n    name\n        Name of correlation.\n    blocks\n        Number of correlation blocks.\n    points\n        Number of points per block.\n    averaging\n        Averaging window per block level.\n    update_frequency\n        Frequency to update the correlation, md steps.\n    ', '__init__': <function Correlation.__init__>, 'update_frequency': <property object>, 'update': <function Correlation.update>, 'get': <function Correlation.get>, '__str__': <function Correlation.__str__>, '__dict__': <attribute '__dict__' of 'Correlation' objects>, '__weakref__': <attribute '__weakref__' of 'Correlation' objects>, '__annotations__': {}})
__init__(*, a, b, name, blocks, points, averaging, update_frequency)[source]

Initialise a correlation.

Parameters:
  • a (Observable) – Observable for a.

  • b (Observable) – Observable for b.

  • name (str) – Name of correlation.

  • blocks (int) – Number of correlation blocks.

  • points (int) – Number of points per block.

  • averaging (int) – Averaging window per block level.

  • update_frequency (int) – Frequency to update the correlation, md steps.

__module__ = 'janus_core.processing.correlator'
__str__()[source]

Return string representation of correlation.

Returns:

String representation.

Return type:

str

__weakref__

list of weak references to the object

get()[source]

Get the correlation value and lags, averaging over atoms if applicable.

Return type:

tuple[Iterable[float], Iterable[float]]

Returns:

  • correlation (Iterable[float]) – The correlation values <a(t)b(t+t’)>.

  • lags (Iterable[float]]) – The correlation lag times t’.

update(atoms)[source]

Update a correlation.

Parameters:

atoms (Atoms) – Atoms object to observe values from.

Return type:

None

property update_frequency: int

Get update frequency.

Returns:

Correlation update frequency.

Return type:

int

class janus_core.processing.correlator.Correlator(*, blocks, points, averaging)[source]

Bases: object

Correlate scalar real values, <ab>.

Implements the algorithm detailed in https://doi.org/10.1063/1.3491098.

Data pairs are observed iteratively and stored in a set of rolling hierarchical data blocks.

Once a block is filled, coarse graining may be applied to update coarser block levels by updating the coarser block with the average of values accumulated up to that point in the filled block.

The correlation is continuously updated when any block is updated with new data.

Parameters:
  • blocks (int) – Number of correlation blocks.

  • points (int) – Number of points per block.

  • averaging (int) – Averaging window per block level.

_max_block_used

Which levels have been updated with data.

Type:

int

_min_dist

First point in coarse-grained block relevant for correlation updates.

Type:

int

_accumulator

Sum of data seen for calculating the average between blocks.

Type:

NDArray[float64]

_count_accumulated

Data points accumulated at this block.

Type:

NDArray[int]

_shift_index

Current position in each block’s data store.

Type:

NDArray[int]

_shift

Rolling data store for each block.

Type:

NDArray[float64]

_shift_not_null

If data is stored in this block’s rolling data store, at a given index.

Type:

NDArray[bool]

_correlation

Running correlation values.

Type:

NDArray[float64]

_count_correlated

Count of correlation updates for each block.

Type:

NDArray[int]

__dict__ = mappingproxy({'__module__': 'janus_core.processing.correlator', '__doc__': "\n    Correlate scalar real values, <ab>.\n\n    Implements the algorithm detailed in https://doi.org/10.1063/1.3491098.\n\n    Data pairs are observed iteratively and stored in a set of rolling hierarchical data\n    blocks.\n\n    Once a block is filled, coarse graining may be applied to update coarser block\n    levels by updating the coarser block with the average of values accumulated up to\n    that point in the filled block.\n\n    The correlation is continuously updated when any block is updated with new data.\n\n    Parameters\n    ----------\n    blocks\n        Number of correlation blocks.\n    points\n        Number of points per block.\n    averaging\n        Averaging window per block level.\n\n    Attributes\n    ----------\n    _max_block_used : int\n        Which levels have been updated with data.\n    _min_dist : int\n        First point in coarse-grained block relevant for correlation updates.\n    _accumulator : NDArray[float64]\n        Sum of data seen for calculating the average between blocks.\n    _count_accumulated : NDArray[int]\n        Data points accumulated at this block.\n    _shift_index : NDArray[int]\n        Current position in each block's data store.\n    _shift : NDArray[float64]\n        Rolling data store for each block.\n    _shift_not_null : NDArray[bool]\n        If data is stored in this block's rolling data store, at a given index.\n    _correlation : NDArray[float64]\n        Running correlation values.\n    _count_correlated : NDArray[int]\n        Count of correlation updates for each block.\n    ", '__init__': <function Correlator.__init__>, 'update': <function Correlator.update>, '_propagate': <function Correlator._propagate>, '_shifts_valid': <function Correlator._shifts_valid>, 'get_lags': <function Correlator.get_lags>, 'get_value': <function Correlator.get_value>, '__dict__': <attribute '__dict__' of 'Correlator' objects>, '__weakref__': <attribute '__weakref__' of 'Correlator' objects>, '__annotations__': {}})
__init__(*, blocks, points, averaging)[source]

Initialise an empty Correlator.

Parameters:
  • blocks (int) – Number of resolution levels.

  • points (int) – Data points at each resolution.

  • averaging (int) – Coarse-graining between resolution levels.

__module__ = 'janus_core.processing.correlator'
__weakref__

list of weak references to the object

_propagate(a, b, block)[source]

Propagate update down block hierarchy.

Parameters:
  • a (float) – Newly observed value of left correland/average.

  • b (float) – Newly observed value of right correland/average.

  • block (int) – Block in the hierachy being updated.

Return type:

None

_shifts_valid(block, p_i, p_j)[source]

Return True if the shift registers have data.

Parameters:
  • block (int) – Block to check the shift register of.

  • p_i (int) – Index i in the shift (left correland).

  • p_j (int) – Index j in the shift (right correland).

Returns:

Whether the shift indices have data.

Return type:

bool

get_lags()[source]

Obtain the correlation lag times.

Returns:

The correlation lag times.

Return type:

Iterable[float]

get_value()[source]

Obtain the correlation value.

Returns:

The correlation values <a(t)b(t+t’)>.

Return type:

Iterable[float]

update(a, b)[source]

Update the correlation, <ab>, with new values a and b.

Parameters:
  • a (float) – Newly observed value of left correland.

  • b (float) – Newly observed value of right correland.

Return type:

None

janus_core.processing.observables module

Module for built-in correlation observables.

class janus_core.processing.observables.ComponentMixin(components)[source]

Bases: object

Mixin to handle Observables with components.

Parameters:

components (dict[str, int]) – Symbolic components mapped to indices.

__dict__ = mappingproxy({'__module__': 'janus_core.processing.observables', '__doc__': '\n    Mixin to handle Observables with components.\n\n    Parameters\n    ----------\n    components\n        Symbolic components mapped to indices.\n    ', '__init__': <function ComponentMixin.__init__>, '_indices': <property object>, 'components': <property object>, '__dict__': <attribute '__dict__' of 'ComponentMixin' objects>, '__weakref__': <attribute '__weakref__' of 'ComponentMixin' objects>, '__annotations__': {}})
__init__(components)[source]

Initialise the mixin with components.

Parameters:

components (dict[str, int]) – Symbolic components mapped to indices.

__module__ = 'janus_core.processing.observables'
__weakref__

list of weak references to the object

property _indices: list[int]

Get indices associated with self.components.

Returns:

The indices for each self.components.

Return type:

list[int]

property components: list[str]

Get the symbolic components of the observable.

Returns:

The observables components.

Return type:

list[str]

class janus_core.processing.observables.Observable(atoms_slice=None)[source]

Bases: ABC

Observable data that may be correlated.

Parameters:

atoms_slice (list[int] | slice | range | int | tuple[int | None, int | None, int] | None) – A slice of atoms to observe.

__abstractmethods__ = frozenset({'__call__'})
__annotations__ = {}
abstract __call__(atoms)[source]

Signature for returning observed value from atoms.

Parameters:

atoms (Atoms) – Atoms object to extract values from.

Returns:

The observed value, with dimensions atoms by self.dimension.

Return type:

list[float]

__dict__ = mappingproxy({'__module__': 'janus_core.processing.observables', '__doc__': '\n    Observable data that may be correlated.\n\n    Parameters\n    ----------\n    atoms_slice\n        A slice of atoms to observe.\n    ', '__init__': <function Observable.__init__>, '__call__': <function Observable.__call__>, '__dict__': <attribute '__dict__' of 'Observable' objects>, '__weakref__': <attribute '__weakref__' of 'Observable' objects>, '__abstractmethods__': frozenset({'__call__'}), '_abc_impl': <_abc._abc_data object>, '__annotations__': {}})
__init__(atoms_slice=None)[source]

Initialise an observable with a given dimensionality.

Parameters:

atoms_slice (list[int] | slice | range | int | tuple[int | None, int | None, int] | None) – A slice of atoms to observe. By default all atoms are included.

__module__ = 'janus_core.processing.observables'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
class janus_core.processing.observables.Stress(*, components, atoms_slice=None, include_ideal_gas=True)[source]

Bases: Observable, ComponentMixin

Observable for stress components.

Parameters:
  • components (list[str]) – Symbols for correlated tensor components, xx, yy, etc.

  • atoms_slice (list[int] | slice | range | int | tuple[int | None, int | None, int] | None) – List or slice of atoms to observe velocities from.

  • include_ideal_gas (bool) – Calculate with the ideal gas contribution.

__abstractmethods__ = frozenset({})
__annotations__ = {}
__call__(atoms)[source]

Get the stress components.

Parameters:

atoms (Atoms) – Atoms object to extract values from.

Returns:

The stress components in GPa units.

Return type:

list[float]

Raises:

ValueError – If atoms is not an Atoms object.

__dict__ = mappingproxy({'__module__': 'janus_core.processing.observables', '__doc__': '\n    Observable for stress components.\n\n    Parameters\n    ----------\n    components\n        Symbols for correlated tensor components, xx, yy, etc.\n    atoms_slice\n        List or slice of atoms to observe velocities from.\n    include_ideal_gas\n        Calculate with the ideal gas contribution.\n    ', '__init__': <function Stress.__init__>, '__call__': <function Stress.__call__>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {}})
__init__(*, components, atoms_slice=None, include_ideal_gas=True)[source]

Initialise the observable from a symbolic str component.

Parameters:
  • components (list[str]) – Symbols for tensor components, xx, yy, etc.

  • atoms_slice (list[int] | slice | range | int | tuple[int | None, int | None, int] | None) – List or slice of atoms to observe velocities from.

  • include_ideal_gas (bool) – Calculate with the ideal gas contribution.

__module__ = 'janus_core.processing.observables'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
property _indices: list[int]

Get indices associated with self.components.

Returns:

The indices for each self.components.

Return type:

list[int]

property components: list[str]

Get the symbolic components of the observable.

Returns:

The observables components.

Return type:

list[str]

class janus_core.processing.observables.Velocity(*, components, atoms_slice=None)[source]

Bases: Observable, ComponentMixin

Observable for per atom velocity components.

Parameters:
__abstractmethods__ = frozenset({})
__annotations__ = {}
__call__(atoms)[source]

Get the velocity components for correlated atoms.

Parameters:

atoms (Atoms) – Atoms object to extract values from.

Returns:

The velocity values.

Return type:

list[float]

__dict__ = mappingproxy({'__module__': 'janus_core.processing.observables', '__doc__': '\n    Observable for per atom velocity components.\n\n    Parameters\n    ----------\n    components\n        Symbols for velocity components, x, y, z.\n    atoms_slice\n        List or slice of atoms to observe velocities from.\n    ', '__init__': <function Velocity.__init__>, '__call__': <function Velocity.__call__>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {}})
__init__(*, components, atoms_slice=None)[source]

Initialise the observable from a symbolic str component and atom index.

Parameters:
__module__ = 'janus_core.processing.observables'
__slots__ = ()
__weakref__

list of weak references to the object

_abc_impl = <_abc._abc_data object>
property _indices: list[int]

Get indices associated with self.components.

Returns:

The indices for each self.components.

Return type:

list[int]

property components: list[str]

Get the symbolic components of the observable.

Returns:

The observables components.

Return type:

list[str]

janus_core.processing.post_process module

Module for post-processing trajectories.

janus_core.processing.post_process.compute_rdf(data, ana=None, /, *, filenames=None, by_elements=False, rmax=2.5, nbins=50, elements=None, index=(0, None, 1), volume=None)[source]

Compute the rdf of data.

Parameters:
  • data (Atoms | Sequence[Atoms]) – Dataset to compute RDF of.

  • ana (Analysis | None) – ASE Analysis object for data reuse.

  • filenames (str | Path | Sequence[str | Path] | None) – Filenames to output data to. Must match number of RDFs computed.

  • by_elements (bool) – Split RDF into pairwise by elements group. Default is False. N.B. mixed RDFs (e.g. C-H) include all self-RDFs (e.g. C-C), to get the pure (C-H) RDF subtract the self-RDFs.

  • rmax (float) – Maximum distance of RDF.

  • nbins (int) – Number of bins to divide RDF.

  • elements (str | int | Sequence[str | int] | None) – Make partial RDFs. If by_elements is true will filter to only display pairs in list.

  • index (slice | range | int | tuple[int | None, int | None, int]) – Images to analyze as: index if int, start, stop, step if tuple, slice if slice or range.

  • volume (float | None) – Volume of cell for normalisation. Only needs to be provided if aperiodic cell. Default is (2*rmax)**3.

Returns:

If by_elements is true returns a dict of RDF by element pairs. Otherwise returns RDF of total system filtered by elements.

Return type:

NDArray[float64] | dict[tuple[str, str] | NDArray[float64]]

janus_core.processing.post_process.compute_vaf(data, filenames=None, *, use_velocities=False, fft=False, index=(0, None, 1), filter_atoms=(None,), time_step=1.0)[source]

Compute the velocity autocorrelation function (VAF) of data.

Parameters:
  • data (Sequence[Atoms]) – Dataset to compute VAF of.

  • filenames (str | Path | Sequence[str | Path] | None) – If present, dump resultant VAF to file.

  • use_velocities (bool) – Compute VAF using velocities rather than momenta. Default is False.

  • fft (bool) – Compute the fourier transformed VAF. Default is False.

  • index (slice | range | int | tuple[int | None, int | None, int]) – Images to analyze as start, stop, step. Default is all images.

  • filter_atoms (int | None | Sequence[int | None] | Sequence[int | None | Sequence[int | None]]) – Compute the VAF averaged over subsets of the system. Default is all atoms.

  • time_step (float) – Time step for scaling lags to align with input data. Default is 1 (i.e. no scaling).

Return type:

tuple[ndarray[Any, dtype[float64]], list[ndarray[Any, dtype[float64]]]]

Returns:

  • lags (numpy.ndarray) – Lags at which the VAFs have been computed.

  • vafs (list[numpy.ndarray]) – Computed VAF(s).

Notes

filter_atoms is given as a series of sequences of atoms, where each element in the series denotes a VAF subset to calculate and each sequence determines the atoms (by index) to be included in that VAF.

E.g.

Would compute separate VAFs for each species.

By default, one VAF will be computed for all atoms in the structure.

janus_core.processing.symmetry module

Module for functions operating on structure symmetry.

janus_core.processing.symmetry.snap_symmetry(struct, sym_tolerance=0.001)[source]

Symmetrize structure’s cell vectors and atomic positions.

Parameters:
  • struct (Atoms) – Structure as an ase Atoms object.

  • sym_tolerance (float) – Atom displacement tolerance for spglib symmetry determination, in Å. Default is 0.001.

Return type:

None

janus_core.processing.symmetry.spacegroup(struct, sym_tolerance=0.001, angle_tolerance=-1.0)[source]

Determine the spacegroup for a structure.

Parameters:
  • struct (Atoms) – Structure as an ase Atoms object.

  • sym_tolerance (float) – Atom displacement tolerance for spglib symmetry determination, in Å. Default is 0.001.

  • angle_tolerance (float) – Angle precision for spglib symmetry determination, in degrees. Default is -1.0, which means an internally optimized routine is used to judge symmetry.

Returns:

Spacegroup name.

Return type:

str

janus_core.training.preprocess module

Preprocess MLIP training data.

janus_core.training.preprocess.preprocess(mlip_config, req_file_keys=('train_file', 'test_file', 'valid_file'), attach_logger=False, log_kwargs=None, track_carbon=None, tracker_kwargs=None)[source]

Convert training data to hdf5 by passing a configuration file to the MLIP’s CLI.

Currently only supports MACE models, but this can be extended by replacing the argument parsing.

Parameters:
  • mlip_config (str | Path) – Configuration file to pass to MLIP.

  • req_file_keys (Sequence[str | Path]) – List of files that must exist if defined in the configuration file. Default is (“train_file”, “test_file”, “valid_file”).

  • attach_logger (bool) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

Return type:

None

janus_core.training.train module

Train MLIP.

janus_core.training.train.train(mlip_config, req_file_keys=('train_file', 'test_file', 'valid_file', 'statistics_file'), attach_logger=False, log_kwargs=None, track_carbon=None, tracker_kwargs=None)[source]

Run training for MLIP by passing a configuration file to the MLIP’s CLI.

Currently only supports MACE models, but this can be extended by replacing the argument parsing.

Parameters:
  • mlip_config (str | Path) – Configuration file to pass to MLIP.

  • req_file_keys (Sequence[str | Path]) – List of files that must exist if defined in the configuration file. Default is (“train_file”, “test_file”, “valid_file”, “statistics_file”).

  • attach_logger (bool) – Whether to attach a logger. Default is True if “filename” is passed in log_kwargs, else False.

  • log_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_logger. Default is {}.

  • track_carbon (bool | None) – Whether to track carbon emissions of calculation. Requires attach_logger. Default is True if attach_logger is True, else False.

  • tracker_kwargs (dict[str, Any] | None) – Keyword arguments to pass to config_tracker. Default is {}.

Return type:

None