openkim / kim-query

Other
1 stars 0 forks source link

a0 = get_lattice_constant_cubic([model], ["fcc"], ["Al"], ["angstrom"])[0] does not give number #3

Closed miroi closed 2 months ago

miroi commented 3 months ago

Hello, for the demonstration code from https://openkim.org/doc/usage/using-models/#ASE :

#!/usr/bin/env python3
#  Cohesive energy calculation for fcc aluminum with query to openkim.org for lattice constant
"""
Compute the cohesive energy and pressure of an FCC Al crystal using the
Ercolessi-Adams EAM potential implemented as a Portable Model (PM) in
OpenKIM for the equilibrium lattice constant obtained by querying openkim.org.
"""
from ase.calculators.kim import KIM
from ase.lattice.cubic import FaceCenteredCubic
from ase.units import GPa
from kim_query import get_lattice_constant_cubic

model = "EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005"

# Perform query to get lattice constant for this model
print("doing query to get lattice constant for this model=",model)
a0 = get_lattice_constant_cubic([model], ["fcc"], ["Al"], ["angstrom"])[0]
print("obtained a0=",a0)

# Set up crystal and calculator
atoms = FaceCenteredCubic("Al", latticeconstant=a0)
calc = KIM(model)
atoms.set_calculator(calc)

# Compute energy/pressure
ecoh = -atoms.get_potential_energy() / len(atoms)
stress = atoms.get_stress()
pressure_MPa = (-sum(stress[:3]) / 3.0) * 1e3 / GPa

print("Computed cohesive energy of {:.3f} eV/atom (experiment: 3.39 eV/atom)".format(ecoh))
print("Computed pressure of {} MPa".format(pressure_MPa))

I couldn't get the a0 - lattice constant

python3 coh_en2.py
doing query to get lattice constant for this model= EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005
obtained a0= {
Traceback (most recent call last):
  File "/mnt/c/Users/milias/Documents/git-projects/open-collection/theoretical_chemistry/software/openkim/buildup_on_servers/jinr_ru/wsl_win10_pc7321b/cohesive_energy_fcc_aluminium/coh_en2.py", line 21, in <module>
    atoms = FaceCenteredCubic("Al", latticeconstant=a0)
  File "/home/milias/.local/lib/python3.10/site-packages/ase/lattice/bravais.py", line 79, in __call__
    self.make_crystal_basis()
  File "/home/milias/.local/lib/python3.10/site-packages/ase/lattice/cubic.py", line 47, in make_crystal_basis
    self.crystal_basis = (self.latticeconstant * self.basis_factor
TypeError: can't multiply sequence by non-int of type 'float'
miroi commented 3 months ago

And I have

pip show kim-query
Name: kim-query
Version: 3.0.0
Summary: Helper routines for querying the OpenKIM Repository
Home-page: https://github.com/openkim/kim-query
Author: Daniel S. Karls
Author-email: karl0100@umn.edu
License: CDDL
Location: /home/milias/.local/lib/python3.10/site-packages
Requires: requests
Required-by:
dskarls commented 3 months ago

Similar to #2, this could be caused by a database connectivity problem on the backend that has been resolved. Can you try again and let me know if it works?

miroi commented 2 months ago

Fine, this works now !

python3 coh_en2.py
doing query to get lattice constant for this model= EAM_Dynamo_ErcolessiAdams_1994_Al__MO_123629422045_005
obtained a0= 4.032082033157349
Computed cohesive energy of 3.360 eV/atom (experiment: 3.39 eV/atom)
Computed pressure of -0.0036923616494566416 MPa

You can close this issue if nobody complains.