Spaces:
Runtime error
Runtime error
File size: 2,077 Bytes
1c703f0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
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
|