rid.op package
Submodules
rid.op.adjust_trust_level module
- class rid.op.adjust_trust_level.AdjustTrustLevel(*args, **kwargs)[source]
Bases:
OPAdjustTrustLeve OP adjust trust level according to the number of cluster (numb_cluster) and the number of cluster threshold (numb_cluster_threshold). If numb_cluster < numb_cluster_threshold, the trust level will be increased. Trust levels won’t increase infinitly. When current trust_lvl_1 > max_level_multiple * init_trust_lvl_1, where init_trust_lvl_1 is the initial trust level, trust_lvl_1 will be tuned to its initial value.
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) –
Input dict with components:
trust_lvl_1: (float) Trust level 1 in the current iteration, or e0.
trust_lvl_2: (float) Trust level 2 in the current iteration, or e1.
init_trust_lvl_1: (float) Initial value of trust level 1.
init_trust_lvl_1: (float) Initial value of trust level 2.
numb_cluster: (int) Number of clusters got from cluster op.
- numb_cluster_threshold: (int) Threshold for cluster number to adjust trust level adaptively.
if numb_cluster > numb_cluster_threshold, trust_lvl will be increased.
adjust_amplifier: (float) Increasing multiple for trust level.
max_level_multiple: (float) The max multiple than trust level can be increased.
- Returns
Output dict with components
- `adjust_trust_lvl_1` ((float) Adjusted Trust level 1 for next iteration.)
- `adjust_trust_lvl_2` ((float) Adjusted Trust level 2 for next iteration.)
rid.op.label_stats module
- class rid.op.label_stats.LabelStats(*args, **kwargs)[source]
Bases:
OPLabelStats OP calculate the std of all the labeling steps, remove the ones with high std.
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) –
Input dict with components:
”cv_forces”: (Artifact(List[Path]))
”mf_info”: (Artifact(List[Path]))
”std_threshold”: (Float)
- Returns
Output dict with components
- “mf_std_fig” ((Artifact(Path)))
- “cv_forces” ((Artifact(List[Path])))
rid.op.mcmc_plot module
- class rid.op.mcmc_plot.MCMCPlot(*args, **kwargs)[source]
Bases:
OPMCMC_Plot plot the reduced free energy surface produced by MCMC run.
rid.op.mcmc_run module
rid.op.prep_data module
- class rid.op.prep_data.CollectData(*args, **kwargs)[source]
Bases:
OPGather data of different simulations to a single file.
rid.op.prep_exploration module
- class rid.op.prep_exploration.PrepExplore(*args, **kwargs)[source]
Bases:
OPPrepare files for exploration tasks. Currently, RiD is based on Gromacs/Lammps with PLUMED2 plugin. Provide .gro files and .top files if running Gromacs and .lmp files if running Lammps. Exploration step would run biased MD sampling with neural network models or brute force MD sampling without neural network model provided.
With models provided, the bias forces will be the average value of outputs of these models and tuned by a switching function. .. math:
F(r) = -\nabla_{r_i} U(r) + \sigma( \me ( s( r))) \nabla_{r_i} A(r)
where \(F(r)\) is forces exrted on atoms, \(U(r)\) is potential energy and \(A(r)\) is free energy represented by neural networks. .. math:
\sigma(\epsilon)= \begin{cases} 1, & \epsilon<\epsilon_0 \\ \frac{1}{2}+\frac{1}{2}\cos{(\pi \frac{\epsilon-\epsilon_0}{\epsilon_1-\epsilon_0})}, & \epsilon_0 <\epsilon < \epsilon_1 \\ 0, &\epsilon > \epsilon_1 \end{cases}
where \(\sigma(\epsilon)\) is the switching function with parameters trust level (trust_lvl_1 and trust_lvl_2).
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) –
Input dict with components:
- models: (Artifact(List[Path])) Optional. Neural network model files (.pb) used to bias the simulation.
Run brute force MD simulations if not provided.
trust_lvl_1: (float) Trust level 1.
trust_lvl_2: (float) Trust level 2.
topology: (Artifact(Path)) Topology files (.top) for Gromacs simulations.
conf: (Artifact(Path)) Conformation files (.gro, .lmp) for Gromacs/Lammps simulations.
exploration_config: (Dict) Configuration in Dict format for Gromacs/Lammps run.
cv_config: (Dict) Configuration for CV creation.
task_name: (str) Task name used to make sub-dir for tasks.
- Returns
Output dict with components
- `task_path` ((Artifact(Path)) A directory containing files for RiD exploration.)
- `cv_dim` ((int) CV dimensions.)
rid.op.prep_label module
- class rid.op.prep_label.CheckLabelInputs(*args, **kwargs)[source]
Bases:
OPCheck Inputs of Label Steps.
If inputs conf are empty or None, if_continue will be False, and the following ops of Label steps won’t be executed.
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) – Input dict with components: - confs: (Artifact(List[Path])) Conformations selected from trajectories of exploration steps.
- Returns
Output dict with components
- `if_continue` ((bool) Whether to execute following ops of Label steps.)
- class rid.op.prep_label.PrepLabel(*args, **kwargs)[source]
Bases:
OPPrepare files for Label steps.
Labels of RiD are mean forces, which are calculated by restrained MD algorithm. Restrained MD simulations are performed by Gromacs/Lammps with PLUMED2 plugin, so input files are in Gromacs/Lammps format.
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) –
Input dict with components:
topology: (Artifact(Path)) Topology files (.top) for Restrained MD simulations.
conf: (Artifact(Path)) Conformation files (.gro, .lmp) for Restrained MD simulations.
label_config: (Dict) Configuration in Dict format for Gromacs/Lammps run.
cv_config: (Dict) Configuration for CV creation.
at: (Artifact(Path)) Files containing initial CV values, or CV centers.
task_name: (str) Task name used to make sub-dir for tasks.
- Returns
Output dict with components
- `task_path` ((Artifact(Path)) A directory containing files for Restrained MD.)
rid.op.prep_rid module
- class rid.op.prep_rid.PrepRiD(*args, **kwargs)[source]
Bases:
OPPre-processing of RiD.
Parse RiD configuration JSON file, get default value if parameters are not provided.
Rearrange conformation files.
Make task names and formats.
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) –
Input dict with components:
confs: (Artifact(Path)) User-provided initial conformation files (.gro) for reinfoced dynamics.
- rid_config: (Artifact(Path)) Configuration file (.json) of RiD.
Parameters in this file will be parsed.
- Returns
Output dict with components
- `numb_iters` ((int) Max number of iterations for Ri.)
- `numb_walkers` ((int) Number of parallel walkers for exploration.)
- `numb_models` ((int) Number of neural network models of RiD.)
- `confs` ((Artifact(List[Path])) Rearranged initial conformation files (.gro) for reinfoced dynamics.)
- `walker_tags` ((List) Tag formmat for parallel walkers.)
- `model_tags` ((List) Tag formmat for neural network models.)
- `exploration_config` ((Dict) Configuration of simulations in exploration steps.)
- `cv_config` ((Dict) Configuration to create CV in PLUMED2 style.)
- `trust_lvl_1` ((List[float]) Trust level 1, or e0.)
- `trust_lvl_2` ((List[float]) Trust level 2, or e1.)
- `cluster_threshold` ((List[float]) Initial guess of cluster threshold.)
- `angular_mask` ((List) Angular mask for periodic collective variables.) – 1 represents periodic, 0 represents non-periodic.
- `weights` ((List) Weights for clustering collective variables. see details in cluster algorithms.)
- `numb_cluster_upper` ((int) Upper limit of cluster number to make cluster threshold.)
- `numb_cluster_lower` ((int) Lower limit of cluster number to make cluster threshold.)
- `max_selection` ((int) Max selection number of clusters in Selection steps for each parallel walker.)
- `numb_cluster_threshold` ((int) Used to adjust trust level. When cluster number is grater than this threshold,) – trust levels will be increased adaptively.
- `dt` ((float) Time interval of exploration MD simulations. Gromacs trjconv commands will need this parameters) – to slice trajectories by -dump tag, see selection steps for detail.
- `slice_mode` ((str) Mode to slice trajectories. Either gmx or mdtraj.)
- `label_config` ((Dict) Configuration of simulations in labeling steps.)
- `kappas` ((List) Force constants of harmonic restraints to perform restrained MD simulations.)
- `train_config` ((Dict) Configuration to train neural networks, including training strategy and network structures.)
rid.op.prep_select module
- class rid.op.prep_select.PrepSelect(*args, **kwargs)[source]
Bases:
OPPrepSelect OP clusters CV outputs of each parallel walker from exploration steps and prepares representative frames of each clusters for further selection steps. RiD-kit employs agglomerative clustering algorithm performed by Scikit-Learn python package. The distance matrix of CVs is pre-calculated, which is defined by Euclidean distance in CV space. For each cluster, one representive frame will be randomly chosen from cluster members. For periodic collective variables, RiD-kit uses angular_mask to identify them and handle their periodic conditions during distance calculation. In the first run of RiD iterations, PrepSelect will make a cluster threshold automatically from the initial guess of this value and make cluter numbers of each parallel walker fall into the interval of [numb_cluster_lower, numb_cluster_upper].
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) –
Input dict with components:
task_name: (str) Task names, used to make sub-directory for tasks.
plm_out: (Artifact(Path)) Outputs of CV values (plumed.out by default) from exploration steps.
cluster_threshold: (float) Cluster threshold of agglomerative clustering algorithm
angular_mask: (array_like) Mask for periodic collective variables. 1 represents periodic, 0 represents non-periodic.
weights: (array_like) Weights to cluster collective variables. see details in cluster parts.
numb_cluster_upper: (Optional[float]) Upper limit of cluster number to make cluster threshold.
numb_cluster_lower: (Optional[float]) Lower limit of cluster number to make cluster threshold.
- max_selection: (int) Max selection number of clusters in Selection steps for each parallel walker.
For each cluster, one representive frame will be randomly chosen from cluster members.
- if_make_threshold: (bool) whether to make threshold to fit the cluster number interval. Usually True in the 1st
iteration and False in the further iterations.
- Returns
Output dict with components
- `numb_cluster` ((int) Number of clusters.)
- `cluster_threshold` ((float) Cluster threshold of agglomerative clustering algorithm.)
- `cluster_selection_index` ((Artifact(Path)) Indice of chosen representive frames of clusters in trajectories.)
- `cluster_selection_data` ((Artifact(Path)) Collective variable values of chosen representive frames of clusters.)
rid.op.recorder module
- class rid.op.recorder.Recorder(*args, **kwargs)[source]
Bases:
OPRecord iteration index of RiD and make names for block (or iterations).
- execute(op_in: OPIO) OPIO[source]
Execute the OP.
- Parameters
op_in (dict) –
Input dict with components:
iteration: (int) Last iteration index. iteration is None means not any iteration performed before.
- Returns
Output dict with components
- `next_iteration` ((int) Next iteration index.)
- `block_tag` ((str) Names for block. See rid.superop.blocks)