RSoftTools module

RSoftTools Created on 8 November 2018 @author: Robert Ivancic

This module was created to facilitate easy creation of softness fields based on current methodologies.

Notes

class RSoftTools.MDTools[source]

Bases: object

Molecular Dynamics Tools for python

This class is designed to provide some standard molecular dynamics tools to analyze trajectories.

DeltaR(rf, ri, bb, bc)[source]

Difference between two vectors or sets of vectors

Calculates the difference between two positions rf and ri (rf-ri) with respect to the box boundaries (bb) and the boundary conditions (bc). The numpy arrays rf and ri can either be single particle positions or sets of particle positions. Let d = dimension of the space and N = number of vectors.

Parameters:
  • rf (numpy array, either (d) or (N, d)) – Final positions of particle(s) in d-dimensional space.
  • ri (numpy array, either (d) or (N, d)) – Initial positions of particle(s) in d-dimensional space.
  • bb (numpy array, (d, 2)) – Box boundaries of simulation or the experiment. For d=2, this should be formatted [[low_x, high_x],[low_y, high_y]]. In d=3, [[low_x, high_x],[low_y, high_y],[low_z, high_z]].
  • bc (numpy str array, (d)) – Boundary conditions of the experiment or simulation. Each value must be a single character string denoting the boundary condition in each direction. ‘p’ means periodic boundary conditions. ‘s’ means shrink wrapped bounday conditions. ‘f’ means fixed boundary conditions.
Returns:

dr – The rf-ri given the box boundaries and boundary conditions.

Return type:

numpy array, either (d) or (N, d)

GetNList(pos_t, bb_t, bc, R_c)[source]

Obtains a neighbor list for a set of particles

Finds all of the neighbors within a cuttoff distance (R_c) for a set of particles (pos_t) given a set of box boundaries (bb_t), and a set of boundary conditions.

Parameters:
  • pos_t (numpy array, (n_p, d)) – Set of n_p particle positions in d-dimensional space
  • bb_t (numpy array, (d, 2)) – Box boundaries of simulation or the experiment. For d=2, this should be formatted [[low_x, high_x],[low_y, high_y]]. In d=3, [[low_x, high_x],[low_y, high_y],[low_z, high_z]].
  • bc (numpy str array, (d)) – Boundary conditions of the experiment or simulation. Each value must be a single character string denoting the boundary condition in each direction. ‘p’ means periodic boundary conditions. ‘s’ means shrink wrapped bounday conditions. ‘f’ means fixed boundary conditions.
  • R_c (float) – Cutoff radius of the simulation.
Returns:

n_list – Python list in which n_list[i] is a numpy array of all neighbors of particle i from pos_t.

Return type:

python array, (n_p)

class RSoftTools.RSoft[source]

Bases: object

RSoft package for python.

This class is made to deal with and generate RSoftSF and RSoftPlane files.

etol_radial

epsilon_R

Radial error tolerance (if available). Can obtain after OpenSFI.

Type:float
mus

Mu structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy array (n_SF_rad)
radial_Xs

Radial_X structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy int array (n_SF_rad)
radial_Ys

Radial_Y structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy int array (n_SF_rad)
etol_angular

Angular error tolerance (if available). Can obtain after OpenSFI.

Type:float
xis

Xi structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy array (n_SF_ang)
lambdas

Lambda structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy int array (n_SF_ang)
zetas

Zeta structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy int array (n_SF_ang)
angular_Xs

Angular_X structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy int array (n_SF_ang)
angular_Ys

Angular_Y structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy int array (n_SF_ang)
angular_Zs

Angular_Z structure function parameters (if available). Can obtain after OpenSFI used.

Type:numpy int array (n_SF_ang)
training_R

Python list containing a numpy array containing the frame and particle id (respectively) for each rearranging training example for each type of particle. Can obtain after SelectTrainingSet is used.

Type:list (n_type) of numpy int array (n_eg_type, 2)
training_NR

Python list containing a numpy array containing the frame and particle id (respectively) for each non-rearranging training example for each type of particle. Can obtain after SelectTrainingSet is used.

Type:list (n_type) of numpy int array (n_eg_type, 2)
CloseDynamicsI()[source]

CLoses input of AMBER NetCDF dynamics file

