thermo
#
Train against thermodynamic properties.
Classes:
-
DataEntry–Represents a single experimental data point.
-
SimulationKey–A key used to identify a simulation.
-
SimulationConfig–Configuration for a simulation to run.
Functions:
-
create_dataset–Create a dataset from a list of existing data points.
-
create_from_evaluator–Create a dataset from an evaluator PhysicalPropertyDataSet
-
extract_smiles–Return a list of unique SMILES strings in the dataset.
-
default_config–Return a default simulation configuration for the specified phase.
-
select_config–A helper method to choose the simulation config based on the phase
-
predict–Predict the properties in a dataset using molecular simulation, or by reweighting
-
default_closure–Return a default closure function for training against thermodynamic
DataEntry
#
Bases: TypedDict
Represents a single experimental data point.
Attributes:
-
type(DataType) –The type of data point.
-
smiles_a(str) –The SMILES definition of the first component.
-
x_a(float | None) –The mole fraction of the first component. This must be set to 1.0 if the data
-
smiles_b(str | None) –The SMILES definition of the second component if present.
-
x_b(float | None) –The mole fraction of the second component if present.
-
temperature(float) –The temperature at which the data point was measured.
-
pressure(float) –The pressure at which the data point was measured.
-
value(float) –The value of the data point.
-
std(float | None) –The standard deviation of the data point if available.
-
units(str) –The units of the data point.
-
source(str) –The source of the data point.
SimulationKey
#
Bases: NamedTuple
A key used to identify a simulation.
Attributes:
-
smiles(tuple[str, ...]) –The SMILES definitions of the components present in the system.
-
counts(tuple[int, ...]) –The number of copies of each component present in the system.
-
temperature(float) –The temperature [K] at which the simulation was run.
-
pressure(float | None) –The pressure [atm] at which the simulation was run.
smiles
instance-attribute
#
The SMILES definitions of the components present in the system.
counts
instance-attribute
#
The number of copies of each component present in the system.
temperature
instance-attribute
#
The temperature [K] at which the simulation was run.
pressure
instance-attribute
#
The pressure [atm] at which the simulation was run.
SimulationConfig
pydantic-model
#
Bases: BaseModel
Configuration for a simulation to run.
Fields:
-
max_mols(int) -
gen_coords(GenerateCoordsConfig) -
apply_hmr(bool) -
equilibrate(list[MinimizationConfig | SimulationConfig]) -
production(SimulationConfig) -
production_frequency(int)
gen_coords
pydantic-field
#
Configuration for generating initial coordinates.
equilibrate
pydantic-field
#
Configuration for equilibration simulations.
production
pydantic-field
#
Configuration for the production simulation.
production_frequency
pydantic-field
#
The frequency at which to write frames during production.
create_dataset
#
create_dataset(*rows: DataEntry) -> Dataset
Create a dataset from a list of existing data points.
Parameters:
-
rows(DataEntry, default:()) –The data points to create the dataset from.
Returns:
-
Dataset–The created dataset.
Source code in descent/targets/thermo.py
create_from_evaluator
#
Create a dataset from an evaluator PhysicalPropertyDataSet
Parameters:
-
dataset_file(Path) –The path to the evaluator dataset
Returns:
-
Dataset–The created dataset
Source code in descent/targets/thermo.py
extract_smiles
#
Return a list of unique SMILES strings in the dataset.
Parameters:
-
dataset(Dataset) –The dataset to extract the SMILES strings from.
Returns:
-
list[str]–The unique SMILES strings with full atom mapping.
Source code in descent/targets/thermo.py
default_config
#
default_config(
phase: Phase, temperature: float, pressure: float | None
) -> SimulationConfig
Return a default simulation configuration for the specified phase.
Parameters:
-
phase(Phase) –The phase to return the default configuration for.
-
temperature(float) –The temperature [K] at which to run the simulation.
-
pressure(float | None) –The pressure [atm] at which to run the simulation.
Returns:
-
SimulationConfig–The default simulation configuration.
Source code in descent/targets/thermo.py
select_config
#
select_config(
phase: Phase,
temperature: float,
pressure: float | None,
custom_config: (
dict[str, SimulationConfig] | None
) = None,
) -> SimulationConfig
A helper method to choose the simulation config based on the phase with the desired temperature and pressure. If a custom configuration is not available the default will be used.
Parameters:
-
phase(Phase) –The phase of the simulation.
-
temperature(float) –The temperature [K] at which to run the simulation.
-
pressure(float | None) –The pressure [atm] at which to run the simulation
-
custom_config(dict[str, SimulationConfig] | None, default:None) –The custom simulation configuration for each phase.
Returns:
-
SimulationConfig–The simulation configuration for the given phase.
Source code in descent/targets/thermo.py
predict
#
predict(
dataset: Dataset,
force_field: TensorForceField,
topologies: dict[str, TensorTopology],
output_dir: Path,
cached_dir: Path | None = None,
per_type_scales: dict[DataType, float] | None = None,
verbose: bool = False,
simulation_config: (
dict[str, SimulationConfig] | None
) = None,
) -> tuple[Tensor, Tensor, Tensor, Tensor]
Predict the properties in a dataset using molecular simulation, or by reweighting previous simulation data.
Parameters:
-
dataset(Dataset) –The dataset to predict the properties of.
-
force_field(TensorForceField) –The force field to use.
-
topologies(dict[str, TensorTopology]) –The topologies of the molecules present in the dataset, with keys of mapped SMILES patterns.
-
output_dir(Path) –The directory to write the simulation trajectories to.
-
cached_dir(Path | None, default:None) –The (optional) directory to read cached simulation trajectories from.
-
per_type_scales(dict[DataType, float] | None, default:None) –The scale factor to apply to each data type. A default of 1.0 will be used for any data type not specified.
-
verbose(bool, default:False) –Whether to log additional information.
-
simulation_config(dict[str, SimulationConfig] | None, default:None) –The (optional) simulation configuration, should contain a config for each phase if not provided the default will be used.
Source code in descent/targets/thermo.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | |
default_closure
#
default_closure(
trainable: Trainable,
topologies: dict[str, TensorTopology],
dataset: Dataset,
per_type_scales: dict[DataType, float] | None = None,
verbose: bool = False,
simulation_config: (
dict[str, SimulationConfig] | None
) = None,
) -> ClosureFn
Return a default closure function for training against thermodynamic properties.
Parameters:
-
trainable(Trainable) –The wrapper around trainable parameters.
-
topologies(dict[str, TensorTopology]) –The topologies of the molecules present in the dataset, with keys of mapped SMILES patterns.
-
dataset(Dataset) –The dataset to train against.
-
per_type_scales(dict[DataType, float] | None, default:None) –The scale factor to apply to each data type.
-
verbose(bool, default:False) –Whether to log additional information about predictions.
-
simulation_config(dict[str, SimulationConfig] | None, default:None) –The (optional) simulation configuration, should contain a config for each phase if not provided the default will be used.
Returns:
-
ClosureFn–The default closure function.