Simulation of a single chain

[1]:
import unittest
import math
import pandas as pd

script="""
MonteCarlo
Configuration cubic_side_length 40 periodic0 false periodic1 false periodic2 false \
    cutoff 20 particle_type0 /feasst/plugin/chain/particle/chain5.fstprt
Potential Model LennardJones VisitModel VisitModelIntra intra_cut 1
ThermoParams beta 1 chemical_potential0 1
Metropolis
TrialAdd particle_type 0
Run until_num_particles 1
RemoveTrial name TrialAdd
#TrialPivot weight 1 tunable_param 20
#TrialCrankshaft weight 1 tunable_param 20
TrialGrowFile file_name grow_chain5.txt
set_variable trials_per 1e4
Log trials_per_write trials_per file_name chain.txt
Movie trials_per_write trials_per file_name chain.xyz
CheckEnergy trials_per_update trials_per tolerance 1e-10
Tune
Run num_trials 1e3
Energy trials_per_write trials_per file_name chain_en.txt
RadiusOfGyration file_name rg.txt
Run num_trials 1e5
"""

with open('grow_chain5.txt', 'w') as file: file.write(
'TrialGrowFile\n\n\
particle_type 0 site 0 regrow true\n\
bond true mobile_site 1 anchor_site 0\n\
bond true mobile_site 2 anchor_site 1\n\
bond true mobile_site 3 anchor_site 2\n\
bond true mobile_site 4 anchor_site 3\n')

with open('script.txt', 'w') as file: file.write(script)
import subprocess
syscode = subprocess.call("../../../build/bin/fst < script.txt > script.log", shell=True, executable='/bin/bash')
with open('script.log', 'r') as file: print(file.read(), '\n', 'exit:', syscode)
# FEASST version: v0.21-21-g12898a9d3b-dirty-hwh/trial_library
Configuration cubic_side_length 40 cutoff 20 particle_type0 /home/hwh/feasst/plugin/chain/particle/chain5.fstprt periodic0 false periodic1 false periodic2 false
Potential Model LennardJones VisitModel VisitModelIntra intra_cut 1
ThermoParams beta 1 chemical_potential0 1
Metropolis
TrialAdd particle_type 0
Run until_num_particles 1
# initializing random number generator with seed: 1678982382
RemoveTrial name TrialAdd
TrialGrowFile file_name grow_chain5.txt
Log file_name chain.txt trials_per_write 1e4
Movie file_name chain.xyz trials_per_write 1e4
CheckEnergy tolerance 1e-10 trials_per_update 1e4
Tune
Run num_trials 1e3
Energy file_name chain_en.txt trials_per_write 1e4
RadiusOfGyration file_name rg.txt
Run num_trials 1e5

 exit: 0
[2]:
class TestChain5RG(unittest.TestCase):
    def test_rg_en(self):
        rg=pd.read_csv('rg.txt')
        self.assertAlmostEqual(0.8806, rg['average'][0], delta=3*(rg['block_stdev'][0]+0.))
        en=pd.read_csv('chain_en.txt')
        self.assertAlmostEqual(-2.050, en['average'][0], delta=3*(en['block_stdev'][0]+0.))
unittest.main(argv=[''], verbosity=2, exit=False)
test_rg_en (__main__.TestChain5RG) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.003s

OK
[2]:
<unittest.main.TestProgram at 0x7fb6a7d3fc10>

Did this tutorial work as expected? Did you find any inconsistencies or have any comments? Please contact us. Any feedback is appreciated!