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))
Exemplo n.º 2
0
def initialize_neighbor_list(mc):
    neigh_crit = fst.MakeNeighborCriteria(
        fst.args({
            "maximum_distance": "10",
            "minimum_distance": "2.5",
            "site_type0": "0",
            "site_type1": "0",
            "potential_index": "1"
        }))
    mc.add(neigh_crit)
    lj_and_coul = fst.MakeModelTwoBodyFactory()
    lj_and_coul.add(fst.MakeLennardJones())
    lj_and_coul.add(fst.MakeChargeScreened(fst.args({"table_size": "0"})))
    mc.set(
        1,
        fst.MakePotential(
            lj_and_coul,
            fst.MakeVisitModel(
                fst.MakeVisitModelInner(
                    fst.MakeEnergyMapNeighborCriteria(neigh_crit))),
            fst.args({"table_size": "1e6"})))
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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
Exemplo n.º 6
0
print("args:", args)

mc = fst.MonteCarlo()
if args.task > 0:
    mc = fst.MakeMonteCarlo("checkpoint.fst")
    mc.attempt(args.trials - mc.trials().num_attempts())
    quit()
mc.set(fst.MakeRandomMT19937(fst.args({"seed": args.seed})))
mc.add(
    fst.Configuration(
        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(
Exemplo n.º 7
0
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
Exemplo n.º 8
0
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
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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