Different fingerprints for the same atom
Closed this issue · 8 comments
Hi,
I used the fingerprinting scheme from SIMPLE-NN but I think there could be an issue in the calculate_sf function. For an ASE atoms generated from the following code
from ase.build import bulk atoms = bulk('Cu').repeat((3,3,3))
all the atoms are identical. As a result, the fingerprints for each atom in the atoms should be the same. However, the fingerprints generated from SIMPLE-NN for each atom are different.
Specifically, I used one G2 with eta = 0.05, and cutoff = 6. The values look like the following:
tensor([[8.0695],
[8.0042],
[7.6038],
[7.9458],
[7.9850],
[7.7613],
[8.0695],
[7.9335],
[7.8366],
[7.9458],
[7.9850],
[7.7613],
[7.8221],
[7.9995],
[7.8896],
[7.7130],
[8.0187],
[7.9795],
[8.0695],
[7.9335],
[7.8366],
[7.7130],
[8.0187],
[7.9795],
[7.8366],
[7.9335],
[8.0695]], requires_grad=True)
Any idea what could lead to this problem? Thanks!
Best,
Mingjie
Hi, Mingjie
Unfortunately, I failed to reproduce your results.
I made the structure through the below code.
from ase import io
from ase.build import bulk
atoms = bulk("Cu")
atoms *= (3, 3, 3)
io.write("POSCAR", atoms)
After calculating the symmetry function, I found that values:
array([[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222],
[8.06950222]])
Please check your structure or setting and inform me of your details.
Best,
Jisu
Hi Jisu,
Thank you for the reply! I have been interfacing the SIMPLE-NN fingerprinting code with PyTorch and it could be due to problems there. I installed the SIMPLE-NN and tried to reproduce what you have. However, I have some questions regarding running the code.
I would like to get the fingerprints for the bulk Cu. However, I am not sure how to get it.
#input.yaml
generate_features: true
preprocess: true
train_model: true
atom_types:
- Cu`
symmetry_function:
params:
Cu: params_Cu
neural_network:
method: Adam
nodes: 30-30
batch_size: 1
total_iteration: 1
learning_rate: 0.001
# script used to generate the atoms
from ase import io
from ase.build import bulk
from ase.calculators.emt import EMT
atoms = bulk("Cu")
atoms *= (3, 3, 3)
atoms.set_calculator(EMT())
atoms.get_potential_energy()
io.write("POSCAR", atoms)
#params_Cu
2 1 0 6.0 0.05 0.0 0.0
#str_list
POSCAR ::1
#run.py
from simple_nn import Simple_nn
from simple_nn.features.symmetry_function import Symmetry_function
from simple_nn.models.neural_network import Neural_network
model = Simple_nn('input.yaml', descriptor=Symmetry_function(), model=Neural_network())
model.run()
I tried to do python run.py but getting the following errors
Traceback (most recent call last):
File "run.py", line 10, in <module>
model.run()
File "C:\Users\lmj\AppData\Roaming\Python\Python36\site-packages\simple_nn-20.2-py3.6-win-amd64.egg\simple_nn\__init__.py", line 185, in run
self.descriptor.generate()
File "C:\Users\lmj\AppData\Roaming\Python\Python36\site-packages\simple_nn-20.2-py3.6-win-amd64.egg\simple_nn\features\symmetry_function\__init__.py", line 562, in generate
snapshots = io.read(tmp_name, index=index, format=self.inputs['refdata_format'])
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\io\formats.py", line 680, in read
**kwargs))
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\parallel.py", line 273, in new_generator
for result in generator(*args, **kwargs):
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\io\formats.py", line 749, in _iread
for dct in io.read(fd, *args, **kwargs):
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\io\formats.py", line 505, in wrap_read_function
for atoms in read(filename, index, **kwargs):
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\utils\__init__.py", line 455, in iofunc
obj = func(fd, *args, **kwargs)
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\io\vasp.py", line 266, in read_vasp_out
return list(g)
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\io\utils.py", line 245, in __call__
for chunk in self._getslice(fd, index):
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\io\vasp_parsers\vasp_outcar_parsers.py", line 678, in outcarchunks
lines = build_header(fd)
File "c:\users\lmj\anaconda3\envs\simplenn\lib\site-packages\ase\io\vasp_parsers\vasp_outcar_parsers.py", line 650, in build_header
raise ParseError('Incomplete OUTCAR')
ase.io.ParseError: Incomplete OUTCAR
It will be really appreciated if you can show me an example of how to configure the input files and then get the fingerprints of the atoms from the program. Thank you very much!
Best,
Mingjie
I write down the only different points of my input files from your input.yaml.
generate_feature: true
preprocess: false
train: false
symmetry_function:
refdata_format: vasp
remain_pickle: true
As you can see, this input file focus on calculating only the symmetry function for a check.
We cannot train the neural network potential by poscar
file.
After running code with the above input file, you can find out the pickle
file in the data
directory.
The values of the symmetry function are saved in that file.
Best,
Jisu
Thanks for the reply!
I used your input file but still getting errors:
Traceback (most recent call last):
File "run.py", line 10, in <module>
model.run()
File "C:\Users\lmj\AppData\Roaming\Python\Python36\site-packages\simple_nn-20.2-py3.6-win-amd64.egg\simple_nn\__init__.py", line 189, in run
**self.descriptor.inputs['atomic_weights']['params'])
File "C:\Users\lmj\AppData\Roaming\Python\Python36\site-packages\simple_nn-20.2-py3.6-win-amd64.egg\simple_nn\features\symmetry_function\__init__.py", line 451, in preprocess
self._write_tfrecords(tmp_res, writer, atomic_weights=aw_tag)
File "C:\Users\lmj\AppData\Roaming\Python\Python36\site-packages\simple_nn-20.2-py3.6-win-amd64.egg\simple_nn\features\symmetry_function\__init__.py", line 89, in _write_tfrecords
'E':_bytes_feature(np.array([res['E']]).tobytes()),
KeyError: 'E'
Despite this error, I do get the pickle file in data
directory. However, when I try to load it, I get the following error:
Traceback (most recent call last):
File "read.py", line 3, in <module>
data = pickle.load(open('./data/data1.pickle'))
File "C:\Users\lmj\Anaconda3\envs\simpleNN\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 229: character maps to <undefined>
Do you use a specific encoding method? I have tried utf-8
but it does not work either.
Best,
Mingjie
Please forget about the first error. It does not affect our results and will be updated soon.
Second, the pickle file is a binary format. Open with rb
tag.
Best,
Jisu
Hi Jisu,
Thanks. This is very helpful! However, using the pickle file, the fingerprint I got is exactly the same as the one I reported. I have made some modifications to the symmetry_functions.h to get away with the compiling errors, but I don't think they should affect the result. Specifically, the modifications are
adding
#define _USE_MATH_DEFINES
because the compiler is complaining about M_PI not defined.
and replacing
sincos(M_PI*frac, &sin, &cos)
sin=1;cos=0
The second modification will change the da
but should not affect x
and dx
.
Are you using a version that is different from the one in this repo?
Thank you very much!
Best,
Mingjie
{'x': {'Cu': array([[8.06950222],
[8.00422679],
[7.60378377],
[7.94581888],
[7.98501495],
[7.76131243],
[8.06950222],
[7.93347457],
[7.836643 ],
[7.94581888],
[7.98501495],
[7.76131243],
[7.82213554],
[7.9995224 ],
[7.88957412],
[7.71295966],
[8.01873424],
[7.97953817],
[8.06950222],
[7.93347457],
[7.836643 ],
[7.71295966],
[8.01873424],
[7.97953817],
[7.836643 ],
[7.93347457],
[8.06950222]])}, 'dx': {'Cu': array([[[[-4.54497551e-16, -2.67147415e-16, 4.86249588e-17],
[-1.82286709e-01, -1.82286709e-01, 5.51778076e-17],
[ 1.82286709e-01, 1.82286709e-01, 1.10355597e-16],
...,
[ 4.16333634e-17, 4.16333634e-17, 1.38777878e-17],
[ 9.99241497e-18, 1.21430643e-17, 1.83368900e-01],
[ 1.38777878e-17, 1.38777878e-17, 1.38777878e-17]]],
[[[ 1.82286709e-01, 1.82286709e-01, -5.51778076e-17],
[-5.39411617e-02, -5.39411617e-02, 9.71618213e-02],
[-1.82286709e-01, -1.82286709e-01, 5.51777897e-17],
...,
[ 4.05405341e-02, 4.05405341e-02, -8.10810681e-02],
[ 5.55111512e-17, 5.55111512e-17, 0.00000000e+00],
[ 1.24727637e-17, 1.21430643e-17, 1.83368900e-01]]],
[[[-1.82286709e-01, -1.82286709e-01, -1.10355597e-16],
[ 1.82286709e-01, 1.82286709e-01, -5.51777897e-17],
[ 1.83880688e-16, 3.85108612e-16, 4.79161961e-01],
...,
[-6.69948168e-17, -6.76542156e-17, 1.83368900e-01],
[ 0.00000000e+00, 0.00000000e+00, 6.93889390e-17],
[ 5.55111512e-17, 5.55111512e-17, 6.93889390e-17]]],
...,
[[[-4.16333634e-17, -4.16333634e-17, -1.38777878e-17],
[-4.05405341e-02, -4.05405341e-02, 8.10810681e-02],
[ 6.74047656e-17, 6.80641644e-17, -1.83368900e-01],
...,
[ 2.39580981e-01, 2.39580981e-01, -2.39580981e-01],
[-2.10275629e-01, -2.10275629e-01, 0.00000000e+00],
[ 1.82286709e-01, 1.82286709e-01, 0.00000000e+00]]],
[[[-1.09072408e-17, -1.13231667e-17, -1.83368900e-01],
[-4.16333634e-17, -4.16333634e-17, 2.77555756e-17],
[ 3.46944695e-17, 3.46944695e-17, -1.66533454e-16],
...,
[ 2.10275629e-01, 2.10275629e-01, 0.00000000e+00],
[-1.49610522e-01, -1.49610522e-01, 8.10810681e-02],
[-1.82286709e-01, -1.82286709e-01, 0.00000000e+00]]],
[[[-1.38777878e-17, -1.38777878e-17, -1.38777878e-17],
[ 0.00000000e+00, 0.00000000e+00, -1.83368900e-01],
[-2.77555756e-17, -2.77555756e-17, 2.77555756e-17],
...,
[-1.82286709e-01, -1.82286709e-01, 0.00000000e+00],
[ 1.82286709e-01, 1.82286709e-01, 0.00000000e+00],
[ 8.25728375e-16, 4.78783679e-16, -1.23512311e-15]]]])}, 'da': {'Cu': array([[[[ 0. , -0.0143996 , -0.0143996 , 0.0143996 ,
-0.0143996 , 0. ],
[-0.0143996 , 0. , -0.0143996 , 0. ,
0.0143996 , -0.0143996 ],
[-0.0143996 , -0.0143996 , 0. , -0.0143996 ,
0. , 0.0143996 ]]],
[[[ 0. , -0.0146148 , -0.01380164, 0.01410824,
-0.0146148 , 0. ],
[-0.0146148 , 0. , -0.01380164, 0. ,
0.01410824, -0.01380164],
[-0.0137864 , -0.0137864 , 0. , -0.0137864 ,
0. , 0.01329507]]],
[[[ 0. , -0.01051425, -0.01207599, 0.01051425,
-0.01051425, 0. ],
[-0.01051425, 0. , -0.01207599, 0. ,
0.01051425, -0.01207599],
[-0.01363772, -0.01363772, 0. , -0.01363772,
0. , 0.01207599]]],
[[[ 0. , -0.01384734, -0.01458433, 0.01415394,
-0.01384734, 0. ],
[-0.01341694, 0. , -0.01292561, 0. ,
0.01292561, -0.01292561],
[-0.01489093, -0.01366261, 0. , -0.01489093,
0. , 0.01366261]]],
[[[ 0. , -0.01455387, -0.014093 , 0.01366453,
-0.01455387, 0. ],
[-0.0141254 , 0. , -0.01382245, 0. ,
0.01382245, -0.01382245],
[-0.01320367, -0.01336159, 0. , -0.01320367,
0. , 0.01336159]]],
[[[ 0. , -0.01144563, -0.01190649, 0.0112152 ,
-0.01144563, 0. ],
[-0.01199789, 0. , -0.01402049, 0. ,
0.01277693, -0.01402049],
[-0.0132378 , -0.01479953, 0. , -0.0132378 ,
0. , 0.0132378 ]]],
[[[ 0. , -0.0143996 , -0.0143996 , 0.0143996 ,
-0.0143996 , 0. ],
[-0.0143996 , 0. , -0.0143996 , 0. ,
0.0143996 , -0.0143996 ],
[-0.0143996 , -0.0143996 , 0. , -0.0143996 ,
0. , 0.0143996 ]]],
[[[ 0. , -0.01486047, -0.01339013, 0.01339013,
-0.01486047, 0. ],
[-0.01463003, 0. , -0.01393874, 0. ,
0.01416917, -0.01393874],
[-0.01269884, -0.01347788, 0. , -0.01269884,
0. , 0.01269884]]],
[[[ 0. , -0.01167606, -0.01167606, 0.01167606,
-0.01167606, 0. ],
[-0.0132378 , 0. , -0.01479953, 0. ,
0.0132378 , -0.01479953],
[-0.0132378 , -0.01479953, 0. , -0.0132378 ,
0. , 0.0132378 ]]],
[[[ 0. , -0.01341694, -0.01292561, 0.01292561,
-0.01341694, 0. ],
[-0.01384734, 0. , -0.01458433, 0. ,
0.01415394, -0.01458433],
[-0.01366261, -0.01489093, 0. , -0.01366261,
0. , 0.01366261]]],
[[[ 0. , -0.0141254 , -0.01382245, 0.01382245,
-0.0141254 , 0. ],
[-0.01455387, 0. , -0.014093 , 0. ,
0.01366453, -0.014093 ],
[-0.01336159, -0.01320367, 0. , -0.01336159,
0. , 0.01336159]]],
[[[ 0. , -0.01199789, -0.01402049, 0.01277693,
-0.01199789, 0. ],
[-0.01144563, 0. , -0.01190649, 0. ,
0.0112152 , -0.01190649],
[-0.01479953, -0.0132378 , 0. , -0.01479953,
0. , 0.0132378 ]]],
[[[ 0. , -0.01286468, -0.01311034, 0.01267995,
-0.01286468, 0. ],
[-0.01286468, 0. , -0.01311034, 0. ,
0.01267995, -0.01311034],
[-0.01415394, -0.01415394, 0. , -0.01415394,
0. , 0.01292561]]],
[[[ 0. , -0.01411016, -0.01358045, 0.01338241,
-0.01411016, 0. ],
[-0.01411016, 0. , -0.01358045, 0. ,
0.01338241, -0.01358045],
[-0.01347381, -0.01347381, 0. , -0.01347381,
0. , 0.01285269]]],
[[[ 0. , -0.01229292, -0.013851 , 0.01284153,
-0.01229292, 0. ],
[-0.01229292, 0. , -0.013851 , 0. ,
0.01284153, -0.013851 ],
[-0.0143996 , -0.0143996 , 0. , -0.0143996 ,
0. , 0.0143996 ]]],
[[[ 0. , -0.01381687, -0.01176381, 0.01176381,
-0.01381687, 0. ],
[-0.01424727, 0. , -0.01342253, 0. ,
0.01299213, -0.01342253],
[-0.01093907, -0.01216739, 0. , -0.01093907,
0. , 0.01093907]]],
[[[ 0. , -0.0141711 , -0.01351951, 0.01359568,
-0.0141711 , 0. ],
[-0.01436914, 0. , -0.01433867, 0. ,
0.0142168 , -0.01433867],
[-0.0132775 , -0.01389862, 0. , -0.0132775 ,
0. , 0.01356521]]],
[[[ 0. , -0.01284153, -0.01362056, 0.01362056,
-0.01284153, 0. ],
[-0.013851 , 0. , -0.01463003, 0. ,
0.01362056, -0.01463003],
[-0.0143996 , -0.0143996 , 0. , -0.0143996 ,
0. , 0.0143996 ]]],
[[[ 0. , -0.0143996 , -0.0143996 , 0.0143996 ,
-0.0143996 , 0. ],
[-0.0143996 , 0. , -0.0143996 , 0. ,
0.0143996 , -0.0143996 ],
[-0.0143996 , -0.0143996 , 0. , -0.0143996 ,
0. , 0.0143996 ]]],
[[[ 0. , -0.01463003, -0.01393874, 0.01416917,
-0.01463003, 0. ],
[-0.01486047, 0. , -0.01339013, 0. ,
0.01339013, -0.01339013],
[-0.01347788, -0.01269884, 0. , -0.01347788,
0. , 0.01269884]]],
[[[ 0. , -0.0132378 , -0.01479953, 0.0132378 ,
-0.0132378 , 0. ],
[-0.01167606, 0. , -0.01167606, 0. ,
0.01167606, -0.01167606],
[-0.01479953, -0.0132378 , 0. , -0.01479953,
0. , 0.0132378 ]]],
[[[ 0. , -0.01424727, -0.01342253, 0.01299213,
-0.01424727, 0. ],
[-0.01381687, 0. , -0.01176381, 0. ,
0.01176381, -0.01176381],
[-0.01216739, -0.01093907, 0. , -0.01216739,
0. , 0.01093907]]],
[[[ 0. , -0.01436914, -0.01433867, 0.0142168 ,
-0.01436914, 0. ],
[-0.0141711 , 0. , -0.01351951, 0. ,
0.01359568, -0.01351951],
[-0.01389862, -0.0132775 , 0. , -0.01389862,
0. , 0.01356521]]],
[[[ 0. , -0.013851 , -0.01463003, 0.01362056,
-0.013851 , 0. ],
[-0.01284153, 0. , -0.01362056, 0. ,
0.01362056, -0.01362056],
[-0.0143996 , -0.0143996 , 0. , -0.0143996 ,
0. , 0.0143996 ]]],
[[[ 0. , -0.01479953, -0.0132378 , 0.0132378 ,
-0.01479953, 0. ],
[-0.01479953, 0. , -0.0132378 , 0. ,
0.0132378 , -0.0132378 ],
[-0.01167606, -0.01167606, 0. , -0.01167606,
0. , 0.01167606]]],
[[[ 0. , -0.01463003, -0.01416917, 0.01393874,
-0.01463003, 0. ],
[-0.01463003, 0. , -0.01416917, 0. ,
0.01393874, -0.01416917],
[-0.01269884, -0.01269884, 0. , -0.01269884,
0. , 0.01347788]]],
[[[ 0. , -0.0143996 , -0.0143996 , 0.0143996 ,
-0.0143996 , 0. ],
[-0.0143996 , 0. , -0.0143996 , 0. ,
0.0143996 , -0.0143996 ],
[-0.0143996 , -0.0143996 , 0. , -0.0143996 ,
0. , 0.0143996 ]]]])}, 'params': {'Cu': array([[2. , 1. , 0. , 6. , 0.05, 0. , 0. ]])}, 'N': {'Cu': 27}, 'tot_num': 27, 'partition': array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1]), 'struct_type': 'None', 'struct_weight': 1.0, 'atom_idx': array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1]), 'partition_Cu': array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1])}
da
is probably wrong but this others should be correct.
Hi Jisu,
I figure out that it is actually due to the ase version. I was using ase==3.21. When I changed it to 3.17, I got the same result as you did. It is due to the inconsistency of atoms.get_positions()
and atoms.get_scaled_positions()
.
Thanks!
Best,
Mingjie