def equil_and_relax(T, fname="", np_layer=0, nptype="spherical"):
    bc = init_bc(50)
    mc = Montecarlo(bc.atoms, T)
    print ("Running at temperature {}K. Initializing from {}".format(T, fname))
    layer_str = "-".join((str(item) for item in np_layers[np_layer]))
    run_identifier = "{}K_layer{}".format(T, layer_str)
    if fname != "":
        # Initialize atoms object from file
        from ase.io import read
        atoms = read(fname)
        symbs = [atom.symbol for atom in atoms]
        mc.set_symbols(symbs)
        run_identifier = "{}K_{}".format(T, atoms.get_chemical_formula())
    else:
        if nptype == "spherical":
            # Initialize by setting a nano particle at the center
            nanop = get_nanoparticle(layer=np_layer)
        elif nptype == "cubic":
            nanop = get_cubic_nano_particle(layer=np_layer)
            run_identifier += "cubic"
        else:
            raise ValueError("Unknown type {}".format(nanop))
        symbs = insert_nano_particle(bc.atoms.copy(), nanop)
        mc.set_symbols(symbs)
    print("Chemical formula: {}".format(mc.atoms.get_chemical_formula()))
    nsteps = int(4E7)
    camera = Snapshot(atoms=mc.atoms, trajfile=workdir+"/snapshots_equil{}.traj".format(run_identifier))
    energy_evol = EnergyEvolution(mc)
    mc_backup = MCBackup(mc, backup_file=workdir+"/mc_backup{}.pkl".format(run_identifier))
    mc.attach(energy_evol, interval=100000)
    mc.attach(camera, interval=nsteps/20)
    mc.attach(mc_backup, interval=500000)
    mc.runMC(steps=nsteps, equil=False)
    write(workdir+"/equillibriated600K.xyz", mc.atoms)
def main():
    energies = []
    sizes = list(range(1, 6))
    atoms = get_atoms()
    two_atoms(atoms)
    exit()
    insert_np(6, atoms)

    mc = Montecarlo(atoms, 0.1)
    camera = Snapshot(atoms=mc.atoms, trajfile="/work/sophus/nuc_cluster.traj")
    db = dataset.connect("sqlite:////work/sophus/mgsi_nuc_barrier_kamijo.db")
    tbl = db["systems"]
    mc.attach(camera, interval=100 * len(atoms))
    num_mg = sum(1 for atom in atoms if atom.symbol == "Mg")
    while num_mg > 2:

        print(atoms.get_chemical_formula())
        mc.runMC(mode="fixed", equil=False, steps=100 * len(atoms))
        thermo = mc.get_thermodynamic()
        tbl.insert(thermo)

        # Remove one Mg atom and one Si atom
        symbols = [a.symbol for a in atoms]
        for i in range(20):
            i = symbols.index("Si")
            symbols[i] = "Al"
            i = symbols.index("Mg")
            symbols[i] = "Al"
        mc.set_symbols(symbols)
        num_mg = sum(1 for atom in atoms if atom.symbol == "Mg")
Esempio n. 3
0
def main(size, T):
    atoms = create_surface(size)
    atoms = wrap_and_sort_by_position(atoms)
    conc_args = {
        "conc_ratio_min_1": [[64, 0, 0]],
        "conc_ratio_max_1": [[24, 40, 0]],
        "conc_ratio_min_2": [[64, 0, 0]],
        "conc_ratio_max_2": [[22, 21, 21]]
    }

    kwargs = {
        "crystalstructure": "fcc",
        "a": 4.05,
        "size": [4, 4, 4],
        "basis_elements": [["Al", "Mg", "Si"]],
        "conc_args": conc_args,
        "db_name": "data/almgsi.db",
        "max_cluster_size": 4
    }

    ceBulk = BulkCrystal(**kwargs)
    eci_file = "data/almgsi_fcc_eci_newconfig.json"
    with open(eci_file, 'r') as infile:
        ecis = json.load(infile)
    db_name = "large_cell_db{}x{}x{}.db".format(size[0], size[1], size[2])
    calc = get_ce_calc(ceBulk, kwargs, ecis, size=size, db_name=db_name)
    ceBulk = calc.BC
    ceBulk.atoms.set_calculator(calc)

    mc = Montecarlo(ceBulk.atoms, T)
    symbs = [atom.symbol for atom in atoms]
    mc.set_symbols(symbs)

    # Write a copy of the current atoms object
    from ase.io import write
    shape_str = "-".join((str(item) for item in size))
    uid_str = "{}K_{}".format(T, shape_str)
    write(WORKDIR + "initial_config{}.xyz".format(uid_str), mc.atoms)

    backup = MCBackup(mc,
                      backup_file=WORKDIR + "backup{}.xyz".format(uid_str),
                      db_name=WORKDIR + "mc_surface.db")
    camera = Snapshot(atoms=mc.atoms,
                      trajfile=WORKDIR + "surface{}.traj".format(uid_str))
    evol = EnergyEvolution(mc)
    nsteps = int(10E6)
    mc.attach(backup, interval=100000)
    mc.attach(camera, interval=int(nsteps / 20))
    mc.attach(evol, interval=10 * len(mc.atoms))
    mc.runMC(mode="fixed", steps=nsteps, equil=False)
    write(WORKDIR + "final_config{}.xyz".format(uid_str), mc.atoms)
def run(N, T):
    bc = init_bc(N)
    mc = Montecarlo(bc.atoms, T)
    nanop = get_nanoparticle()
    symbs = insert_nano_particle(bc.atoms.copy(), nanop)
    mc.set_symbols(symbs)
    order_param = SiteOrderParameter(mc.atoms)
    nsteps = int(1E6)
    equil_params = {"mode": "fixed", "window_length": int(1E5)}
    mc.attach(order_param)
    mc.runMC(steps=nsteps, equil=True, equil_params=equil_params)
    thermo = mc.get_thermodynamic()
    mean, std = order_param.get_average()
    thermo["order_param_mean"] = mean
    thermo["order_param_std"] = std
    thermo.update(equil_params)
    db = dataset.connect("sqlite:///{}".format(mc_db_name))
    tbl = db["cluster_stability"]
    tbl.insert(thermo)
    fname = workdir + "/final_structure{}K.xyz".format(T)
    write(fname, mc.atoms)
Esempio n. 5
0
 def set_symbols(self, symbs):
     """Override parents set symbols."""
     Montecarlo.set_symbols(self, symbs)
     self.init_cluster_info()