def criteria_flathist( temperature=1.5, chemical_potential=-2.352321, macro_min=0, # minimum macrostate macro_max=370, # maximum macrostate tmmc=True, # use Transition-Matrix (TM) if true, else Wang-Landau (WL) iterations=20): # number of sweeps (TM) or flatness (WL) """Return a flat histogram acceptance criteria with number of particles as the macrostate""" if tmmc: bias = fst.MakeTransitionMatrix( fst.args({"min_sweeps": str(iterations)})) else: bias = fst.MakeWangLandau(fst.args({"min_flatness": str(iterations)})) return fst.MakeFlatHistogram( fst.MakeMacrostateNumParticles( fst.Histogram( fst.args({ "width": "1", "min": str(macro_min), "max": str(macro_max) }))), bias, fst.args({ "beta": str(1. / temperature), "chemical_potential": str(chemical_potential) }))
def mc(thread, mn, mx): steps_per = str(int(1e6)) mc = fst.MakeMonteCarlo() 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())) trial_args = {"particle_type": "0", "site": "0"} if mx >= args.dccb_begin: mc.run( fst.MakeAddReference(fst.args({ "cutoff": "1", "use_cell": "true" }))) trial_args["reference_index"] = "0" trial_args["num_steps"] = "4" mc.set( fst.MakeThermoParams( fst.args({ "beta": str(1. / args.temperature), "chemical_potential": str(args.mu) }))) 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.min_sweeps)})), fst.MakeWLTM( fst.args({ "collect_flatness": "18", "min_flatness": "22", "min_sweeps": str(args.min_sweeps) })))) #mc.add(fst.MakeTrialTranslate(fst.args({"weight": "1.", "tunable_param": "1."}))) #mc.add(fst.MakeTrialTransfer(fst.args({"weight": "4", "particle_type": "0", mc.add( fst.MakeTrialGrow( fst.ArgsVector([ dict({ "translate": "true", "tunable_param": "1" }, **trial_args) ]))) mc.add( fst.MakeTrialGrow( fst.ArgsVector( [dict({ "transfer": "true", "weight": "4" }, **trial_args)]))) mc.add( fst.MakeCheckEnergy( fst.args({ "steps_per": steps_per, "tolerance": "0.0001" }))) mc.add( fst.MakeTune( fst.args({ "steps_per": steps_per, "stop_after_phase": "0" }))) mc.add( fst.MakeLogAndMovie( fst.args({ "steps_per": steps_per, "file_name": "clones" + str(thread), "file_name_append_phase": "True" }))) mc.add( fst.MakeEnergy( fst.args({ "steps_per_write": steps_per, "file_name": "en" + str(thread) + ".txt", "file_name_append_phase": "True", "start_after_phase": "0", "multistate": "True" }))) mc.add(fst.MakeCriteriaUpdater(fst.args({"steps_per": steps_per}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "steps_per": 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": str(0.1 * args.num_procs * args.num_hours), "num_hours_terminate": str(0.9 * args.num_procs * args.num_hours) }))) return mc
def mc(thread, mn, mx, trials_per=str(int(1e6))): mc = fst.MakeMonteCarlo() mc.add(config()) mc.add(fst.MakePotential(fst.MakeLennardJonesForceShift())) mc.set( fst.MakeThermoParams( fst.args({ "beta": str(1. / args.temperature), "chemical_potential": str(args.mu) }))) 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.min_sweeps)})), fst.MakeWLTM( fst.args({ "collect_flatness": "18", "min_flatness": "22", "min_sweeps": str(args.min_sweeps) })))) mc.add( fst.MakeTrialTranslate( fst.args({ "weight": "1.", "tunable_param": "1." }))) mc.add( fst.MakeTrialRotate(fst.args({ "weight": "1.", "tunable_param": "20." }))) mc.add( fst.MakeTrialTransfer(fst.args({ "weight": "4", "particle_type": "0" }))) mc.add( fst.MakeCheckEnergy( fst.args({ "trials_per": trials_per, "tolerance": "0.0001" }))) mc.add(fst.MakeTune(fst.args({"stop_after_phase": "0"}))) mc.add( fst.MakeLogAndMovie( fst.args({ "trials_per": trials_per, "file_name": "clones" + str(thread), "file_name_append_phase": "True" }))) mc.add( fst.MakeEnergy( fst.args({ "trials_per_write": trials_per, "file_name": "en" + str(thread) + ".txt", "file_name_append_phase": "True", "start_after_phase": "0", "multistate": "True" }))) mc.add(fst.MakeCriteriaUpdater(fst.args({"trials_per": trials_per}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "trials_per": trials_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": str(0.1 * args.num_procs * args.num_hours), "num_hours_terminate": str(0.9 * args.num_procs * args.num_hours) }))) return mc
def mc(thread, mn, mx): steps_per = int(1e5) avb, dccb = avb_or_dccb(mx) mc = fst.MakeMonteCarlo() mc.add( fst.MakeConfiguration( fst.args({ "cubic_box_length": "20", "physical_constants": "CODATA2010", "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())) if dccb or avb: mc.run( fst.MakeAddReference( fst.args({ "potential_index": "1", "cutoff": "3.16555789", "use_cell": "true" }))) if avb: initialize_neighbor_list(mc) beta = 1. / fst.kelvin2kJpermol(525, mc.configuration()) mc.set( fst.MakeThermoParams( fst.args({ "beta": str(beta), "chemical_potential": str(-8.14 / beta) }))) mc.set( fst.MakeFlatHistogram( fst.MakeMacrostateNumParticles( fst.Histogram( fst.args({ "width": "1", "max": str(mx), "min": str(mn) }))), fst.MakeTransitionMatrix(fst.args({"min_sweeps": "10"})))) mc.add( fst.MakeTrialTranslate( fst.args({ "weight": "1.", "tunable_param": "1.", }))) mc.add( fst.MakeTrialRotate(fst.args({ "weight": "1.", "tunable_param": "1." }))) mc.add( fst.MakeTrialTransfer(fst.args({ "particle_type": "0", "weight": "4" }))) regrow1 = [{ "angle": "true", "mobile_site": "1", "anchor_site": "0", "anchor_site2": "2" }] regrow2 = [{ "angle": "true", "mobile_site": "2", "anchor_site": "0", "anchor_site2": "1" }] regrow12 = [{ "bond": "true", "mobile_site": "1", "anchor_site": "0" }] + copy.deepcopy(regrow2) regrow21 = [{ "bond": "true", "mobile_site": "2", "anchor_site": "0" }] + copy.deepcopy(regrow1) if dccb: grow012 = [{ "transfer": "true", "site": "0", "weight": "4" }] + copy.deepcopy(regrow12) grow021 = [{ "transfer": "true", "site": "0", "weight": "4" }] + copy.deepcopy(regrow21) for grow in [regrow1, regrow2]: grow[0]["weight"] = "0.3" for grow in [regrow12, regrow21]: grow[0]["weight"] = "0.2" for grow in [grow012, grow021, regrow12, regrow21, regrow1, regrow2]: grow[0]["particle_type"] = "0" mc.add( fst.MakeTrialGrow( fst.ArgsVector(grow), fst.args({ "reference_index": "0", "num_steps": "4" }))) if avb: for avbtype in ["transfer_avb", "regrow_avb2", "regrow_avb4"]: avb = [{ avbtype: "true", "site": "0", "neighbor_index": "0", "target_particle_type": "0", "target_site": "0" }] avb_012 = copy.deepcopy(avb) + copy.deepcopy(regrow12) avb_021 = copy.deepcopy(avb) + copy.deepcopy(regrow21) for grow in [avb_012, avb_021]: grow[0]["weight"] = "0.5" grow[0]["particle_type"] = "0" mc.add( fst.MakeTrialGrow( fst.ArgsVector(grow), fst.args({ "num_steps": "4", "reference_index": "0" }))) mc.add( fst.MakeCheckEnergyAndTune( fst.args({ "steps_per": str(steps_per), "tolerance": "0.0001" }))) mc.add( fst.MakeLogAndMovie( fst.args({ "steps_per": str(steps_per), "file_name": "clones" + str(thread) }))) mc.add(fst.MakeCriteriaUpdater(fst.args({"steps_per": str(steps_per)}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "steps_per": str(steps_per), "file_name": "clones" + str(thread) + "_crit.txt" }))) mc.add( fst.MakeEnergy( fst.args({ "steps_per_write": str(steps_per), "file_name": "en" + str(thread), "multistate": "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
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
def mc(thread, mn, mx): steps_per = str(int(1e6)) mc = fst.MakeMonteCarlo() mc.add( fst.MakeConfiguration( fst.args({ "cubic_box_length": str(args.cubic_box_length), "particle_type0": fst.install_dir() + "/forcefield/hard_sphere.fstprt" }))) mc.add(fst.MakePotential(fst.MakeHardSphere())) # mc.add_to_optimized(fst.MakePotential(fst.MakeHardSphere(), fst.MakeVisitModelCell(fst.args({"min_length": "1"})))) mc.set( fst.MakeThermoParams( fst.args({ "beta": "1", "chemical_potential": str(args.mu) }))) 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.min_sweeps)})), fst.MakeWLTM( fst.args({ "collect_flatness": "18", "min_flatness": "22", "min_sweeps": str(args.min_sweeps) })))) mc.add( fst.MakeTrialTranslate( fst.args({ "new_only": "true", "weight": "1.", "tunable_param": "1." }))) mc.add( fst.MakeTrialTransfer(fst.args({ "weight": "4", "particle_type": "0" }))) mc.add( fst.MakeCheckEnergy( fst.args({ "steps_per": steps_per, "tolerance": "0.0001" }))) mc.add( fst.MakeTune( fst.args({ "steps_per": steps_per, "stop_after_phase": "0" }))) mc.add( fst.MakeLogAndMovie( fst.args({ "steps_per": steps_per, "file_name": "clones" + str(thread), "file_name_append_phase": "True" }))) mc.add( fst.MakePairDistribution( fst.args({ "steps_per_update": "1000", "steps_per_write": steps_per, "dr": "0.025", "file_name": "gr" + str(thread) + ".txt", "file_name_append_phase": "True", "start_after_phase": "0", "multistate": "True", "multistate_aggregate": "False" }))) mc.add(fst.MakeCriteriaUpdater(fst.args({"steps_per": steps_per}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "steps_per": 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": str(0.1 * args.num_procs * args.num_hours), "num_hours_terminate": str(0.9 * args.num_procs * args.num_hours) }))) return mc
def mc(thread, mn, mx): mc = fst.MakeMonteCarlo() #mc.set(fst.MakeRandomMT19937(fst.args({"seed": "123"}))) mc.add( fst.MakeConfiguration( fst.args({ "cubic_box_length": str(args.cubic_box_length), "physical_constants": "CODATA2010", "particle_type0": args.molecule }))) mc.add( fst.MakePotential( fst.MakeEwald( fst.args({ "alpha": str(5.6 / args.cubic_box_length), "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())) if mx > args.dccb_begin: mc.run( fst.MakeAddReference( fst.args({ "potential_index": "1", "cutoff": "3.16555789", "use_cell": "true" }))) beta = 1. / fst.kelvin2kJpermol(args.temperature, mc.configuration()) mc.set( fst.MakeThermoParams( fst.args({ "beta": str(beta), "chemical_potential": str(args.beta_mu / beta) }))) mc.set( fst.MakeFlatHistogram( fst.MakeMacrostateNumParticles( fst.Histogram( fst.args({ "width": "1", "max": str(mx), "min": str(mn) }))), fst.MakeTransitionMatrix(fst.args({"min_sweeps": "10"})))) mc.add( fst.MakeTrialTranslate( fst.args({ "weight": "1.", "tunable_param": "1.", }))) if mx > args.dccb_begin: regrow1 = [{ "angle": "true", "mobile_site": "1", "anchor_site": "0", "anchor_site2": "2" }] regrow2 = [{ "angle": "true", "mobile_site": "2", "anchor_site": "0", "anchor_site2": "1" }] regrow12 = [{ "bond": "true", "mobile_site": "1", "anchor_site": "0" }] + copy.deepcopy(regrow2) regrow21 = [{ "bond": "true", "mobile_site": "2", "anchor_site": "0" }] + copy.deepcopy(regrow1) grow012 = [{ "transfer": "true", "site": "0", "weight": "4" }] + copy.deepcopy(regrow12) grow021 = [{ "transfer": "true", "site": "0", "weight": "4" }] + copy.deepcopy(regrow21) for grow in [regrow1, regrow2]: grow[0]["weight"] = "0.3" for grow in [regrow12, regrow21]: grow[0]["weight"] = "0.2" for grow in [grow012, grow021, regrow12, regrow21, regrow1, regrow2]: grow[0]["particle_type"] = "0" mc.add( fst.MakeTrialGrow( fst.ArgsVector(grow), fst.args({ "reference_index": "0", "num_steps": "4" }))) else: mc.add( fst.MakeTrialRotate( fst.args({ "weight": "1.", "tunable_param": "1." }))) mc.add( fst.MakeTrialTransfer( fst.args({ "particle_type": "0", "weight": "4" }))) mc.add( fst.MakeCheckEnergyAndTune( fst.args({ "steps_per": str(args.steps_per), "tolerance": "0.0001" }))) mc.add( fst.MakeLogAndMovie( fst.args({ "steps_per": str(args.steps_per), "file_name": "clones" + str(thread) }))) 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" }))) mc.add( fst.MakeEnergy( fst.args({ "steps_per_write": str(args.steps_per), "file_name": "en" + str(thread), "multistate": "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
def mc(thread, mn, mx): steps_per = int(1e4) mc = fst.MakeMonteCarlo() mc.add( fst.MakeConfiguration( fst.args({ "cubic_box_length": "12", "particle_type0": fst.install_dir() + "/plugin/charge/forcefield/rpm_plus.fstprt", "particle_type1": fst.install_dir() + "/plugin/charge/forcefield/rpm_minus.fstprt", "cutoff": "4.891304347826090", "charge0": str(1. / math.sqrt(fst.CODATA2018().charge_conversion())), "charge1": str(-1. / math.sqrt(fst.CODATA2018().charge_conversion())) }))) mc.add( fst.MakePotential( fst.MakeEwald( fst.args({ "alpha": str(6.87098396396261 / 12), "kmax_squared": "38" })))) mc.add( fst.MakePotential( fst.MakeModelTwoBodyFactory(fst.MakeHardSphere(), fst.MakeChargeScreened()), fst.args({"table_size": "1e6"}))) mc.add(fst.MakePotential(fst.MakeChargeSelf())) num_steps = "1" ref = "-1" if mx >= args.dccb_begin: mc.run( fst.MakeAddReference( fst.args({ "potential_index": "1", "cutoff": "1", "use_cell": "true" }))) ref = "0" num_steps = "4" beta = 1. / args.temperature mc.set( fst.MakeThermoParams( fst.args({ "beta": str(beta), "chemical_potential0": str(args.beta_mu / beta), "chemical_potential1": str(args.beta_mu / beta) }))) 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.min_sweeps)})), fst.MakeWLTM( fst.args({ "collect_flatness": "18", "min_flatness": "22", "min_sweeps": str(args.min_sweeps) })), fst.MakeAEqualB(fst.args({"extra_A": "1"})))) mc.add( fst.MakeTrialTranslate( fst.args({ "weight": "1.", "tunable_param": "1." }))) for particle_type in range(mc.configuration().num_particle_types()): mc.add( fst.MakeTrialTransfer( fst.args({ "weight": "4", "particle_type": str(particle_type), "reference_index": ref, "num_steps": num_steps }))) mc.add( fst.MakeCheckEnergy( fst.args({ "steps_per": str(steps_per), "tolerance": "0.0001" }))) mc.add( fst.MakeTune( fst.args({ "steps_per": str(steps_per), "stop_after_phase": "0" }))) mc.add( fst.MakeLogAndMovie( fst.args({ "steps_per": str(steps_per), "file_name": "clones" + str(thread), "file_name_append_phase": "True" }))) mc.add( fst.MakeEnergy( fst.args({ "steps_per_write": str(steps_per), "file_name": "en" + str(thread) + ".txt.", "file_name_append_phase": "True", "start_after_phase": "0", "multistate": "True" }))) mc.add(fst.MakeCriteriaUpdater(fst.args({"steps_per": str(steps_per)}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "steps_per": str(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": str(0.1 * args.num_procs * args.num_hours), "num_hours_terminate": str(0.9 * args.num_procs * args.num_hours) }))) return mc
def mc(thread, mn, mx): steps_per = str(int(1e5)) mc = fst.MakeMonteCarlo() #mc.set(fst.MakeRandomMT19937(fst.args({"seed": "12345"}))) #mc.set(fst.MakeRandomMT19937(fst.args({"seed": "1634926410"}))) chi = 0.7 # patch coverage patch_angle = 2 * math.asin(math.sqrt(chi / 2)) * 180 / math.pi print('patch_angle', patch_angle) mc = fst.MonteCarlo() config = fst.MakeConfiguration( fst.args({ "cubic_box_length": "8", "particle_type0": fst.install_dir() + "/plugin/patch/forcefield/two_patch_linear.fstprt" })) config.add(fst.MakeGroup(fst.args({"site_type0": "0"}))) mc.add(config) mc.add( fst.MakePotential( fst.MakeHardSphere(), fst.MakeVisitModelCell( fst.args({ "min_length": "1", "cell_group": "1" })), fst.args({"group_index": "1"}))) patch = fst.MakeVisitModelInnerPatch( fst.args({"patch_degrees_of_type1": str(patch_angle)})) mc.add( fst.MakePotential( fst.MakeSquareWell(), fst.MakeVisitModel(patch), #fst.MakeVisitModelCell(patch, fst.args({"min_length": "1.5", "cell_group": "1"})), fst.args({"group_index": "1"}))) mc.set( fst.MakeThermoParams( fst.args({ "beta": str(1. / args.temperature), "chemical_potential": str(args.mu) }))) 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.min_sweeps)})), fst.MakeWLTM( fst.args({ "collect_flatness": "18", "min_flatness": "22", "min_sweeps": str(args.min_sweeps) })))) mc.add( fst.MakeTrialTranslate( fst.args({ "weight": "0.5", "tunable_param": "0.1" }))) mc.add( fst.MakeTrialRotate(fst.args({ "weight": "0.5", "tunable_param": "20." }))) mc.add( fst.MakeTrialTransfer(fst.args({ "weight": "4", "particle_type": "0" }))) # mc.add(fst.MakeTrialGrow(fst.ArgsVector([{"translate": "true", "site": "0", "tunable_param": "1"}]), # {"reference_index": ref, "num_steps": num_steps})) # mc.add(fst.MakeTrialGrow(fst.ArgsVector([{"transfer": "true", "site": "0", "weight": "4"}]), # {"reference_index": ref, "num_steps": num_steps})) mc.add( fst.MakeCheckEnergy( fst.args({ "steps_per": steps_per, "tolerance": "0.0001" }))) mc.add( fst.MakeTune( fst.args({ "steps_per": steps_per, "stop_after_phase": "0" }))) mc.add( fst.MakeLog( fst.args({ "steps_per": steps_per, "file_name": "clones" + str(thread) + ".txt", "file_name_append_phase": "True" }))) mc.add( fst.MakeMoviePatch( fst.args({ "steps_per": steps_per, "file_name": "clones" + str(thread) + ".xyz", "file_name_append_phase": "True" }))) mc.add( fst.MakeEnergy( fst.args({ "steps_per_write": steps_per, "file_name": "en" + str(thread) + ".txt", "file_name_append_phase": "True", "start_after_phase": "0", "multistate": "True" }))) mc.add(fst.MakeCriteriaUpdater(fst.args({"steps_per": steps_per}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "steps_per": 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": str(0.1 * args.num_procs * args.num_hours), "num_hours_terminate": str(0.9 * args.num_procs * args.num_hours) }))) return mc
def mc(thread, mn, mx): steps_per = int(1e4) mc = fst.MakeMonteCarlo() if mx > args.dccb_begin: ref = "0" num = "4" else: ref = "-1" num = "1" config_args = dict() index = 0 thermo_params = {"beta": str(1. / args.temperature)} for part in args.particles: config_args["particle_type" + str(index)] = part thermo_params["chemical_potential" + str(index)] = str( args.beta_mu * args.temperature) index += 1 thermo_params["chemical_potential0"] = str( (args.delta_betamu_0 + args.beta_mu) * args.temperature) mc.add( fst.MakeConfiguration( fst.args( dict( { "side_length0": str(args.lx), "side_length1": str(args.ly), "side_length2": str(args.lz) }, **config_args)))) mc.add(fst.MakePotential(fst.MakeLennardJones())) 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.set(fst.MakeThermoParams(thermo_params)) 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" })))) for particle_type in range(mc.configuration().num_particle_types()): mc.add( fst.MakeTrialTranslate( fst.args({ "particle_type": str(particle_type), "weight": "1.", "tunable_param": "1." }))) if mx > args.dccb_begin and mc.configuration().particle_type( particle_type).num_sites() == 2: mc.add( fst.MakeTrialGrow( fst.ArgsVector([ { "transfer": "true", # "regrow": "true", # regrow isn't very efficient "particle_type": str(particle_type), "site": "0", "weight": "4" }, { "bond": "true", "mobile_site": "1", "anchor_site": "0" } ]), fst.args({ "reference_index": ref, "num_steps": num }))) mc.add( fst.MakeTrialGrow( fst.ArgsVector([{ "particle_type": str(particle_type), "weight": "0.5", "bond": "true", "mobile_site": "1", "anchor_site": "0", "reference_index": ref, "num_steps": num }]))) mc.add( fst.MakeTrialGrow( fst.ArgsVector([{ "particle_type": str(particle_type), "weight": "0.5", "bond": "true", "mobile_site": "0", "anchor_site": "1", "reference_index": ref, "num_steps": num }]))) else: mc.add( fst.MakeTrialRotate( fst.args({ "particle_type": str(particle_type), "weight": "1.", "tunable_param": "1." }))) mc.add( fst.MakeTrialTransfer( fst.args({ "particle_type": str(particle_type), "weight": "4" }))) mc.add( fst.MakeCheckEnergy( fst.args({ "steps_per": str(steps_per), "tolerance": "0.0001" }))) mc.add( fst.MakeTune( fst.args({ "steps_per": str(steps_per), "stop_after_phase": "0" }))) mc.add( fst.MakeLogAndMovie( fst.args({ "steps_per": str(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(steps_per), "steps_per_update": "1", "multistate": "True" }))) if mc.configuration().num_particle_types() > 1: mc.add( fst.MakeNumParticles( fst.args({ "particle_type": "0", "file_name": "num" + str(thread) + '.txt', "file_name_append_phase": "True", "start_after_phase": "0", "steps_per_write": str(steps_per), "steps_per_update": "1", "multistate": "True" }))) mc.add( fst.MakeExtensiveMoments( fst.args({ "steps_per_write": str(steps_per), "file_name": "extmom" + str(thread) + ".txt", "file_name_append_phase": "True", "start_after_phase": "0", # do not update until equilibration complete (phase 1) "max_order": "3", "multistate": "True" }))) mc.add(fst.MakeCriteriaUpdater(fst.args({"steps_per": str(steps_per)}))) mc.add( fst.MakeCriteriaWriter( fst.args({ "steps_per": str(steps_per), "file_name": "clones" + str(thread) + "_crit.txt", "file_name_append_phase": "True" }))) print(0.9 * args.num_procs * args.num_hours) 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