def nvtw(num_particles, num_procs, num_equil, num_prod, num_hours, dccb_begin, temperature, mu, steps_per, model): mc = fst.MakeMonteCarlo() #mc.set(fst.MakeRandomMT19937(fst.args({"seed": "1633373856"}))) beta = 1./temperature if model == "lj": mc.add(fst.MakeConfiguration(fst.args({"cubic_box_length": "8", "particle_type0": fst.install_dir() + "/forcefield/lj.fstprt"}))) mc.add(fst.MakePotential(fst.MakeLennardJones())) mc.add(fst.MakePotential(fst.MakeLongRangeCorrections())) elif model == "sqw": config = fst.MakeConfiguration(fst.args({"cubic_box_length": "8", "particle_type0": fst.install_dir() + "/forcefield/atom.fstprt"})) config.set_model_param("cutoff", 0, 1.5) mc.add(config) mc.add(fst.MakePotential(fst.MakeSquareWell())) elif model == "spce": mc.add(fst.MakeConfiguration(fst.args({"cubic_box_length": "20", "particle_type0": fst.install_dir() + "/forcefield/spce.fstprt"}))) mc.add(fst.MakePotential(fst.MakeEwald(fst.args({"alpha": str(5.6/20), "kmax_squared": "38"})))) mc.add(fst.MakePotential(fst.MakeModelTwoBodyFactory(fst.MakeLennardJones(), fst.MakeChargeScreened()), fst.args({"table_size": "1e6"}))) mc.add(fst.MakePotential(fst.MakeChargeScreenedIntra(), fst.MakeVisitModelBond())) mc.add(fst.MakePotential(fst.MakeChargeSelf())) mc.add(fst.MakePotential(fst.MakeLongRangeCorrections())) beta = 1./fst.kelvin2kJpermol(temperature, mc.configuration()) else: assert(False) # model not recognized # fill box with larger temperature and mu mc.set(fst.MakeThermoParams(fst.args({"beta": "0.01", "chemical_potential": "10"}))) mc.set(fst.MakeMetropolis()); #trial_args = {"particle_type": "0", "site": "0", "reference_index": ref, "num_steps": num_steps} mc.add(fst.MakeTrialTranslate(fst.args({"tunable_param": "0.1"}))) #mc.add(fst.MakeTrialGrow(fst.ArgsVector([dict({"translate": "true", "tunable_param": "0.1"}, **trial_args)]))) mc.add(fst.MakeTrialAdd(fst.args({"particle_type": "0", "weight": "4"}))) mc.add(fst.MakeTune(fst.args({"steps_per": steps_per}))) mc.add(fst.MakeCheckEnergy(fst.args({"steps_per": steps_per, "tolerance": "0.0001"}))) mc.add(fst.MakeLogAndMovie(fst.args({"steps_per": steps_per, "file_name": model + str(num_particles)}))) mc.set(fst.MakeCheckpoint(fst.args({"file_name": "checkpoint" + str(num_particles) + ".fst", "num_hours": str(0.1*num_procs*num_hours), "num_hours_terminate": str(0.9*num_procs*num_hours)}))) mc.run(fst.MakeRun(fst.args({"until_num_particles": str(num_particles)}))) mc.run(fst.MakeRemoveTrial(fst.args({"name": "TrialAdd"}))) # nvt equilibration at desired temperature mc.set(fst.MakeThermoParams(fst.args({"beta": str(beta), "chemical_potential": str(mu)}))) mc.attempt(int((num_particles+1)*num_equil)) mc.run(fst.MakeRemoveModify(fst.args({"name": "Tune"}))) mc.add(fst.MakeTrialTransfer(fst.args({"particle_type": "0", "weight": "4"}))) #mc.add(fst.MakeTrialGrow(fst.ArgsVector([dict({"transfer": "true", "weight": "4"}, **trial_args)]))) mc.set(fst.MakeFlatHistogram(fst.args({ "Macrostate": "MacrostateNumParticles", "width": "1", "max": str(num_particles), "min": str(num_particles), "Bias": "TransitionMatrix", "min_sweeps": "1"}))) mc.add(fst.MakeEnergy(fst.args({"steps_per_write": steps_per, "file_name": "en" + str(num_particles) + ".txt"}))) mc.add(fst.MakeCriteriaWriter(fst.args({"steps_per": steps_per, "file_name": "crit" + str(num_particles) + ".txt"}))) mc.attempt(int((num_particles+1)*num_prod))
def mc(thread, mn, mx): mc = fst.MakeMonteCarlo() mc.set(fst.MakeRandomMT19937(fst.args({"seed": "123"}))) mc.add( fst.MakeConfiguration( fst.args({ "side_length0": str(args.lx), "side_length1": str(args.ly), "side_length2": str(args.lz), "particle_type0": args.particle }))) for site_type in range(mc.configuration().num_site_types()): mc.get_system().get_configuration().set_model_param( "cutoff", site_type, args.cutoff) mc.add(fst.MakePotential(fst.MakeLennardJones())) mc.add( fst.MakePotential(fst.MakeLennardJones(), fst.MakeVisitModelIntra(fst.args({"cutoff": "4"})))) mc.add(fst.MakePotential(fst.MakeLongRangeCorrections())) if mx > args.dccb_begin: reference = fst.Potential( fst.MakeLennardJones(), fst.MakeVisitModelCell( fst.args({"min_length": str(args.dccb_cutoff)}))) reference.set_model_params(mc.configuration()) for site_type in range(mc.configuration().num_site_types()): reference.set_model_param("cutoff", site_type, args.dccb_cutoff) mc.add_to_reference(reference) #mc.add_to_reference(fst.MakePotential(fst.MakeLennardJones(), # fst.MakeVisitModelIntra(fst.args({"cutoff": "4"})))) stage_args = {"reference_index": "0", "num_steps": "4"} else: mc.add_to_reference(fst.MakePotential(fst.DontVisitModel())) stage_args = {"reference_index": "0", "num_steps": "1"} beta = 1. / fst.kelvin2kJpermol(args.temperature) mc.set( fst.MakeThermoParams( fst.args({ "beta": str(beta), "chemical_potential0": str(args.beta_mu / beta) }))) mc.set(fst.MakeMetropolis()) mc.add(fst.MakeTrialTranslate(fst.args({"weight": "0.5"}))) mc.add(fst.MakeTrialRotate(fst.args({"weight": "0.5"}))) print('thread', thread, 'mn', mn, 'mx', mx) if thread == 0 and mn > 0: mc.add(fst.MakeTrialAdd(fst.args({"particle_type": "0"}))) mc.run(fst.MakeRun(fst.args({"until_num_particles": str(mn)}))) mc.run(fst.RemoveTrial(fst.args({"name": "TrialAdd"}))) mc.set( fst.MakeFlatHistogram( fst.MakeMacrostateNumParticles( fst.Histogram( fst.args({ "width": "1", "max": str(mx), "min": str(mn) }))), # fst.MakeTransitionMatrix(fst.args({"min_sweeps": str(args.sweeps)})), fst.MakeWLTM( fst.args({ "collect_flatness": str(args.collect_flatness), "min_flatness": str(args.min_flatness), "min_sweeps": "1000" })))) # configurational bias with TrialGrow: full and partial regrows from 0-site, and reverse num_sites = mc.configuration().particle_type(0).num_sites() for site in range(num_sites): for g in gen_grow(num_sites, reptate=False): mc.add( fst.MakeTrialGrow( fst.ArgsVector(add_particle_type_weight( site, num_sites, g)), fst.args(stage_args))) # reptation if num_sites > 3: for g in gen_grow(num_sites, reptate=True): mc.add( fst.MakeTrialGrow( fst.ArgsVector(add_particle_type_weight(0, num_sites, g)), fst.args(stage_args))) # these moves may not take bond energies into consideration properly. Instead, should implement a dihedral rotation. #mc.add(fst.MakeTrialCrankshaft(fst.args(dict({"weight": "0.25", "tunable_param": "25.", "max_length": "5."}, **stage_args)))) #mc.add(fst.MakeTrialPivot(fst.args(dict({"weight": "0.25", "tunable_param": "25.", "max_length": "5."}, **stage_args)))) mc.add( fst.MakeCheckEnergy( fst.args({ "steps_per": str(args.steps_per), "tolerance": "0.0001" }))) mc.add( fst.MakeTune( fst.args({ "steps_per": str(args.steps_per), "stop_after_phase": "0" }))) mc.add( fst.MakeLogAndMovie( fst.args({ "steps_per": str(args.steps_per), "file_name": "clones" + str(thread), "file_name_append_phase": "True" }))) mc.add( fst.MakeEnergy( fst.args({ "file_name": "en" + str(thread) + '.txt', "file_name_append_phase": "True", "start_after_phase": "0", "steps_per_write": str(args.steps_per), "steps_per_update": "1", "multistate": "True" }))) mc.add( fst.MakeCriteriaUpdater(fst.args({"steps_per": str(args.steps_per)}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "steps_per": str(args.steps_per), "file_name": "clones" + str(thread) + "_crit.txt", "file_name_append_phase": "True" }))) mc.set( fst.MakeCheckpoint( fst.args({ "file_name": "checkpoint" + str(thread) + ".fst", "num_hours_terminate": str(0.9 * args.num_procs * args.num_hours) }))) return mc
fst.MakeDomain( fst.args({ "cubic_box_length": str((args.num / args.density)**(1. / 3.)) })), fst.args({"particle_type": args.data}))) mc.add(fst.MakePotential(fst.MakeLennardJones())) mc.add(fst.MakePotential(fst.MakeLongRangeCorrections())) mc.set(fst.MakeThermoParams(fst.args({"beta": str(args.beta)}))) mc.set(fst.MakeMetropolis()) mc.add( fst.MakeTrialTranslate( fst.args({ "tunable_param": "0.2", "tunable_target_acceptance": "0.2" }))) mc.add(fst.MakeTrialAdd(fst.args({"particle_type": "0"}))) mc.run(fst.MakeRun(fst.args({"until_num_particles": str(args.num)}))) mc.run(fst.MakeRemoveTrial(fst.args({"name": "TrialAdd"}))) steps_per = str(int(1e5)) mc.add( fst.MakeCheckEnergyAndTune( fst.args({ "steps_per": steps_per, "tolerance": "1e-8" }))) mc.set( fst.MakeCheckpoint( fst.args({ "file_name": "checkpoint.fst", "num_hours": str(0.95 * args.num_hours), "num_hours_terminate": str(0.95 * args.num_hours)