htmd.adaptive.adaptive module#

class htmd.adaptive.adaptive.AdaptiveBase#

Bases: ABC, ProtocolInterface

Base class for adaptive sampling strategies.

Parameters:
  • app (SimQueue object, optional) – A SimQueue class object used to retrieve and submit simulations.

  • project (str, optional) – The name of the project.

  • nmin (int, optional) – Minimum number of running simulations.

  • nmax (int, optional) – Maximum number of running simulations.

  • nepochs (int, optional) – Stop adaptive once we have reached this number of epochs.

  • nframes (int, optional) – Stop adaptive once we have simulated this number of aggregate simulation frames.

  • inputpath (str, optional) – The directory used to store input folders.

  • generatorspath (str, optional) – The directory containing the generators.

  • dryrun (bool, optional) – A dry run means that the adaptive will retrieve and generate a new epoch but not submit the simulations.

  • updateperiod (float, optional) – When set to a value other than 0, the adaptive will run synchronously every updateperiod seconds.

  • coorname (str, optional) – Name of the file containing the starting coordinates for the new simulations.

  • boxname (str, optional) – Name of the file containing the starting box dimensions for the new simulations. Set to ‘none’ to disable box writing.

  • lock (bool, optional) – Lock the folder while adaptive is ongoing.

  • mps (int, optional) – If mps > 0, it will run simulations using the Multi-Process Service (MPS) with the number of processes specified. If set to 0, mps is disabled.

run()#

Run the adaptive sampling loop.

Starts the adaptive run, which iterates over epochs: retrieving completed simulations, running the selection algorithm, writing new inputs, and submitting them. When updateperiod is greater than 0 the loop repeats synchronously at that interval; otherwise it runs a single epoch and returns.

Examples

>>> adapt = AdaptiveMD()
>>> adapt.run()
htmd.adaptive.adaptive.epochSimIndexes(simlist)#

Find the simulation indexes for each epoch.

Creates a dictionary with the epoch number as key and values the simlist indexes of the simulations corresponding to the given epoch.

Parameters:

simlist (list) – A simulation list created using the simlist function.

Returns:

epochidx – A dictionary mapping epoch number (int) to a list of simlist indexes belonging to that epoch.

Return type:

dict

htmd.adaptive.adaptive.getEpochFromName(name)#

Return the epoch number for a given adaptive simulation name.

Parameters:

name (str) – Simulation name, e.g. the trajectory path produced by an adaptive run.

Returns:

epoch – The epoch number extracted from the simulation name.

Return type:

int

htmd.adaptive.adaptive.reconstructAdaptiveTraj(simlist, trajID)#

Reconstruct a long trajectory out of short adaptive simulation runs.

Walks back through the parent chain of an adaptive trajectory identified by trajID and concatenates all ancestor trajectory segments into a single continuous Molecule object.

Parameters:
  • simlist (ndarray) – A simulation list generated by the simlist function, containing Sim objects.

  • trajID (int) – The simulation ID of the trajectory from which to start the reconstruction.

Return type:

tuple

Returns:

  • mol (Molecule) – A Molecule object containing the full reconstructed trajectory.

  • chain (list) – Tuples of (sim, piece, frame) for all simulations involved in order.

  • pathlist (list) – Trajectory file paths for all simulations involved, in order.

Examples

>>> mol, chain, pathlist = reconstructAdaptiveTraj(data.simlist, 52)