Skip to content

Commit

Permalink
update deepmd input to v2; format JSON files (#1315)
Browse files Browse the repository at this point in the history
This PR updates all JSON files:
- convert `default_training_param` to v2 format
- format JSON files
- update `_comment` to `_commentN` to avoid duplicated keys
- enable `check-json` and `pretty-format-json` hooks

```py
import json
from glob import glob

from deepmd.utils.compat import update_deepmd_input, convert_input_v1_v2

for ii in glob("**/*.json", recursive=True):
    with open(ii) as f:
        content = f.read()
    count = 1
    while True:
        if r'"_comment"' not in content:
            break
        content = content.replace('"_comment"', '"_comment%d"' % count, 1)
        count += 1
    try:
        jdata = json.loads(content)
    except Exception as e:
        print(ii, e)
        continue
    if "default_training_param" in jdata:
        jdata["default_training_param"] = update_deepmd_input(
            jdata["default_training_param"], warning=False)
        if "decay_rate" in jdata["default_training_param"]["learning_rate"]:
            jdata["default_training_param"] = convert_input_v1_v2(
                jdata["default_training_param"], warning=False)
        if "load_ckpt" in jdata["default_training_param"]["training"]:
            del jdata["default_training_param"]["training"]["load_ckpt"]
    content = json.dumps(jdata, indent=2)

    with open(ii, "w") as f:
        f.write(content)
```

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] committed Aug 28, 2023
1 parent 0761763 commit 2a25606
Show file tree
Hide file tree
Showing 184 changed files with 13,612 additions and 7,972 deletions.
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ repos:
exclude: "^tests/.*$"
- id: check-yaml
exclude: "^conda/.*$"
#- id: check-json
- id: check-json
exclude: "^examples/CH4-lebesgue/.*$"
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
exclude: "^tests/tools/run_report_test_output/.*$"
- id: check-toml
- id: pretty-format-json
args:
- "--autofix"
- "--no-sort-keys"
- "--indent=4"
exclude: "^examples/CH4-lebesgue/.*$"

# Python
- repo: https://github.com/psf/black
rev: 23.7.0
Expand Down
5 changes: 2 additions & 3 deletions doc/simplify/simplify.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Here is an example of `param.json` for QM7 dataset:
"learning_rate": {
"type": "exp",
"start_lr": 0.001,
"decay_steps": 10,
"stop_lr": 5e-8,
"decay_rate": 0.99
},
"loss": {
Expand All @@ -85,12 +85,11 @@ Here is an example of `param.json` for QM7 dataset:
},
"training": {
"set_prefix": "set",
"stop_batch": 10000,
"numb_steps": 10000,
"disp_file": "lcurve.out",
"disp_freq": 1000,
"numb_test": 1,
"save_freq": 1000,
"save_ckpt": "model.ckpt",
"disp_training": true,
"time_training": true,
"profiling": false,
Expand Down
54 changes: 34 additions & 20 deletions dpgen/data/jsons/al.diamond.111.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
{
"cell_type": "diamond",
"latt": 2.5,
"super_cell": [1, 1, 1],
"elements": ["Al"],
"potcars": ["/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.08,
"kgamma": false,
"scale": [0.96, 0.98, 1.00, 1.02, 1.04, 1.06],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../generator/template/",
"coll_ndata": 5000,
"_comment": "that's all"
"cell_type": "diamond",
"latt": 2.5,
"super_cell": [
1,
1,
1
],
"elements": [
"Al"
],
"potcars": [
"/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.08,
"kgamma": false,
"scale": [
0.96,
0.98,
1.0,
1.02,
1.04,
1.06
],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../generator/template/",
"coll_ndata": 5000,
"_comment1": "that's all"
}
54 changes: 34 additions & 20 deletions dpgen/data/jsons/al.diamond.222.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
{
"cell_type": "diamond",
"latt": 2.5,
"super_cell": [2, 2, 2],
"elements": ["Al"],
"potcars": ["/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.08,
"kgamma": false,
"scale": [0.96, 0.98, 1.00, 1.02, 1.04, 1.06],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment": "that's all"
"cell_type": "diamond",
"latt": 2.5,
"super_cell": [
2,
2,
2
],
"elements": [
"Al"
],
"potcars": [
"/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.08,
"kgamma": false,
"scale": [
0.96,
0.98,
1.0,
1.02,
1.04,
1.06
],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment1": "that's all"
}
54 changes: 34 additions & 20 deletions dpgen/data/jsons/al.fcc.111.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
{
"cell_type": "fcc",
"latt": 4.04,
"super_cell": [1, 1, 1],
"elements": ["Al"],
"potcars": ["/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [0.96, 0.98, 1.00, 1.02, 1.04, 1.06],
"skip_relax": true,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment": "that's all"
"cell_type": "fcc",
"latt": 4.04,
"super_cell": [
1,
1,
1
],
"elements": [
"Al"
],
"potcars": [
"/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [
0.96,
0.98,
1.0,
1.02,
1.04,
1.06
],
"skip_relax": true,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment1": "that's all"
}
54 changes: 34 additions & 20 deletions dpgen/data/jsons/al.fcc.222.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
{
"cell_type": "fcc",
"latt": 4.04,
"super_cell": [2, 2, 2],
"elements": ["Al"],
"potcars": ["/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [0.96, 0.98, 1.00, 1.02, 1.04, 1.06],
"skip_relax": true,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment": "that's all"
"cell_type": "fcc",
"latt": 4.04,
"super_cell": [
2,
2,
2
],
"elements": [
"Al"
],
"potcars": [
"/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [
0.96,
0.98,
1.0,
1.02,
1.04,
1.06
],
"skip_relax": true,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment1": "that's all"
}
54 changes: 34 additions & 20 deletions dpgen/data/jsons/al.hcp.111.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
{
"cell_type": "hcp",
"latt": 4.04,
"super_cell": [1, 1, 1],
"elements": ["Al"],
"potcars": ["/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [0.96, 0.98, 1.00, 1.02, 1.04, 1.06],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment": "that's all"
"cell_type": "hcp",
"latt": 4.04,
"super_cell": [
1,
1,
1
],
"elements": [
"Al"
],
"potcars": [
"/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [
0.96,
0.98,
1.0,
1.02,
1.04,
1.06
],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment1": "that's all"
}
54 changes: 34 additions & 20 deletions dpgen/data/jsons/al.hcp.222.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
{
"cell_type": "hcp",
"latt": 4.04,
"super_cell": [2, 2, 2],
"elements": ["Al"],
"potcars": ["/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [0.96, 0.98, 1.00, 1.02, 1.04, 1.06],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment": "that's all"
"cell_type": "hcp",
"latt": 4.04,
"super_cell": [
2,
2,
2
],
"elements": [
"Al"
],
"potcars": [
"/home/wanghan/Soft/vasp/potcar.unknown/potpaw_PBE/Al/POTCAR"
],
"encut": 600,
"kspacing_relax": 0.16,
"kspacing_md": 0.06,
"kgamma": false,
"scale": [
0.96,
0.98,
1.0,
1.02,
1.04,
1.06
],
"skip_relax": false,
"pert_numb": 100,
"pert_box": 0.03,
"pert_atom": 0.01,
"md_temp": 100,
"md_nstep": 10,
"deepgen_templ": "../template/",
"coll_ndata": 5000,
"_comment1": "that's all"
}

0 comments on commit 2a25606

Please sign in to comment.