Second virial coefficient calculation of a Trimer using Mayer-Sampling
Here, we reproduce the virial coefficient of a trimer at the Boyle temperature as reported Table 1 of the following manuscript for \(L=0.4\sigma\)
https://dx.doi.org/10.1063/1.4918557
[1]:
params={"beta": 1./0.815, "rwca": 2.**(1./6.)}
script="""
MonteCarlo
Configuration cubic_side_length 1e100 particle_type0 /feasst/particle/trimer_0.4L.fstprt \
add_particles_of_type0 2 cutoff0_1 {rwca} cutoff1_1 {rwca} \
group0 first first_particle_index 0
Potential Model LennardJonesForceShift
RefPotential Model HardSphere sigma0 1 sigma1 0
ThermoParams beta {beta}
MayerSampling
TrialTranslate new_only true reference_index 0 tunable_param 1 group first
TrialRotate new_only true reference_index 0 tunable_param 40
set_variable trials_per 1e4
CriteriaWriter trials_per_write trials_per output_file b2.txt
Log trials_per_write trials_per output_file tmp/trib.txt
Movie trials_per_write trials_per output_file tmp/trib.xyz
Run num_trials 1e6
""".format(**params)
with open('script1.txt', 'w') as file: file.write(script)
import subprocess
syscode = subprocess.call("../../../build/bin/fst < script1.txt > script1.log", shell=True, executable='/bin/bash')
with open('script1.log', 'r') as file: print(file.read(), '\n', 'exit:', syscode)
# FEASST version: v0.19.0-104-gc3a7e003a2-dirty-user/newtutorials
Configuration add_particles_of_type0 2 cubic_side_length 1e100 cutoff0_1 1.122462048309373 cutoff1_1 1.122462048309373 first_particle_index 0 group0 first particle_type0 /home/user/feasst/particle/trimer_0.4L.fstprt
Potential Model LennardJonesForceShift
RefPotential Model HardSphere sigma0 1 sigma1 0
ThermoParams beta 1.2269938650306749
MayerSampling
TrialTranslate group first new_only true reference_index 0 tunable_param 1
TrialRotate new_only true reference_index 0 tunable_param 40
CriteriaWriter output_file b2.txt trials_per 1e4
Log output_file tmp/trib.txt trials_per 1e4
Movie output_file tmp/trib.xyz trials_per 1e4
Run num_trials 1e6
# initializing random number generator with seed: 1653572226
exit: 0
[2]:
import math
import unittest
class TestMayerSamplingTrimer(unittest.TestCase):
def test(self):
with open("b2.txt") as f:
firstline = f.readline().rstrip()
#print(firstline)
b2=eval(firstline)
#b2={"second_virial_ratio": -0.0166853, "second_virial_ratio_block_stdev": 0.0159632}
print(b2)
# print(mayer.mayer().str())
self.assertAlmostEqual(0, b2['second_virial_ratio'], delta=4*b2['second_virial_ratio_block_stdev'])
unittest.main(argv=[''], verbosity=2, exit=False)
test (__main__.TestMayerSamplingTrimer) ...
{'second_virial_ratio': -0.0067179, 'second_virial_ratio_block_stdev': 0.0132613}
ok
----------------------------------------------------------------------
Ran 1 test in 0.001s
OK
[2]:
<unittest.main.TestProgram at 0x7f0df8193eb0>
Did this tutorial work as expected? Did you find any inconsistencies or have any comments? Please contact us. Any feedback is appreciated!