materialsvirtuallab / maml

Python for Materials Machine Learning, Materials Descriptors, Machine Learning Force Fields, Deep Learning, etc.
BSD 3-Clause "New" or "Revised" License
342 stars 73 forks source link

Running error in the mtp example in notebook #601

Open tomblister opened 4 months ago

tomblister commented 4 months ago

Email (Optional)

tomblister@gmail.com

Version

v2023.9.9

Which OS(es) are you using?

What happened?

Dear Sir, I was running through the pes examples in the notebook of maml. However, when I ran the following step in the mtp example:

mtp.train( train_structures=train_structures, train_energies=train_energies, train_forces=train_forces, train_stresses=None, max_dist=5, stress_weight=0, )

the following returned:

**INFO:maml.utils._lammps:Structure index 0 is rotated. INFO:maml.utils._lammps:Structure index 1 is rotated. INFO:maml.utils._lammps:Structure index 2 is rotated. INFO:maml.utils._lammps:Structure index 3 is rotated. INFO:maml.utils._lammps:Structure index 4 is rotated. INFO:maml.utils._lammps:Structure index 5 is rotated. INFO:maml.utils._lammps:Structure index 6 is rotated. INFO:maml.utils._lammps:Structure index 7 is rotated. INFO:maml.utils._lammps:Structure index 8 is rotated. INFO:maml.utils._lammps:Structure index 9 is rotated.

ValueError Traceback (most recent call last) Cell In[3], line 1 ----> 1 mtp.train( 2 train_structures=train_structures, 3 train_energies=train_energies, 4 train_forces=train_forces, 5 train_stresses=None, 6 max_dist=5, 7 stress_weight=0, 8 )

File /opt/anaconda3/envs/myenv/lib/python3.8/site-packages/maml/apps/pes/_mtp.py:602, in MTPotential.train(self, train_structures, train_energies, train_forces, train_stresses, unfitted_mtp, max_dist, radial_basis_size, max_iter, energy_weight, force_weight, stress_weight, init_params, scale_by_force, bfgs_conv_tol, weighting) 600 with open("min_dist") as f: 601 lines = f.readlines() --> 602 min_dist = float(lines[-1].split(":")[1]) 604 with open(unfitted_mtp) as f: 605 template = f.read()

ValueError: could not convert string to float: ' command mindist does not exist.\n'

I could not find the "min_dist" in the example. Could you please offer me some help on this issue? Thank you!

Code snippet

mtp.train(
    train_structures=train_structures,
    train_energies=train_energies,
    train_forces=train_forces,
    train_stresses=None,
    max_dist=5,
    stress_weight=0,
)

Log output

INFO:maml.utils._lammps:Structure index 0 is rotated.
INFO:maml.utils._lammps:Structure index 1 is rotated.
INFO:maml.utils._lammps:Structure index 2 is rotated.
INFO:maml.utils._lammps:Structure index 3 is rotated.
INFO:maml.utils._lammps:Structure index 4 is rotated.
INFO:maml.utils._lammps:Structure index 5 is rotated.
INFO:maml.utils._lammps:Structure index 6 is rotated.
INFO:maml.utils._lammps:Structure index 7 is rotated.
INFO:maml.utils._lammps:Structure index 8 is rotated.
INFO:maml.utils._lammps:Structure index 9 is rotated.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[3], line 1
----> 1 mtp.train(
      2     train_structures=train_structures,
      3     train_energies=train_energies,
      4     train_forces=train_forces,
      5     train_stresses=None,
      6     max_dist=5,
      7     stress_weight=0,
      8 )

File /opt/anaconda3/envs/myenv/lib/python3.8/site-packages/maml/apps/pes/_mtp.py:602, in MTPotential.train(self, train_structures, train_energies, train_forces, train_stresses, unfitted_mtp, max_dist, radial_basis_size, max_iter, energy_weight, force_weight, stress_weight, init_params, scale_by_force, bfgs_conv_tol, weighting)
    600 with open("min_dist") as f:
    601     lines = f.readlines()
--> 602 min_dist = float(lines[-1].split(":")[1])
    604 with open(unfitted_mtp) as f:
    605     template = f.read()

ValueError: could not convert string to float: ' command mindist does not exist.\n'

Code of Conduct

zz11ss11zz commented 2 months ago

@tomblister Hi, could you check which version of the mlip package you are using? This maml is suited for mlip-2. The min_dist is generated in a temporary file during the code running and this file will be deleted after the code finishes running.