tfcompute

Note tfcompute is available as htf.tfcompute

Details

class htf.tensorflowcompute.tfcompute(model)

The main class for applying SimModel to Hoomd simulation.

__init__(model)

Initialize a tfcompute class instance

Parameters:model (SimModel) – HOOMD-TF model
attach(nlist=None, r_cut=0, period=1, batch_size=None, train=False, save_output_period=None)

Attaches the TensorFlow instance to Hoomd. This method sets up TensorFlow and gets Hoomd ready to interact with it.

Parameters:
  • nlist (Hoomd nlist) – The Hoomd neighbor list that will be used as the TensorFlow input.
  • r_cut (float) – Cutoff radius for neighbor listing.
  • period (int) – How many Hoomd steps should pass before updating the TensorFlow model.
  • batch_size (int) – The size of batches if we are using batching. Cannot be used if molecule-wise batching is active.
  • train (bool) – Indicate if train_on_batch Keras model method should be called at each step with the labels being Hoomd forces.
  • save_output_period (int) – How often to save output from model. Each output is accessible after as attributes outputs as numpy arrays with a new axis at 0, representing each call. Note that if your model outputs forces or forces and virial, then these will not be present.
enable_mapped_nlist(system, mapping_fxn)

Modifies existing snapshot to enable CG beads to be in simulation simultaneously with AA so that CG bead nlists can be accessed using hoomd’s accelerated nlist methods. This must be called in order to use SimModel.mapped_nlist() in a model.

Warning

Hoomd re-orders positions to improve performance. Calling this will disable sorting to keep a specific ordering of positions necessary for CG mapping.

Parameters:
  • system (hoomd system) – hoomd system
  • mapping_fxn (python callable) – a function whose signature is f(positions, box) where positions is an Nx4 array of fine-grained positions and box is a list containing Lx, Ly, and Lz of the simulation box, and whose return value is an Mx4 array of coarse-grained positions.
get_forces_array()

Retrieve forces array as numpy array

get_nlist_array()

Retrieve neighbor list array as numpy array

get_positions_array()

Retrieve positions array as numpy array

get_virial_array()

Retrieve virial array as numpy array

set_reference_forces(*forces)

Sets the Hoomd reference forces to be used by TensorFlow.

This allows you to choose which forces are used as the label for training.

Parameters:forces – Hoomd force objects