def system(config, alphaL=5.6, kmax_squared=38, rcut=False): if rcut: config.set_model_param("cutoff", 0, rcut) config.set_model_param("cutoff", 1, rcut) system = feasst.System() system.add(config) system.add( feasst.Potential( feasst.MakeEwald( feasst.args({ "kmax_squared": str(kmax_squared), "alpha": str(alphaL / system.configuration().domain().min_side_length()) })))) # Unfortunatley, swig isn't accepting the below method of constructing a two body factory # system.add(feasst.Potential(feasst.MakeModelTwoBodyFactory( # feasst.ModelTwoBodyVector([feasst.MakeLennardJones(), feasst.MakeChargeScreened()])))) two = feasst.MakeModelTwoBodyFactory() two.add(feasst.MakeLennardJones()) two.add(feasst.MakeChargeScreened()) system.add(feasst.Potential(two)) system.add( feasst.Potential(feasst.MakeChargeScreenedIntra(), feasst.MakeVisitModelBond())) system.add(feasst.Potential(feasst.MakeChargeSelf())) system.add(feasst.Potential(feasst.MakeLongRangeCorrections())) # system.precompute() return system
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 system(config=None, box_length=8.109613, alphaL=6.870983963962610000, kmax_squared=38, rcut=4.891304347826090): if not config: config = feasst.Configuration( feasst.MakeDomain( feasst.args({"cubic_box_length": str(box_length)})), feasst.args({ "particle_type0": feasst.install_dir() + "/plugin/ewald/forcefield/data.rpm_plus", "particle_type1": feasst.install_dir() + "/plugin/ewald/forcefield/data.rpm_minus" })) config.set_model_param("cutoff", 0, rcut) config.set_model_param("cutoff", 1, rcut) system = feasst.System() system.add(config) system.add( feasst.Potential( feasst.MakeEwald( feasst.args({ "kmax_squared": str(kmax_squared), "alpha": str(alphaL / system.configuration().domain().min_side_length()) })))) # Unfortunatley, swig isn't accepting the below method of constructing a two body factory # system.add(feasst.Potential(feasst.MakeModelTwoBodyFactory( # feasst.ModelTwoBodyVector([feasst.MakeLennardJones(), feasst.MakeChargeScreened()])))) two = feasst.MakeModelTwoBodyFactory() two.add(feasst.MakeHardSphere()) two.add(feasst.MakeChargeScreened()) system.add(feasst.Potential(two)) system.add(feasst.Potential(feasst.MakeChargeSelf())) # system.precompute() return system
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({ "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