from gpaw import GPAW import periodictable from .latmatcher_interface import extract_from_xyz, process_file, extract_from_bespoke from backend.soft_gpaw.experiment import bespoke_structure_to_ase def get_atomic_number(element_name): # Find the element element = getattr(periodictable, element_name, None) # Check if the element exists if element is not None and hasattr(element, 'number'): return element.number else: return "Element not found" def gpaw_calc_energy(file_gpaw_format, file_gpaw, convergence_forces, hund, xc, basis, beta, method, weight, backend, ecut, mode_name, maxiter, kpts, log_file_name, mail): path_to_move = "/Users/voicutomut/Documents/GitHub/BespokeMaterials/DB/OnlineGPAW" # https://wiki.fysik.dtu.dk/gpaw/documentation/basic.html # TODO: ad proper kpts: kpts = None mode = {"name": mode_name, "ecut": ecut} mixer = {"beta": beta, "method": method, "weight": weight, "backend": backend} poissonsolver = {}#{'dipolelayer': 'xy',} log_file_name = path_to_move + "/{}".format(log_file_name) calc = GPAW(mode=mode, xc=xc, basis=basis, convergence={'forces': convergence_forces}, poissonsolver=poissonsolver, hund=hund, mixer=mixer, maxiter=maxiter, txt=log_file_name, ) file1 = process_file(file_gpaw, path_to_move + "/") if file_gpaw_format == ".xyz": structure = extract_from_xyz(file1) elif file_gpaw_format == "bespoke.json": structure = extract_from_bespoke(file1) print("structure:", structure) lattice = bespoke_structure_to_ase(b_structure=structure) print("lattice", lattice) lattice.calc = calc energy = lattice.get_potential_energy() return energy