deepmodeling / deepmd-kit

A deep learning package for many-body potential energy representation and molecular dynamics
https://docs.deepmodeling.com/projects/deepmd/
GNU Lesser General Public License v3.0
1.45k stars 499 forks source link

ntypes error #261

Closed Xi-yuanWang closed 3 years ago

Xi-yuanWang commented 3 years ago

I set the typemap in param.json as ["Co","Ni"], and use a dataset of bulk Ni. Then ntypes error happens!

Traceback (most recent call last):
  File "/nfs-share/home/1800011848/miniconda3/bin/dp", line 10, in <module>
    sys.exit(main())
  File "/nfs-share/home/1800011848/miniconda3/lib/python3.8/site-packages/deepmd/main.py", line 66, in main
    train(args)
  File "/nfs-share/home/1800011848/miniconda3/lib/python3.8/site-packages/deepmd/train.py", line 81, in train
    _do_work(jdata, run_opt)
  File "/nfs-share/home/1800011848/miniconda3/lib/python3.8/site-packages/deepmd/train.py", line 134, in _do_work
    model.build (data, stop_batch)
  File "/nfs-share/home/1800011848/miniconda3/lib/python3.8/site-packages/deepmd/Trainer.py", line 209, in build
    assert (self.ntypes == data.get_ntypes()), "ntypes should match that found in data"
AssertionError: ntypes should match that found in data

And the same param works well when using a alloy dataset( all type.raw have two elements)

njzjz commented 3 years ago

Does sel in your parameters contain 2 values? https://github.com/deepmodeling/deepmd-kit/blob/59d780c77aaf0c0692d1bb56a630c50bc987ea13/examples/water/train/water_se_a.json#L4-L7

Xi-yuanWang commented 3 years ago

Yes, and here is my param.json and dataset. error.zip

njzjz commented 3 years ago

Creating a file error/0/system/type_map.raw can solve the problem:

Co
Ni

I am marking this issue as a bug and would like to discuss whether we need to solve the problem without type_map.raw. Thanks!