%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import plotly.graph_objects as go 

Conformations of Random Polymer Chains#

End-to-End Distance

  • Generate polymer chains consisting of 100 monomers in 2D, where each monomer has a fixed length \(a\) and can point in any direction with equal probability. Use the uniform random number \(\theta \sim U(0,1)\) generated by np.random.rand() to compute angles between \([0, 2\pi]\). This will allow you to determine the coordinates of monomers using \(x = l\cdot \cos(\theta)\) and \(y = l\cdot \sin(\theta)\).

  • After generating all monomer positions, visualize several polymer conformations to verify that you have correctly created polymer chains in 2D.

  • Compute the probability distribution of the end-to-end distances of the polymer. It’s essential to assess how many conformations are necessary to generate a distribution that aligns with theoretical expectations. Calculate the probability distribution of the radius of gyration for a polymer with \(N\) monomers, given by \(R^2_g = \frac{1}{N}\sum (r_k-\langle r \rangle)^2\), where \(r_k\) denotes the positions of monomers, and \(\langle r \rangle\) is the average position of the monomers.

  • Investigate how the average root mean square end-to-end distance and the radius of gyration vary with the number of monomers.

Entropy

  • Given any probability distribution, one can calculate entropy via \(S = -\sum p_i \log(p_i)\).

  • Calculate the entropy of the polymer chain using the end-to-end probability distribution.

  • Simulate a chain where monomers are twice as likely to align along the x-axis, and calculate the entropy again.

This assignment will help you understand the statistical mechanics of polymer chains by exploring their conformations, distributions, and entropy. Ensure your simulations are accurate and reflect the theoretical models closely.

def gen_conf(n_mon=100, n_conf=10000):
    '''This function should generate 2D conformations of random polymer and store the result in conf
    conf: array of size (n_mon, n_conf, 2)'''
    
    # TODO: generate first monomer at origin so we can use the coordinate of the last bead for end-to-end distance calculations
    
    return conf
def ee_dist(conf):
    '''This function calculates end to end distance'''
    
    return ee_dists
def entropy(prob_end_to_end):
    '''Calculate entropy of polymer conformational ensemble from end to end distance'''

In the class we are going to generalize this to 3D polymer chains#