bigd4 / PyNEP

A python interface of NEP
MIT License
46 stars 17 forks source link

ValueError: vector #1

Closed kkly1995 closed 2 years ago

kkly1995 commented 2 years ago

When attempting to load an ASE calculator for a particular water model, I get the following error:

In [1]: from pynep.calculate import NEP

In [2]: calc = NEP('nep.txt')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-746ad733c731> in <module>
----> 1 calc = NEP('nep.txt')

~/anaconda3/lib/python3.8/site-packages/pynep/calculate.py in __init__(self, model_file, **kwargs)
     16     def __init__(self, model_file="nep.txt", **kwargs) -> None:
     17         Calculator.__init__(self, **kwargs)
---> 18         self.calc = NepCalculator(model_file)
     19         self.type_dict = {e: i for i, e in enumerate(self.calc.info["element_list"])}
     20

ValueError: vector::_M_default_append

The model was constructed with GPUMD 3.2, here is a snippet of how nep.in was parsed:

Input or default parameters:
    (input)   use NEP version 3.
    (input)   number of atom types = 2.
        (default) type 0 (H with Z = 1) has force weight of 1.
        (default) type 1 (O with Z = 8) has force weight of 1.
    (default) will not add the ZBL potential.
    (input)   radial cutoff = 4.3 A.
    (input)   angular cutoff = 3 A.
    (default) n_max_radial = 8.
    (default) n_max_angular = 6.
    (default) l_max_3body = 4, l_max_4body = 0.
    (default) number of neurons = 50.
    (default) lambda_1 = 0.02.
    (default) lambda_2 = 0.02.
    (default) lambda_e = 1.
    (default) lambda_f = 1.
    (default) lambda_v = 0.1.
    (default) force_delta = 0.
    (input)   batch size = 2264.
    (default) population size = 50.
    (input)   maximum number of generations = 20000.
Some calculated parameters:
    number of radial descriptor components = 9.
    number of angualr descriptor components = 28.
    total number of  descriptor components = 37.
    NN architecture = 37-50-1.
    number of NN parameters to be optimized = 1951.
    number of descriptor parameters to be optimized = 576.
    total number of parameters to be optimized = 2527.

To be sure, the calculator works for some other models, e.g. the PbTe example model in GPUMD/examples/nep_potentials/PbTe/train. I'm not sure what the difference is with this new model that I have?

bigd4 commented 2 years ago

Could you please provide the nep.txt or just the the first few lines if it's not convenient to upload?

brucefan1983 commented 2 years ago

This is an expected error. PyNEP was developed for GPUMD-v3.3 and later versions. The nep.txt file format has been changed from GPUMD-v3.2 to GPUMD-v3.3. There are two ways to fix:

nep3 2 H O 
cutoff 4.3 3
n_max 8 6
basis_size 8 8
l_max 4 0 0

A side note: a radial cutoff of 4.3 A might be too small for water and I would try 5.5 A. I would also try a larger angular cutoff such as 3.5 A.

kkly1995 commented 2 years ago

Thank you, the basis_size line was indeed the missing link. I will update GPUMD on this machine. I will also try the larger cutoff, thank you for the suggestion.

brucefan1983 commented 2 years ago

You are welcome. Just to remind that there is also a change in the line starting with l_max, which requires 3 parameters in GPUMD-v3.3 and later but only 2 in GPUMD-v3.2.