Make your own custom analysis
In this example, a user can follow the instructions in /feasst/plugin/example/include/analyze_example.h to make their own custom analysis. In some cases, it is preferable to implement the analysis within FEASST rather than analyze stored configurations in order to limit the number of configurations that need to be saved to disk.
In this relatively trivial example, the geometric center of all (PBC wrapped) sites is computed for an ideal gas fluid. The PBCs are centered on the origin, so the result should be the origin, within statistical error.
[1]:
import sys
import subprocess
import numpy as np
import pandas as pd
def run_fst():
with open("launch2.txt", "w") as myfile: myfile.write("""
MonteCarlo
Configuration particle_type0 /feasst/particle/atom.fstprt cubic_side_length 8 add_particles_of_type0 100
Potential Model IdealGas
ThermoParams beta 1
Metropolis trials_per_cycle 1e2
TrialTranslate tunable_param 4,
AnalyzeExample trials_per_write 1e3 output_file ig_center.csv start_after_cycle 1
Run num_trials 1e5
""")
syscode = subprocess.call("../../../build/bin/fst < launch2.txt", shell=True, executable='/bin/bash')
if syscode > 0: sys.exit(1)
Run the test and check the energy.
[2]:
run_fst()
df = pd.read_csv('ig_center.csv')
df['center_is_origin'] = abs(df['average']) < 3*df['block_stdev']
assert df['center_is_origin'].all()
# Usage: ./fst < file.txt
FEASST version 0.25.6
MonteCarlo
Configuration add_particles_of_type0 100 cubic_side_length 8 particle_type0 /home/user/feasst/particle/atom.fstprt
Potential Model IdealGas
ThermoParams beta 1
Metropolis trials_per_cycle 1e2
TrialTranslate tunable_param 4,
AnalyzeExample output_file ig_center.csv start_after_cycle 1 trials_per_write 1e3
Run num_trials 1e5
# initializing random number generator with seed: 1734454564
Did this tutorial work as expected? Did you find any inconsistencies or have any comments? Please contact us. Any feedback is appreciated!