def optimize_lammpslib(struc, lmp, parameters=None, path='tmp', calc_type=None, lmp_file=None, molecule=False, strain=np.ones([3, 3]), method='FIRE', fmax=0.01): if lmp_file is not None: lammps = LAMMPSlib(lmp=lmp, lmp_file=lmp_file, log_file='lammps.log', \ molecule=molecule, path=path) elif calc_type is not None: lammps = LAMMPSlib(lmp=lmp, lmpcmds=parameters, calc_type=calc_type, \ log_file='lammps.log', molecule=molecule, path=path) else: lammps = LAMMPSlib(lmp=lmp, lmpcmds=parameters, log_file='lammps.log', \ molecule=molecule, path=path) struc.set_calculator(lammps) box = mushybox(struc, fixstrain=strain) if method == 'FIRE': dyn = FIRE(box) else: dyn = LBFGS(box) dyn.run(fmax=fmax, steps=500) return struc
def optimize_lammpslib(pbcgb, lmp, parameters, path, method='FIRE', fmax=0.1): lammps = LAMMPSlib(lmp=lmp, lmpcmds=parameters, log_file='lammps.log', path=path) pbcgb.set_calculator(lammps) cell0 = pbcgb.cell fixstrain = np.zeros((3, 3)) fixstrain[2][2] = 1 box = mushybox(pbcgb, fixstrain=fixstrain) if method == 'FIRE': dyn = FIRE(box) else: dyn = BFGS(box) dyn.run(fmax=fmax, steps=500) return pbcgb
for i in range(1): while True: sg = randint(2, 230) crystal = molecular_crystal(sg, ['H2O'], [randint(1, 4)], 1.0) #, lattice=para) if crystal.valid: struc = Atoms( crystal.spg_struct[2], cell=crystal.spg_struct[0], scaled_positions=crystal.spg_struct[1], ) break #struc = struc.repeat((2,2,2)) lammps = LAMMPSlib(lmp=lmp, lmpcmds=parameters, mol=True) struc.set_calculator(lammps) box = mushybox(struc) dyn = FIRE(box) dyn.run(fmax=0.00, steps=1100) #dyn = BFGS(box) #dyn.run(fmax=0.01, steps=200) #dyn = BFGS(box) #dyn.run(fmax=0.01, steps=200) Eng = struc.get_potential_energy() * 96 / len(struc) * 3 Vol = struc.get_volume() / len(struc) * 3 stress = np.max(struc.get_stress()) struc = sort(struc) try: spg = get_symmetry_dataset(struc, symprec=1e-1)['number']