def create_child_from(self, parent): child = parent.copy() calc = EMT() child.set_calculator(calc) if (random.random() > 0.25): child.rattle(0.02, random.randint(0, 50)) else: child.rattle(0.2, random.randint(0, 50)) dyn = LBFGSLineSearch(atoms=child) dyn.run(steps=20000) dyn = FIRE(atoms=child) dyn.run(fmax=0.05) return child
def genParticle(definingString, number): """definingString should be something like " 'Pt80' ", for example. number should be the number of atoms that will be in the molecule.""" dummyAtom = ase.io.read("InputGeom.vasp", format="vasp") while len(dummyAtom) > number: dummyAtom.pop(-1) coords = dummyAtom.get_positions().tolist() shuffledCoords = [] while len(coords) > 0: # THIS IS SCREWED UP! R = random.randint(0, len(coords) - 1) item = coords.pop(R) shuffledCoords.append(item) newAtom = Atoms(definingString, shuffledCoords) calc = EMT() newAtom.set_calculator(calc) newAtom.set_cell(dummyAtom.get_cell() * 10.0) dyn = LBFGSLineSearch(atoms=newAtom) dyn.run(steps=20000) dyn = FIRE(atoms=newAtom) dyn.run(fmax=0.05) return newAtom
def nearlySphericalAtom(definingString, inRadius, number): """definingString should be something like " 'Pt80' ", for example. inRadius should be the radius that you wish to have for the atom. number should be the number of atoms that will be in the molecule.""" positionList = [] for x in range(number): xDistance = random.uniform(0, inRadius) * plusOrMinus() remainingX = ((inRadius ** 2) - (xDistance ** 2)) ** 0.5 yDistance = random.uniform(0, remainingX) * plusOrMinus() zDistance = random.uniform( 0, (((remainingX ** 2) - (yDistance ** 2)) ** 0.5) * plusOrMinus() + random.normal(0, 0.1) ) coordinates = (xDistance, yDistance, zDistance) positionList.append(coordinates) newAtom = Atoms(definingString, positionList) calc = EMT() newAtom.set_calculator(calc) dyn = LBFGSLineSearch(atoms=newAtom) dyn.run(steps=200000) dyn = FIRE(atoms=newAtom) dyn.run(fmax=0.01) return newAtom
def change_concentration(ge_concentration=0): # Read in 1728 atom system atoms = read('structures/1728_atom/aSi.xyz', format='xyz') # Swap in Ge atoms if ge_concentration != 0: symbols = np.array(atoms.get_chemical_symbols()) n_ge_atoms = int(np.round(ge_concentration * len(symbols), 0)) rng = np.random.default_rng(seed=random_seed) id = rng.choice(len(atoms), size=n_ge_atoms, replace=False) symbols[id] = 'Ge' atoms.set_chemical_symbols(symbols.tolist()) ge_concentration = str(int(ge_concentration * 100)) folder_string = 'structures/1728_atom/aSiGe_C' + str(ge_concentration) if not os.path.exists(folder_string): os.makedirs(folder_string) # Minimize structure - LAMMPS + ASE lammps_inputs = { 'lmpcmds': [ "pair_style tersoff", "pair_coeff * * forcefields/SiCGe.tersoff Si(D) Ge" ], "log_file": "min.log", "keep_alive": True } calc = LAMMPSlib(**lammps_inputs) atoms.set_calculator(calc) atoms.pbc = True search = LBFGSLineSearch(atoms) search.run(fmax=.001) write('structures/1728_atom/aSiGe_C' + str(ge_concentration) + '/replicated_atoms.xyz', search.atoms, format='xyz')
from ase.constraints import UnitCellFilter import pyjulip bulk_at = bulk("Cu", cubic=True) sigma = (bulk_at * 2).get_distance(0, 1) * (2.**(-1. / 6)) calc = LennardJones(sigma=sigma, epsilon=0.05) N_cell = 3 at0 = bulk_at * N_cell del at0[0] at_ref = at0.copy() at_ref.set_calculator(calc) opt = LBFGSLineSearch(at_ref) opt.run(fmax=1e-6) at_ref_var_cell = at0.copy() at_ref_var_cell.set_calculator(calc) opt = LBFGSLineSearch(UnitCellFilter(at_ref_var_cell)) opt.run(fmax=1e-6) for variable_cell in [False, True]: at = at0.copy() at.set_calculator(calc) opt = pyjulip.JulipOptimizer(at, variable_cell=variable_cell) opt.run(fmax=1e-6) if variable_cell: assert np.abs(at.positions - at_ref_var_cell.positions).max() < 1e-6 assert np.abs(at.cell - at_ref_var_cell.cell).max() < 1e-6