dralgroup / mlatom

AI-enhanced computational chemistry
http://mlatom.com
Other
59 stars 11 forks source link

something missing with the model KREG #20

Closed ilcpm closed 3 months ago

ilcpm commented 3 months ago

I am a beginner for mlatom. And now I have some problem run the example in the MLP tutorial

my code is just copied from the tutorial:

import mlatom as ml

molDB = ml.data.molecular_database.from_xyz_file(filename = 'H2.xyz')
molDB.add_scalar_properties_from_file('H2_HF.en', 'energy')
molDB.add_xyz_vectorial_properties_from_file('H2_HF.grad', 'energy_gradients')

# Here we define the KREG model for demonstration purposes as it is the fastest
model = ml.models.kreg(model_file='kreg.npz')

the first problem is that the data files contain different numbers of value: the H2.xyz has 361 values while the other two (H2_HF.en and H2_HF.grad) both have 451 values. so it results in the following error:

Traceback (most recent call last):
  File "/home/ilcpm/MD/mlp/testMLP.py", line 4, in <module>
    molDB.add_scalar_properties_from_file('H2_HF.en', 'energy')
  File "/home/ilcpm/.local/lib/python3.10/site-packages/mlatom/data.py", line 863, in add_scalar_properties_from_file
    self.molecules[ii].__dict__[property_name] = yy
IndexError: list index out of range

it can be solved by use the test_H2.xyz, test_H2_HF.en and test_H2_HF.grad, or just delete the values in H2_HF.en and H2_HF.grad.

then the biggest problem appears:

Traceback (most recent call last):
  File "/home/ilcpm/MD/mlp/testMLP.py", line 8, in <module>
    model = ml.models.kreg(model_file='kreg.npz')
  File "/home/ilcpm/.local/lib/python3.10/site-packages/mlatom/models.py", line 951, in __init__
    from .kreg_api import KREG_API
  File "/home/ilcpm/.local/lib/python3.10/site-packages/mlatom/kreg_api.py", line 5, in <module>
    from .fortran import KREG
ImportError: cannot import name 'KREG' from 'mlatom.fortran' (/home/ilcpm/.local/lib/python3.10/site-packages/mlatom/fortran/__init__.py)

it looks like there should be a python file named KREG.py in the folder mlatom/fortran, but I can't find it image


then I try to run the Command-line (input file)

my command is mlatom train_KREG.inp, it can be successfully finish and get the output then I found the following line in the output:

> /home/ilcpm/.local/lib/python3.10/site-packages/mlatom/MLatomF createMLmodel XYZfile=H2.xyz Yfile=H2_HF.en YgradXYZfile=H2_HF.grad MLmodelOut=kreg.unf sigma=1.0 lambda=1e-06

it seems that there is a binary executable program named MLatomF, so the missing of KREG.py didn't cause problem.

and the values in the three files are not equal:

 <!> File H2_HF.en contains 451 reference values
     but only first 361 will be used

    Charge        X            Y            Z
       1     0.000000     0.000000     0.000000
       1     0.000000     0.000000     1.350000

  Equilibrium distances: 
1     1-2      1.350000000000
 <!> File H2_HF.en contains 451 reference values
     but only first 361 will be used

 <!> File H2_HF.grad contains 451 reference values
     but only first 361 will be used
dralgroup commented 3 months ago

thank you for reporting these issues!

  1. H2.xyz file was indeed wrong - we reuploaded the correct H2.xyz in mlp.zip and updated the tutorial online.
  2. Also, we uploaded the missing file into PyPI repo, please run pip install --upgrade mlatom. That should solve all the issues with running the tutorial with the KREG model.
ilcpm commented 3 months ago

thanks for the reply, after updating, I fix some lib missing and finally it works (maybe these steps should be written in the docs, it's so difficult for beginners.)

dralgroup commented 3 months ago

sure, please let us know what libs where missing and we will update the docs

ilcpm commented 3 months ago

I find these libs from my command history

sudo apt install libomp-dev
sudo apt install libmkl-intel-lp64
sudo apt install libmkl-intel-thread
sudo apt install libmkl-core
dralgroup commented 3 months ago

thanks, updated the docs!