# Molecular MC simulation is not equilibrating [closed]

Suppose, a polymer has N monomers in its chain. I want to simulate its movement using the bead-spring model.

So, I wrote the following program in Python.

I am using 0.1 million steps. The energy is not fluctuating as expected. After several steps, the curve goes totally flat.

The X-axis is steps. Y-axis is total energy.

Can anyone check the source code and tell me what I should change?

N.B. I am especially concerned with the function that calculates the total energy of the polymer.

• My last advice would be to write it in a friendlier language, or, more common language. Python/Matlab/Julia are the best for trying new things, and many people don't mind looking at codes written in these languages. C# is not that common for modelling. Last Last advice, make a polymer made of only two beads, calculate the energy for several snapshots by hand, and compare with the program. Apr 28, 2022 at 2:24
• Do your beads stop moving when it goes flat? If so, perhaps your random number generator breaks. print to screen the random number used in the metropolis criteria, as well as the math.exp(-(energy_new-energy_old)/T), see which one of those stops changing. Also print to screen the X and Y positions to see if they stop changing Apr 28, 2022 at 2:37
• If the beads stop moving, you need to figure out if it is because new positions aren't being generated correctly, or, new positions arent being accepted correctly. If positions aren't being generated correctly - probably random number generator issue. If moves aren't being accepted, it could be random number generator issue, or potential energy calculation issue, but since potential energy seems to work before, that would be odd. If your energies are dimensionless as they appear, and really are raised to the thousand, that may be an issue. that is a big number for a single molecule Apr 28, 2022 at 2:41
• Not sure what the best chat room for this would be. May 2, 2022 at 4:56
• Thanks for letting me know :) May 3, 2022 at 21:22