Simulation of a single chain

[1]:
import unittest
import math
import numpy as np
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 grow_file grow_chain5.txt
set_variable trials_per 1e4
Log trials_per_write trials_per output_file chain.txt
Movie trials_per_write trials_per output_file chain.xyz
CheckEnergy trials_per_update trials_per tolerance 1e-10
Tune
Run num_trials 1e3
Energy trials_per_write trials_per output_file chain_en.txt
RadiusOfGyration output_file 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.24.2-6-gf3cf33172b-dirty-hwh/whatnow
MonteCarlo
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: 1702503519
RemoveTrial name TrialAdd
TrialGrowFile grow_file grow_chain5.txt
Log output_file chain.txt trials_per_write 1e4
Movie output_file chain.xyz trials_per_write 1e4
CheckEnergy tolerance 1e-10 trials_per_update 1e4
Tune
Run num_trials 1e3
Energy output_file chain_en.txt trials_per_write 1e4
RadiusOfGyration output_file 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.9335, 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.002s

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

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