Slab, cylindrical, spherical and mixed confinement

[1]:
def shape(confinement):
    if confinement == "slab":
        shape = """Slab dimension=2 bound0=-1 bound1=1"""
    elif confinement == "cylinder":
        shape = """Cylinder radius=4 first_point=0,0,0 \
second_point=0,0,1"""
    elif confinement == "sphere":
        shape = """Sphere radius=4"""
    elif confinement == "union":
        shape = """Sphere radius=2.5
union Slab dimension=2 bound0=-1 bound1=1"""
    elif confinement == "network":
        shape = """Sphere radius=5
union Cylinder radius=2 first_point=0,0,0 second_point=1,0,0
union Cylinder radius=2 first_point=0,0,0 second_point=0,1,0
union Cylinder radius=2 first_point=0,0,0 second_point=0,0,1"""
    else:
        assert False # unrecognized
    with open(confinement+'.txt', 'w') as file: file.write(shape)

for confinement in ["slab", "cylinder", "sphere", "union", "network"]:
    shape(confinement)
    params={"confinement": confinement, "cubic_side_length": 8, "num_particles": 50}
    if confinement == 'network':
        params["cubic_side_length"]=20
        params["num_particles"]=500
    script="""
MonteCarlo
Configuration cubic_side_length={cubic_side_length} particle_type=fluid:/feasst/particle/lj_new.txt
Potential Model=LennardJones
Potential VisitModel=LongRangeCorrections
Potential Model=ModelHardShape shape_file={confinement}.txt
ThermoParams beta=1.5 chemical_potential=1
Metropolis
TrialTranslate tunable_param=2
TrialAdd particle_type=fluid
Run until_num_particles={num_particles}
Remove name=TrialAdd
Log trials_per_write=1e4 output_file={confinement}.log
Movie trials_per_write=1e4 output_file={confinement}.xyz
CheckEnergy trials_per_update=1e4
Tune
Run num_trials=1e5
""".format(**params)

    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)
# Usage: /home/user/feasst/build/bin/fst < file.txt
FEASST version 0.25.13
MonteCarlo
Configuration cubic_side_length=8 particle_type=fluid:/feasst/particle/lj_new.txt
Potential Model=LennardJones
Potential VisitModel=LongRangeCorrections
Potential Model=ModelHardShape shape_file=slab.txt
ThermoParams beta=1.5 chemical_potential=1
Metropolis
TrialTranslate tunable_param=2
TrialAdd particle_type=fluid
Run until_num_particles=50
# Initializing random number generator with seed: 1749480625
Remove name=TrialAdd
Log output_file=slab.log trials_per_write=1e4
Movie output_file=slab.xyz trials_per_write=1e4
CheckEnergy trials_per_update=1e4
Tune
Run num_trials=1e5

 exit: 0
# Usage: /home/user/feasst/build/bin/fst < file.txt
FEASST version 0.25.13
MonteCarlo
Configuration cubic_side_length=8 particle_type=fluid:/feasst/particle/lj_new.txt
Potential Model=LennardJones
Potential VisitModel=LongRangeCorrections
Potential Model=ModelHardShape shape_file=cylinder.txt
ThermoParams beta=1.5 chemical_potential=1
Metropolis
TrialTranslate tunable_param=2
TrialAdd particle_type=fluid
Run until_num_particles=50
# Initializing random number generator with seed: 1749480626
Remove name=TrialAdd
Log output_file=cylinder.log trials_per_write=1e4
Movie output_file=cylinder.xyz trials_per_write=1e4
CheckEnergy trials_per_update=1e4
Tune
Run num_trials=1e5

 exit: 0
# Usage: /home/user/feasst/build/bin/fst < file.txt
FEASST version 0.25.13
MonteCarlo
Configuration cubic_side_length=8 particle_type=fluid:/feasst/particle/lj_new.txt
Potential Model=LennardJones
Potential VisitModel=LongRangeCorrections
Potential Model=ModelHardShape shape_file=sphere.txt
ThermoParams beta=1.5 chemical_potential=1
Metropolis
TrialTranslate tunable_param=2
TrialAdd particle_type=fluid
Run until_num_particles=50
# Initializing random number generator with seed: 1749480626
Remove name=TrialAdd
Log output_file=sphere.log trials_per_write=1e4
Movie output_file=sphere.xyz trials_per_write=1e4
CheckEnergy trials_per_update=1e4
Tune
Run num_trials=1e5

 exit: 0
# Usage: /home/user/feasst/build/bin/fst < file.txt
FEASST version 0.25.13
MonteCarlo
Configuration cubic_side_length=8 particle_type=fluid:/feasst/particle/lj_new.txt
Potential Model=LennardJones
Potential VisitModel=LongRangeCorrections
Potential Model=ModelHardShape shape_file=union.txt
ThermoParams beta=1.5 chemical_potential=1
Metropolis
TrialTranslate tunable_param=2
TrialAdd particle_type=fluid
Run until_num_particles=50
# Initializing random number generator with seed: 1749480627
Remove name=TrialAdd
Log output_file=union.log trials_per_write=1e4
Movie output_file=union.xyz trials_per_write=1e4
CheckEnergy trials_per_update=1e4
Tune
Run num_trials=1e5

 exit: 0
# Usage: /home/user/feasst/build/bin/fst < file.txt
FEASST version 0.25.13
MonteCarlo
Configuration cubic_side_length=20 particle_type=fluid:/feasst/particle/lj_new.txt
Potential Model=LennardJones
Potential VisitModel=LongRangeCorrections
Potential Model=ModelHardShape shape_file=network.txt
ThermoParams beta=1.5 chemical_potential=1
Metropolis
TrialTranslate tunable_param=2
TrialAdd particle_type=fluid
Run until_num_particles=500
# Initializing random number generator with seed: 1749480627
Remove name=TrialAdd
Log output_file=network.log trials_per_write=1e4
Movie output_file=network.xyz trials_per_write=1e4
CheckEnergy trials_per_update=1e4
Tune
Run num_trials=1e5

 exit: 0

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