ClosePlaneO()[source]

Closes output of RSoftPlane file

CloseSFI()[source]

Closes input of RSoftSF file

CloseSFO()[source]

Closes output of RSoftSF

GetAngular(f)[source]

Gets angular structure functions

Gets angular structure functions for frame f.

Parameters:f (int) – Frame number to obtain angular structure functions
GetRadial(f)[source]

Gets radial structure functions

Gets radial structure functions for frame f.

Parameters:f (int) – Frame number to obtain radial structure functions
OpenDynamicsI(nc_file_name, dynamics_name)[source]

Opens dynamic file in AMBER (netCDF) file format

Opens an AMBER molecular dynamics file. This file must have a data column named dynamics_name. This data column should contain p_hop or D^2_min data to classify rearrangements or non-rearrangements in the system.

Parameters:
  • nc_file_name (str) – Name of AMBER file you wish to read from.
  • dynamics_name (str) – Name of dynamics data column
OpenPlaneO(nc_file_name)[source]

Opens RSoftPlane file

Opens a RSoftPlane file of nc_file_name for writing (output).

Parameters:nc_file_name (str) – Name of RSoftPlane file you wish to write to.
OpenSFI(nc_file_name)[source]

Opens RSoftSF file

Opens a RSoftSF file of nc_file_name for reading (input).

Parameters:nc_file_name (str) – Name of RSoftSF file you wish to read from.
OpenSFO(nc_file_name)[source]

Opens RSoftSF file

Opens a RSoftSF file of nc_file_name for writing (output).

Parameters:nc_file_name (str) – Name of RSoftSF file you wish to write to.
SelectTrainingSet(rearrangement_cutoff, non_rearrangement_frames=None, non_rearrangement_cutoff=None, str_mask=None)[source]

Selects training set

Selects the training set from the dynamic AMBER file.

Parameters:
  • rearrangement_cutoff (numpy array (n_types)) – Numpy array with a rearrangement cutoff for the dynamical quantity in data column of AMBER dynamical file.
  • non_rearrangement_frames (numpy int array (n_types), optional) – Numpy array of frames for a particle not to rearrange before being counted as part of non-rearranging training set for each particle type. If not set, assumes 0 frames for each particle type, i.e. instantaneously less than non_rearrangement_cutoff.
  • non_rearrangement_cutoff (numpy array (n_types), optional) – Numpy array with a non-rearrangement cutoff for the dynamical quantity in data column of AMBER dynamical file. If not set, uses the rearrangement_cutoff.
  • str_mask (str, optional) – Name of the data column of AMBER dynamic file corresponding to a mask of 0’s and 1’s in which 1’s are particles that may be included in training set and 0’s cannot.
SetAngular(f, SF)[source]

Sets angular structure functions

Sets angular structure functions for frame f.

Parameters:f (int) – Frame number to set angular structure functions
SetRadial(f, SF)[source]

Sets radial structure functions

Sets radial structure functions for frame f.

Parameters:f (int) – Frame number to set radial structure functions
Train(n_eg=None, K=5, C_parameters=array([1.e-02, 1.e-01, 1.e+00, 1.e+01, 1.e+02]), norm_SF=True, norm_plane=True, tol_=0.0001, max_iter_=10000)[source]

Trains a softness hyperplane

Trains a softness hyperplane for all species given an RSoftSF file and an AMBER molecular dynamics file containing dynamics_name data column.

Parameters:
  • n_eg (numpy int array (n_types), optional) – Numpy array with number of rearranging training examples to include for each type. If not set, assumes this to be maximum number which meets all other criteria
  • K (int, optional) – Positive integer of folds for K-folds cross-validation to chooose optimal penalty parameter. K = 5 is used by default.
  • C_parameters (numpy array, optional) – Numpy array of penalty parameters to test during cross-validation. Values 0.01, 0.1, 1, 10, and 100 are default values to check.
  • norm_SF (boolean, optional) – Whether to normalize structure functions before running linear SVM. This typically leads to better fits. If true, we subtract the mean and divide by the STDev of all structure functions. If not set, default is True.
  • norm_plane (boolean, optional) – Ensures the standard deviation of softness is 1. If not set, default is true.
WritePlane()[source]

Writes plane to RSoftPlane file