PolymerCpp package

Submodules

PolymerCpp.algorithms module

Tools to ensure the chain generation algorithms work as expected.

© All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, Laboratory of Experimental Biophysics, 2017 See the LICENSE.txt file for more details.

PolymerCpp.algorithms.verifyWLC(algorithm, numChains=10, numExperiments=1000, pathLength=1000, persisLength=50, **kwargs)

Compares outputs of a wormlike chain algorithm to theory.

This function performs two numerical experiments that verify the accuracy of the simulations. In the first, it performs a number numExperiments of experiments with numChains realizations in each experiment. The mean end-to-end distance and mean radius of gyration is computed for each group and a histogram of the results is displayed. The x-axis is the difference between the computed mean and the theoretical mean.

In the second experiment, a number of chains equal to numChains are simulated for a range of chain contour lengths. The mean end-to-end distance and mean radius of gyration for each group is then plotted vs. the contour length, along with the theoretical predications. The error bars denote the standard deviation of the group.

The mean value of all the end-to-end distances and radii of gyration are output to the console.

Parameters:
  • algorithm (func) – The algorithm for generating a wormlike chain.
  • numChains (int) – The number of chains per numerical experiment to generate.
  • numExperiments (int) – The number of experiments to perform for calculating the mean-squared moments.
  • pathLength (float) – The length of each chain in units of segments.
  • persisLength (float) – The persistence length of the wormlike chain in units of chain segments.
  • kwargs (dict) – A list of additional keyword arguments to pass to the algorithm function.

Notes

If a self-avoiding wormlike chain is provided as the argument to algorithm, the results will be compared to the theory for the infinitesimally thin wormlike chain.

PolymerCpp.helpers module

Python wrappers to the C++ wormlike chain generation code.

© All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, Laboratory of Experimental Biophysics, 2017 See the LICENSE.txt file for more details.

PolymerCpp.helpers.end_to_end_distance(chain)

Compute the end-to-end distance of a chain.

Parameters:chain (array_like) – A MxN array of numbers representing the Cartesian coordinates of the points in the set where M is the number of points and N is the number of dimensions.
Returns:R – The end-to-end distance of the chain.
Return type:float
PolymerCpp.helpers.getCppSAWLC(pathLength=1000.0, persisLength=1.0, linkDiameter=0.5)

Generate a trajectory of a self-avoiding wormlike chain.

Parameters:
  • pathLength (float) – The length of the chain in atomic units, e.g. atoms, molecules base pairs, or segments.
  • persisLength (float) – The persistence length of the chain in units of distance.
Returns:

rawChain – A Mx3 ordered array representing the chain’s trajectory, where M is the number of points. Each row represents the x-, y-, and z-coordinates of the points in the trajectory.

Return type:

array_like

Examples

Generate a single self-avoiding wormlike chain that is 100 units long, has a persistence length of 10, and a diameter that is 0.5 times the length of a single link.

>>> chain = getCppSAWLC(pathLength=100, persisLength=10, linkDiameter=0.5)
>>> print(chain.shape)
(101, 3)
PolymerCpp.helpers.getCppWLC(pathLength=1000.0, persisLength=1.0)

Generate the trajectory of an infinitesimal wormlike chain.

Parameters:
  • pathLength (float) – The length of the chain in atomic units, e.g. atoms, molecules, base pairs, or segments.
  • persisLength (float) – The persistence length of the chain in units of chain segments.
Returns:

rawChain – A Mx3 ordered array representing the chain’s trajectory, where M is the number of points. Each row represents the x-, y-, and z-coordinates of the points in the trajectory.

Return type:

array_like

Examples

Generate a single WLC that contains 100 points and has a persistence length of 10 line segments.

>>> chain = getCppWLC(pathLength=100, persisLength=10)
>>> print(chain.shape)
(101, 3)
PolymerCpp.helpers.getCppWLC2D(pathLength=1000, persisLength=1.0)

Create a infinitesimally-thin wormlike chain in two dimensions.

Parameters:
  • pathLength (int) – The length of the chain in atomic units, e.g. atoms, molecules, base pairs, or segments.
  • persisLength (float) – The persistence length of the chain in units of chain segments.
Returns:

rawChain

Return type:

array_like

Examples

Generates a single 2D WLC with 50 segments (51 vertices) and a persistence length of 10 segments.

>>> chain = getCppWLC2D(pathLength=50, persisLength=10)
>>> print(chain.shape)
(51, 2)
PolymerCpp.helpers.radius_of_gyration(chain)

Compute the radius of gyration of a chain.

This function computes the radius of gyration of a set of points. The points are defined as a NumPy array where each row corresponds to the Cartesian coordinate values and each column is one of the principle directions.

Parameters:chain (array_like) – A MxN array of numbers representing the Cartesian coordinates of the points in the set where M is the number of points and N is the number of dimensions.
Returns:Rg – The radius of gyration of the chain.
Return type:float
PolymerCpp.helpers.theory_R_WLC(contour_length, persistence_length, dim=3)

The mean squared end-to-end distance of the wormlike chain.

Note that this returns the square root fo the mean squared end-to- end distance.

Parameters:
  • contour_length (float) – The total contour length of the chain.
  • persistence_length (float) – The persistence length of the chain, which is related to the chain’s stiffness.
  • dim (int) – The dimension of the chain. This may be either 2 or 3.
Returns:

R – The square root of the mean squared end-to-end distance.

Return type:

float

PolymerCpp.helpers.theory_Rg_WLC(contour_length, persistence_length, dim=3)

The mean squared radius of gyration of the wormlike chain.

Note that this returns the square root of the mean squared radius of gyration.

Parameters:
  • contour_length (float) – The total contour length of the chain
  • persistence_length (float) – The persistence length of the chain, which is related to the chain’s stiffness.
  • dim (int) – The dimension of the chain. This may be either 2 or 3.
Returns:

Rg – The square root of the mean squared radius of gyration.

Return type:

float

Module contents