ipsuite.calculators package¶
Submodules¶
ipsuite.calculators.ase_geoopt module¶
- class ipsuite.calculators.ase_geoopt.ASEGeoOpt(*args, **kwargs)[source]¶
Bases:
IPSNodeGeometry optimization using ASE optimizers.
Parameters¶
- datalist[ase.Atoms]
Input atomic configurations to optimize.
- data_idint, default=-1
Index of the configuration to optimize from the data list.
- modelNodeWithCalculator
A model node that implements ‘get_calculator’ method.
- optimizerstr, default=”FIRE”
Name of the ASE optimizer to use (e.g., “FIRE”, “BFGS”, “LBFGS”).
- repeattuple[int, int, int], default=(1, 1, 1)
Repeat the unit cell in x, y, z directions.
- run_kwargsdict, default={“fmax”: 0.05}
Keyword arguments passed to the optimizer run method.
- init_kwargsdict, default={}
Keyword arguments passed to the optimizer initialization.
- maxstepint, optional
Maximum number of optimization steps to perform.
- sampling_rateint, default=1
How often to sample atomic configurations during optimization.
- dump_rateint, default=1000
How many configurations to cache before writing to file.
- checkslist, optional
List of check nodes for monitoring optimization progress.
- constraintslist, optional
List of constraint nodes to apply during optimization.
Attributes¶
- frameslist[ase.Atoms]
Optimized atomic configurations from the trajectory.
- traj_filePath
Path to the HDF5 trajectory file containing optimization steps.
Examples¶
>>> model = ips.MACEMPModel() >>> with project: ... data = ips.AddData(file="ethanol.xyz") ... geoopt = ips.ASEGeoOpt(data=data.frames, model=model, optimizer="FIRE") >>> project.repro() >>> print(f"Optimization completed with {len(geoopt.frames)} steps") Optimization completed with 74 steps
- checks: list = None¶
- constraints: list = None¶
- data: List[Atoms]¶
- data_id: int = -1¶
- dump_rate: int = 1000¶
- property frames: List[Atoms]¶
- init_kwargs: dict¶
- log_file: Path = PosixPath('$nwd$/opt.log')¶
- maxstep: int = None¶
- model: NodeWithCalculator¶
- model_outs: Path = PosixPath('$nwd$/model_outs')¶
- optimizer: str = 'FIRE'¶
- repeat: tuple[int, int, int] = (1, 1, 1)¶
- run_kwargs: dict¶
- sampling_rate: int = 1¶
- traj_file: Path = PosixPath('$nwd$/structures.h5')¶
ipsuite.calculators.ase_md module¶
ipsuite.calculators.ase_standard module¶
- class ipsuite.calculators.ase_standard.EMTCalculator(**kwargs)[source]¶
Bases:
EMT- calculate(atoms=None, properties=None, system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]¶
Do the calculation.
- properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute and create any missing directories.
- class ipsuite.calculators.ase_standard.EMTSinglePoint[source]¶
Bases:
objectThis is a testing Node! It uses ASE’S EMT calculator with default arguments. The calculator accept all elements and implements energy, forces, making it very useful for creating dummy data.
- class ipsuite.calculators.ase_standard.LJSinglePoint(epsilon: float = 1.0, sigma: float = 1.0, rc: float = 10.0)[source]¶
Bases:
objectThis is a testing Node! It uses ASE’S Lennard-Jones calculator with default arguments. The calculator accept all elements and implements energy, forces and stress, making it very useful for creating dummy data.
- epsilon: float = 1.0¶
- rc: float = 10.0¶
- sigma: float = 1.0¶
ipsuite.calculators.cp2k module¶
CP2K interface without ASE calculator.
This interface is less restrictive than CP2K Single Point.
- class ipsuite.calculators.cp2k.CP2KSinglePoint(*args, **kwargs)[source]¶
Bases:
IPSNodeNode for running CP2K Single point calculations.
Parameters¶
- cp2k_shellstr, default=None
The cmd to run cp2k. If None, the environment variable IPSUITE_CP2K_SHELL is used.
- cp2k_paramsstr
The path to the cp2k yaml input file. cp2k-input-tools is used to generate the input file from the yaml file.
- cp2k_fileslist[str]
Additional dependencies for the cp2k calculation.
- wfn_restart_filestr, optional
The path to the wfn restart file.
- wfn_restart_nodestr, optional
A cp2k Node that has a wfn restart file.
- cp2k_directory: Path = PosixPath('$nwd$/cp2k')¶
- cp2k_files: list[str] = None¶
- cp2k_params: str = 'cp2k.yaml'¶
- cp2k_shell: str | None = None¶
- data: list[Atoms]¶
- failed_configs: dict = NOT_AVAILABLE¶
- failure_policy: Literal['skip', 'fail'] = 'fail'¶
- property frames: list[Atoms]¶
- output_file: Path = PosixPath('$nwd$/structures.h5')¶
- wfn_restart_file: str = None¶
- wfn_restart_node: Node = None¶
ipsuite.calculators.lammps module¶
- class ipsuite.calculators.lammps.LammpsSimulator(*args, **kwargs)[source]¶
Bases:
ProcessSingleAtomCan perform LAMMPS Simulations.
Parameters¶
- lmp_exe: str
This is the name or path of the LAMMPS executable. Either path to executable, “lmp” or “lamp_<machine>”. See https://docs.lammps.org/Run_basics.html for more information
- lmp_params: str
Path to file. To be able to change parameters with DVC and not have to change them manually in the input script, a params file in yaml format and corresponding template file must be provided.
- lmp_template: str
Path to file. In combination with the params file this will be the input script for the LAMMPS simulation
- skiprun: bool, optional
Whether to skip running LAMMPS or not, by default False
Returns¶
- None
This function does not return anything. Instead, it creates a LAMMPS input script based on the specified template and parameter files, runs the LAMMPS simulation using the specified executable, and saves the simulation output to the specified directory.
- data: List[ase.Atoms]¶
- dump_file: Path = PosixPath('$nwd$/NPT.lammpstraj')¶
- property frames: list[Atoms]¶
- classmethod get_template(filename: str = 'lmp.jinja2', name='lammps_npt.jinja2') None[source]¶
Get the template file.
Parameters¶
- filename: str, optional
The name where to write the template to.
- name: str, optional
The name of the template, by default “lammps_npt.jinja2”
Returns¶
- lmp_directory: str = PosixPath('$nwd$/lammps')¶
- lmp_exe: str = 'lmp_serial'¶
- lmp_params: str¶
- lmp_template: str¶
- log_file: Path = PosixPath('$nwd$/NPT.log')¶
- skiprun: bool = False¶
ipsuite.calculators.orca module¶
- class ipsuite.calculators.orca.OrcaSinglePoint(*args, **kwargs)[source]¶
Bases:
IPSNodeNode for running ORCA Single point calculations.
Parameters¶
- orca_shellstr, default=None
The cmd to run orca. If None, the environment variable IPSUITE_ORCA_SHELL is used.
- data: list[Atoms]¶
- property frames: list[Atoms]¶
- orca_directory: Path = PosixPath('$nwd$/orca')¶
- orca_shell: str | None = None¶
- orcablocks: str = '%pal nprocs 16 end'¶
- orcasimpleinput: str = 'B3LYP def2-TZVP'¶
- output_file: str = PosixPath('$nwd$/structures.h5')¶
ipsuite.calculators.xtb module¶
- class ipsuite.calculators.xtb.xTBSinglePoint(*args, **kwargs)[source]¶
Bases:
ProcessAtomsNode for labeling date with xTB and obtaining ASE calculators.
Installation: conda install conda-forge::tblite-python
Attributes¶
- method: str
xTB method to be used. Only “GFN1-xTB” supports PBC.
- accuracy: float = 1.0¶
- charge: int = None¶
- data: list[ase.Atoms]¶
- electronic_temperature: float = 300.0¶
- initial_guess: str = 'sad'¶
- max_iterations: int = 250¶
- method: str = 'GFN1-xTB'¶
- mixer_damping: float = 0.4¶
- multiplicity: int = None¶
- spin_polarization: float = None¶
Module contents¶
Calculators can be used for labeling a given set of data and running molecular dynamics. For all cases, ASE calculators are used.
- class ipsuite.calculators.ASEGeoOpt(*args, **kwargs)[source]¶
Bases:
IPSNodeGeometry optimization using ASE optimizers.
Parameters¶
- datalist[ase.Atoms]
Input atomic configurations to optimize.
- data_idint, default=-1
Index of the configuration to optimize from the data list.
- modelNodeWithCalculator
A model node that implements ‘get_calculator’ method.
- optimizerstr, default=”FIRE”
Name of the ASE optimizer to use (e.g., “FIRE”, “BFGS”, “LBFGS”).
- repeattuple[int, int, int], default=(1, 1, 1)
Repeat the unit cell in x, y, z directions.
- run_kwargsdict, default={“fmax”: 0.05}
Keyword arguments passed to the optimizer run method.
- init_kwargsdict, default={}
Keyword arguments passed to the optimizer initialization.
- maxstepint, optional
Maximum number of optimization steps to perform.
- sampling_rateint, default=1
How often to sample atomic configurations during optimization.
- dump_rateint, default=1000
How many configurations to cache before writing to file.
- checkslist, optional
List of check nodes for monitoring optimization progress.
- constraintslist, optional
List of constraint nodes to apply during optimization.
Attributes¶
- frameslist[ase.Atoms]
Optimized atomic configurations from the trajectory.
- traj_filePath
Path to the HDF5 trajectory file containing optimization steps.
Examples¶
>>> model = ips.MACEMPModel() >>> with project: ... data = ips.AddData(file="ethanol.xyz") ... geoopt = ips.ASEGeoOpt(data=data.frames, model=model, optimizer="FIRE") >>> project.repro() >>> print(f"Optimization completed with {len(geoopt.frames)} steps") Optimization completed with 74 steps
- checks: list = None¶
- constraints: list = None¶
- data: List[Atoms]¶
- data_id: int = -1¶
- dump_rate: int = 1000¶
- property frames: List[Atoms]¶
- init_kwargs: dict¶
- log_file: Path = PosixPath('$nwd$/opt.log')¶
- maxstep: int = None¶
- model: NodeWithCalculator¶
- model_outs: Path = PosixPath('$nwd$/model_outs')¶
- optimizer: str = 'FIRE'¶
- repeat: tuple[int, int, int] = (1, 1, 1)¶
- run_kwargs: dict¶
- sampling_rate: int = 1¶
- traj_file: Path = PosixPath('$nwd$/structures.h5')¶
- class ipsuite.calculators.CP2KSinglePoint(*args, **kwargs)[source]¶
Bases:
IPSNodeNode for running CP2K Single point calculations.
Parameters¶
- cp2k_shellstr, default=None
The cmd to run cp2k. If None, the environment variable IPSUITE_CP2K_SHELL is used.
- cp2k_paramsstr
The path to the cp2k yaml input file. cp2k-input-tools is used to generate the input file from the yaml file.
- cp2k_fileslist[str]
Additional dependencies for the cp2k calculation.
- wfn_restart_filestr, optional
The path to the wfn restart file.
- wfn_restart_nodestr, optional
A cp2k Node that has a wfn restart file.
- cp2k_directory: Path = PosixPath('$nwd$/cp2k')¶
- cp2k_files: list[str] = None¶
- cp2k_params: str = 'cp2k.yaml'¶
- cp2k_shell: str | None = None¶
- data: list[Atoms]¶
- failed_configs: dict = NOT_AVAILABLE¶
- failure_policy: Literal['skip', 'fail'] = 'fail'¶
- property frames: list[Atoms]¶
- output_file: Path = PosixPath('$nwd$/structures.h5')¶
- wfn_restart_file: str = None¶
- wfn_restart_node: Node = None¶
- class ipsuite.calculators.EMTSinglePoint[source]¶
Bases:
objectThis is a testing Node! It uses ASE’S EMT calculator with default arguments. The calculator accept all elements and implements energy, forces, making it very useful for creating dummy data.
- class ipsuite.calculators.LJSinglePoint(epsilon: float = 1.0, sigma: float = 1.0, rc: float = 10.0)[source]¶
Bases:
objectThis is a testing Node! It uses ASE’S Lennard-Jones calculator with default arguments. The calculator accept all elements and implements energy, forces and stress, making it very useful for creating dummy data.
- epsilon: float = 1.0¶
- rc: float = 10.0¶
- sigma: float = 1.0¶
- class ipsuite.calculators.LammpsSimulator(*args, **kwargs)[source]¶
Bases:
ProcessSingleAtomCan perform LAMMPS Simulations.
Parameters¶
- lmp_exe: str
This is the name or path of the LAMMPS executable. Either path to executable, “lmp” or “lamp_<machine>”. See https://docs.lammps.org/Run_basics.html for more information
- lmp_params: str
Path to file. To be able to change parameters with DVC and not have to change them manually in the input script, a params file in yaml format and corresponding template file must be provided.
- lmp_template: str
Path to file. In combination with the params file this will be the input script for the LAMMPS simulation
- skiprun: bool, optional
Whether to skip running LAMMPS or not, by default False
Returns¶
- None
This function does not return anything. Instead, it creates a LAMMPS input script based on the specified template and parameter files, runs the LAMMPS simulation using the specified executable, and saves the simulation output to the specified directory.
- data: List[ase.Atoms]¶
- dump_file: Path = PosixPath('$nwd$/NPT.lammpstraj')¶
- property frames: list[Atoms]¶
- classmethod get_template(filename: str = 'lmp.jinja2', name='lammps_npt.jinja2') None[source]¶
Get the template file.
Parameters¶
- filename: str, optional
The name where to write the template to.
- name: str, optional
The name of the template, by default “lammps_npt.jinja2”
Returns¶
- lmp_directory: str = PosixPath('$nwd$/lammps')¶
- lmp_exe: str = 'lmp_serial'¶
- lmp_params: str¶
- lmp_template: str¶
- log_file: Path = PosixPath('$nwd$/NPT.log')¶
- skiprun: bool = False¶
- class ipsuite.calculators.MixCalculator(*args, **kwargs)[source]¶
Bases:
IPSNodeCombine multiple models or calculators into one.
- Attributes:
- calculators: list[NodeWithCalculator]
List of calculators to combine.
- method: str
choose from “mean” or “sum” to combine the calculators.
- calculators: list[NodeWithCalculator]¶
- get_calculator(**kwargs) Calculator[source]¶
Property to return a model specific ase calculator object.
Returns¶
- calc:
ase calculator object
- method: str = 'sum'¶
- class ipsuite.calculators.OrcaSinglePoint(*args, **kwargs)[source]¶
Bases:
IPSNodeNode for running ORCA Single point calculations.
Parameters¶
- orca_shellstr, default=None
The cmd to run orca. If None, the environment variable IPSUITE_ORCA_SHELL is used.
- data: list[Atoms]¶
- property frames: list[Atoms]¶
- orca_directory: Path = PosixPath('$nwd$/orca')¶
- orca_shell: str | None = None¶
- orcablocks: str = '%pal nprocs 16 end'¶
- orcasimpleinput: str = 'B3LYP def2-TZVP'¶
- output_file: str = PosixPath('$nwd$/structures.h5')¶
- class ipsuite.calculators.PlumedModel(*args, **kwargs)[source]¶
Bases:
IPSNodePlumed interface.
Parameters¶
- data: list[ase.Atoms]
List of ase atoms objects used to initialize the calculator.
- data_id: int
Index of the ase atoms object to use for initialization.
- model: NodeWithCalculator
The node that provides the calculator to compute unbiased energy and forces.
- config: str | Path
Path to the plumed input file.
- temperature: float
Temperature of the simulation in Kelvin.
- timestep: float
Timestep of the simulation in fs.
Example¶
An example config file for plumed can look like this:
hoh-c: DISTANCE ATOMS=48,3 c-r1: DISTANCE ATOMS=2,3 metad: METAD ARG=hoh-c,c-r1 PACE=100 HEIGHT=0.75 SIGMA=0.5,0.5 BIASFACTOR=10 TEMP=400 FILE=HILLS GRID_MIN=1.15,1.15 GRID_MAX=8.0,8.0 GRID_BIN=200,200 PRINT ARG=hoh-c,c-r1 STRIDE=10 FILE=COLVAR
References¶
[1] Plumed manual: https://www.plumed.org/doc-master/user-doc/html/index.html [2] Plumed : https://www.plumed.org/
- config: str | Path¶
- data: list[Atoms]¶
- data_id: int = -1¶
- model: NodeWithCalculator¶
- temperature: float¶
- timestep: float¶
- class ipsuite.calculators.xTBSinglePoint(*args, **kwargs)[source]¶
Bases:
ProcessAtomsNode for labeling date with xTB and obtaining ASE calculators.
Installation: conda install conda-forge::tblite-python
Attributes¶
- method: str
xTB method to be used. Only “GFN1-xTB” supports PBC.
- accuracy: float = 1.0¶
- charge: int = None¶
- data: list[ase.Atoms]¶
- electronic_temperature: float = 300.0¶
- initial_guess: str = 'sad'¶
- max_iterations: int = 250¶
- method: str = 'GFN1-xTB'¶
- mixer_damping: float = 0.4¶
- multiplicity: int = None¶
- spin_polarization: float = None¶