API

class potentials.PotClass(dim, pot_id, stiff_eps)

This class implements several potential functions and their 1st-order derivatives.

Parameters

pot_id (int) – index of the potential function.

V(x)

This function computes the corresponding potential for given x, depending on the value of pot_id.

grad_V(x)

This function computes the gradient of the corresponding potential for given x, depending on the value of pot_id.

Returns

1st-order derivatives (gradients) at each point of the input.

grad_modified_dw1d(xvec, a=1.0, b=1.0, c=0.7)

1st-order derivative of the 1d double-well potential.

grad_v_1d_dw(x)

Compute the gradient of v_1d_dw().

grad_v_1d_quadratic(x)

1st-order derivative of the 1d quadratic potential.

grad_v_2d_3well(x)

Compute the gradient of potential v_2d_3well().

grad_v_2d_curved(x)

Compute the gradient of v_2d_curved().

grad_v_2d_dw_quadratic(x)

Compute the gradient of v_2d_dw_quadratic().

grad_v_2d_quaratic(x)

Compute the gradient of v_2d_quadratic().

grad_v_nd_3well_in_x01(x)

Compute the gradient of v_nd_3well_in_x01().

modified_dw1d(xvec, a=1.0, b=1.0, c=0.7)

1d double-well potential, defined as

\[\begin{split}f(x) = \begin{cases} \frac{b\pi^2}{4a^2} (x+a)^2 - cx \,, & x \in (-\infty, -a)\,; \\ \frac{b}{2}(\cos(\frac{x}{a}\pi) + 1.0)- cx\,, & x \in [-a,a)\,; \\ \frac{b\pi^2}{4a^2} (x-a)^2- cx \,, & x \in [a,+\infty)\,. \end{cases}\end{split}\]
Parameters
  • xvec (1d numpy array) – points for which to compute potential.

  • a,b,c (positive, double) – parameters used in defining \(f(x)\).

Returns

potential values at each point of xvec, same length as xvec.

Return type

1d numpy array.

v_1d_dw(x)

1d double well potential. This function simply call modified_dw1d().

pot_id=2.

v_1d_quadratic(x)

1d quadratic potential \(f(x)=\frac{x^2}{2}.\)

pot_id=1.

v_2d_3well(x)

This is a 2d potential. It has three wells (low-potential regions) along radius.

pot_id=5.

v_2d_curved(x)

a 2d potential pot_id=6

v_2d_dw_quadratic(x)

2d potential, the sum of 1d double-well potential in \(x_1\) and 1d quadratic potential in \(x_2\).

pot_id=4.

v_2d_quadratic(x)

2d quadratic potential \(f(x) = 0.5 x_1^2 + 2.0 x_2^2\,, \mbox{for}~ x=(x_1,x_2) \in \mathbb{R}^2\,\).

pot_id=3.

v_nd_3well_in_x01(x)

This is a high-dimensional potential, a sum of v_2d_3well() in (x[0], x[1]) and quadratic in other dimensions.

pot_id=7.

class network_arch.MyNet(size_list, activation_name, d_out)

List of network_arch.MySequential neural networks. The ith entry is used to store the ith eigenfunction.

Parameters
  • size_list (list) – number of neurons for each layer. Each neural network has the same size_list.

  • activation_name (string) – name of the non-linear activation function.

  • d_out (int) – number of neural networks in the list.

feature_forward(xf)

Map the input feature xf to list of output tensors. For each neural network in the list, it simply calls network_arch.MySequential.feature_forward() function.

Parameters

xf (torch tensor) – input feature

forward(x)

Map the input data set x to list of output tensors. For each neural network in the list, it simply calls network_arch.MySequential.forward() function.

Parameters

x (data_set.data_set) – input data set

shift_and_normalize(mean_list, var_list)

For each neural networks in the list, substract and divide the function by the values specified in the mean_list and var_list. It simply calls the function network_arch.MySequential.shift_and_normalize().

Parameters
  • mean_list (list of double) – list of mean values.

  • var_list (list of positive double) – list of variances.

class network_arch.MySequential(size_list, activation_name)

This class implements a feedforward neural network.

Parameters
  • size_list (list) – number of neurons for each layer.

  • activation_name (string) – name of activation function. It should match one of the names of non-linear activations functions for PyTorch.

feature_forward(xf)

Map the feature to output tensor by the neural network.

Parameters

xf (torch tensor) – input feature.

forward(x)

Map the input data set to feature according to feature map, and then to output tensor by the neural network.

Parameters

x (data_set.data_set) – input data set

Returns

output tensor

Return type

torch tensor

shift_and_normalize(mean, var)

Substract the neural network function by mean and divide it by \(\sqrt{var}\). This is achieved by modifying parameters of the neural network.

class data_set.MD_data_set(xvec, weights)

This class is a child class of data_set, used for data of molecular system.

align()

Align all states in the data set with respect to the reference configuration.

This function implements the Kabash’s algorithm, which minimizes the the root mean squared deviation of states with respect to the reference configuration.

classmethod from_file(states_filename)

Initize the data set from file.

load_ref_state()

Load a reference configuration from the file ./data/ref_state.txt. It is used to align the data.

map_to_all_features()

Map the states in the mini-batch to all features, by calling map_to_feature() for each feature.

Returns

2d torch tensor, whose dimensions are (batch_size, num_features).

map_to_feature(idx)

Map the states in the mini-batch to one feature.

Parameters

idx – idx of the feature to which states are mapped.

pre_processing_layer()

If features are defined, then map data to features. Otherwise, return the aligned data.

write_all_features_file(feature_filename)

Map all states to features, and write the features to file.

Parameters

feature_filename – filename to output features.

class data_set.data_set(xvec, weights)

The class for data set.

Parameters
  • xvec (2d numpy array) – array containing trajectory data

  • weights (1d numpy array) – weights of trajectory data

Variables
  • batch_size – current batch-size

  • K – number of data

  • active_index – indices of active states. A state is included in mini-batch, if the entry is 1.

  • features – the tuple of features (the state is first transformed to features, before it is passed to neural networks).

  • num_features – number of features

  • batch_uniform_weight – when True (default), the data is included in mini-batch with equal probability.

dim_of_features()

Number of features.

classmethod from_file(states_filename)

Initialize the data_set from a data file.

generate_minibatch(batch_size, minibatch_flag=True)

Generate a mini-batch.

Parameters
  • batch_size (int) – size of mini-batch.

  • minibatch_flag (bool) – control whether generate mini-batch or entire data set.

pre_processing_layer()

Process data before it is sent to neural networks. This function returns the mini-batch itself (i.e., no features is used to transform data, in base class). It can be overrided in child class (i.e., mapping data to features).

set_features(features)

Set the features of the data set. :param features: list of features. :type features:

set_nonuniform_batch_weight()

By default, batch_uniform_weight is True and indices for mini-batch are selected with equal probability, unless this function is called, which set batch_uniform_weight to False, and indices for mini-batch will be selected randomly according to their weights.

weights_minibatch()

Return the array containing the weights of states in mini-batch. The array will be constant 1 if batch_uniform_weight is False.

class data_set.feature_tuple(features)

Class containing features.

Parameters

features (string) – user-defined features.

Currently supported types of features:

dihedral angle, angle, bond.

convert_atom_ix_by_file(ids_filename)

Convert indices in features according to the index file.

show_features()

Display information of features.