def main(args): function = get_function(args.function) distances = np.linspace(args.range[0], args.range[1], args.ndata) with connect(args.dbname) as db: for d in distances: pos_dict = { "units": "angstroem", "boundary_conditions": "free", "positions": [ { args.element: [0, 0, 0] }, { args.element: [d, 0, 0] }, ], } posinp = Posinp.from_dict(pos_dict) atoms = posinp_to_ase_atoms(posinp) energy = function.value(d) forces = np.array([ [-1.0 * function.first_derivative(-d), 0, 0], [-1.0 * function.first_derivative(d), 0, 0], ]) db.write(atoms, data={"energy": energy, "forces": forces})
def generate_graphene_cell(xsize, zsize): base_cell = np.array([2.4674318, 0, 4.2737150]) positions = [] reduced_pos = np.array([[0, 0, 0], [0, 0, 1.0 / 3], [0.5, 0, 0.5], [0.5, 0, 5.0 / 6]]) for i in range(xsize): for j in range(zsize): p = (np.array([i, 0, j]) + reduced_pos) * base_cell for pi in p: positions.append({"C": pi}) pos_dict = { "units": "angstroem", "cell": base_cell * np.array([xsize, 0, zsize]), "positions": positions, } pos = Posinp.from_dict(pos_dict) return pos