Skip to content

Commit

Permalink
BUG FIX in loading kpoints.npy files with ndim==3 (deepmodeling#20)
Browse files Browse the repository at this point in the history
* bug fix in loading `kpoints.npy` files with `ndim==3`

* added tests for nnsk training

* main program for test_train
  • Loading branch information
SharpLonde authored Feb 1, 2024
1 parent e4ff19f commit c4b586e
Show file tree
Hide file tree
Showing 19 changed files with 369 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ asserts
*.css
band.png
*.pth
*.npy
*.traj
*.dat
*.vasp
#*.npy
#*.traj
#*.dat
#*.vasp
*log*
checkpoint.pl
# Byte-compiled / optimized / DLL files
Expand Down
2 changes: 1 addition & 1 deletion dptb/data/dataset/_default_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __init__(self,
kpoints = np.expand_dims(kpoints, axis=0)
self.data["kpoints"] = np.broadcast_to(kpoints, (self.info["nframes"],
kpoints.shape[1], 3))
if kpoints.shape[0] == self.info["nframes"]:
elif kpoints.ndim == 3 and kpoints.shape[0] == self.info["nframes"]:
# array of kpoints, (nframes, nkpoints, 3)
self.data["kpoints"] = kpoints
else:
Expand Down
Binary file not shown.
19 changes: 19 additions & 0 deletions dptb/tests/data/test_data_nequip/dataset/kpath_spk.0/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"nframes": 1,
"natoms": 2,
"pos_type": "ase",
"AtomicData_options": {
"r_max": 5.0,
"er_max": 5.0,
"oer_max": 2.5,
"pbc": true
},
"bandinfo": {
"nkpoints": 61,
"nbands": 14,
"band_min": 0,
"band_max": 6,
"emin": null,
"emax": null
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions dptb/tests/data/test_data_nequip/dataset/kpathmd25.0/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"nframes": 10,
"natoms": 8,
"pos_type": "ase",
"AtomicData_options": {
"r_max": 5.0,
"er_max": 5.0,
"oer_max": 2.5,
"pbc": true
},
"bandinfo": {
"band_min": 0,
"band_max": 8,
"emin": null,
"emax": null
}
}
Binary file not shown.
16 changes: 16 additions & 0 deletions dptb/tests/data/test_data_nequip/dataset/kpathmd25.0/struct.vasp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Si
1.0000000000000000
5.4300150871000001 0.0000000000000000 0.0000000000000000
0.0000000000000000 5.4300150871000001 0.0000000000000000
0.0000000000000000 0.0000000000000000 5.4300150871000001
Si
8
Cartesian
0.0264071000000000 5.4365699999999997 5.4306599999999996
2.7157399999999998 2.7145600000000001 5.4341600000000003
2.6988300000000001 0.0021865800000000 2.7229999999999999
-0.0085004700000000 2.6946599999999998 2.7118500000000001
1.3702900000000000 1.3672899999999999 1.3587400000000001
4.0686400000000003 4.0873600000000003 1.3605700000000001
4.0663099999999996 1.3515699999999999 4.0690799999999996
1.3523300000000000 4.0658700000000003 4.0620099999999999
Binary file not shown.
54 changes: 54 additions & 0 deletions dptb/tests/data/test_data_nequip/input/input_dptb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"common_options": {
"basis": {
"Si": ["3s", "3p", "d*"]
},
"device": "cpu",
"dtype": "float32",
"overlap": false
},
"train_options": {
"num_epoch": 1500,
"batch_size": 1,
"optimizer": {
"lr": 0.001,
"type": "Adam"
},
"lr_scheduler": {
"type": "exp",
"gamma": 0.999
},
"loss_options":{
"train": {"method": "eigvals"}
},
"save_freq": 500,
"validation_freq": 10,
"display_freq": 100
},
"model_options": {
"embedding":{
"method": "se2",
"rs": 2.5,
"rc": 5.0,
"radial_net": {
"neurons": [10,20,30]
}
},
"prediction":{
"method": "sktb",
"neurons": [16,16,16]
},
"nnsk": {
"onsite": {"method": "strain", "rs":2.5 ,"w":0.3},
"hopping": {"method": "powerlaw", "rs":5.0, "w": 0.1},
"freeze": true
}
},
"data_options": {
"train": {
"root": "./data/",
"prefix": "kpath_spk",
"get_eigenvalues": true
}
}
}
42 changes: 42 additions & 0 deletions dptb/tests/data/test_data_nequip/input/input_md.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"common_options": {
"basis": {
"Si": ["3s", "3p", "d*"]
},
"device": "cpu",
"dtype": "float32",
"overlap": false
},
"train_options": {
"num_epoch": 2,
"batch_size": 1,
"optimizer": {
"lr": 0.01,
"type": "Adam"
},
"lr_scheduler": {
"type": "exp",
"gamma": 0.999
},
"loss_options":{
"train": {"method": "eigvals"}
},
"save_freq": 500,
"validation_freq": 10,
"display_freq": 100
},
"model_options": {
"nnsk": {
"onsite": {"method": "strain", "rs":2.5 ,"w":0.3},
"hopping": {"method": "powerlaw", "rs":2.6, "w": 0.35},
"freeze": false
}
},
"data_options": {
"train": {
"root": "./dptb/tests/data/test_data_nequip/dataset/",
"prefix": "kpathmd25",
"get_eigenvalues": true
}
}
}
42 changes: 42 additions & 0 deletions dptb/tests/data/test_data_nequip/input/input_push_rs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"common_options": {
"basis": {
"Si": ["3s", "3p", "d*"]
},
"device": "cpu",
"dtype": "float32",
"overlap": false
},
"train_options": {
"num_epoch": 10,
"batch_size": 1,
"optimizer": {
"lr": 0.01,
"type": "Adam"
},
"lr_scheduler": {
"type": "exp",
"gamma": 0.999
},
"loss_options":{
"train": {"method": "eigvals"}
},
"save_freq": 1,
"display_freq": 100
},
"model_options": {
"nnsk": {
"onsite": {"method": "strain", "rs":2.5 ,"w":0.3},
"hopping": {"method": "powerlaw", "rs":2.6, "w": 0.3},
"freeze": false,
"push": {"rs_thr": 0.01, "period": 1}
}
},
"data_options": {
"train": {
"root": "./dptb/tests/data/test_data_nequip/dataset/",
"prefix": "kpath_spk",
"get_eigenvalues": true
}
}
}
42 changes: 42 additions & 0 deletions dptb/tests/data/test_data_nequip/input/input_push_w.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"common_options": {
"basis": {
"Si": ["3s", "3p", "d*"]
},
"device": "cpu",
"dtype": "float32",
"overlap": false
},
"train_options": {
"num_epoch": 10,
"batch_size": 1,
"optimizer": {
"lr": 0.05,
"type": "Adam"
},
"lr_scheduler": {
"type": "exp",
"gamma": 0.999
},
"loss_options":{
"train": {"method": "eigvals"}
},
"save_freq": 1,
"display_freq": 100
},
"model_options": {
"nnsk": {
"onsite": {"method": "strain", "rs":2.5 ,"w":0.3},
"hopping": {"method": "powerlaw", "rs":5.0, "w": 0.3},
"freeze": false,
"push": {"w_thr": 0.01, "period": 1}
}
},
"data_options": {
"train": {
"root": "./dptb/tests/data/test_data_nequip/dataset/",
"prefix": "kpath_spk",
"get_eigenvalues": true
}
}
}
41 changes: 41 additions & 0 deletions dptb/tests/data/test_data_nequip/input/input_strain_polar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"common_options": {
"basis": {
"Si": ["3s", "3p", "d*"]
},
"device": "cpu",
"dtype": "float32",
"overlap": false
},
"train_options": {
"num_epoch": 5,
"batch_size": 1,
"optimizer": {
"lr": 0.05,
"type": "Adam"
},
"lr_scheduler": {
"type": "exp",
"gamma": 0.999
},
"loss_options":{
"train": {"method": "eigvals"}
},
"save_freq": 1,
"display_freq": 100
},
"model_options": {
"nnsk": {
"onsite": {"method": "strain", "rs":2.5 ,"w":0.3},
"hopping": {"method": "powerlaw", "rs":2.6, "w": 0.3},
"freeze": false
}
},
"data_options": {
"train": {
"root": "./dptb/tests/data/test_data_nequip/dataset/",
"prefix": "kpath_spk",
"get_eigenvalues": true
}
}
}
42 changes: 42 additions & 0 deletions dptb/tests/data/test_data_nequip/input/input_valence.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"common_options": {
"basis": {
"Si": ["3s", "3p"]
},
"device": "cpu",
"dtype": "float32",
"overlap": false,
"seed": 120468
},
"train_options": {
"num_epoch": 5,
"batch_size": 1,
"optimizer": {
"lr": 0.05,
"type": "Adam"
},
"lr_scheduler": {
"type": "exp",
"gamma": 0.999
},
"loss_options":{
"train": {"method": "eigvals"}
},
"save_freq": 1,
"display_freq": 10
},
"model_options": {
"nnsk": {
"onsite": {"method": "none"},
"hopping": {"method": "powerlaw", "rs":2.6, "w": 0.3},
"freeze": false
}
},
"data_options": {
"train": {
"root": "./dptb/tests/data/test_data_nequip/dataset/",
"prefix": "kpath_spk",
"get_eigenvalues": true
}
}
}
Loading

0 comments on commit c4b586e

Please sign in to comment.