Skip to content

Commit

Permalink
add simplify jdata docs; fix and check example
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz committed Jul 7, 2022
1 parent adb261d commit 34aac74
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 10 deletions.
6 changes: 6 additions & 0 deletions doc/simplify/simplify-jdata.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dpgen simplify parameters
=========================

.. dargs::
:module: dpgen.simplify.arginfo
:func: simplify_jdata_arginfo
107 changes: 105 additions & 2 deletions dpgen/simplify/arginfo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,113 @@
from dargs import Argument
from typing import List
from dargs import Argument, Variant

from dpgen.arginfo import general_mdata_arginfo
from dpgen.generator.arginfo import (
basic_args,
data_args,
training_args,
fp_style_vasp_args,
fp_style_gaussian_args,
)


def general_simplify_arginfo() -> Argument:
"""General simplify arginfo.
Returns
-------
Argument
arginfo
"""
doc_labeled = "If true, the initial data is labeled."
doc_pick_data = "Path to the directory with the pick data with the deepmd/npy format. Systems are detected recursively."
doc_init_pick_number = "The number of initial pick data."
doc_iter_pick_number = "The number of pick data in each iteration."
doc_model_devi_f_trust_lo = "The lower bound of forces for the selection for the model deviation."
doc_model_devi_f_trust_hi = "The higher bound of forces for the selection for the model deviation."

return [
Argument("labeled", bool, optional=False, default=False, doc=doc_labeled),
Argument("pick_data", str, doc=doc_pick_data),
Argument("init_pick_number", int, doc=doc_init_pick_number),
Argument("iter_pick_number", int, doc=doc_iter_pick_number),
Argument("model_devi_f_trust_lo", float, optional=False, doc=doc_model_devi_f_trust_lo),
Argument("model_devi_f_trust_hi", float, optional=False, doc=doc_model_devi_f_trust_hi),
]


def fp_style_variant_type_args() -> Variant:
"""Generate variant for fp style variant type.
Returns
-------
Variant
variant for fp style
"""
doc_fp_style = 'Software for First Principles, if `labeled` is false. Options include “vasp”, “gaussian” up to now.'
doc_fp_style_none = 'No fp.'
doc_fp_style_vasp = 'VASP.'
doc_fp_style_gaussian = 'Gaussian. The command should be set as `g16 < input`.'

return Variant("fp_style", [
Argument("none", dict, doc=doc_fp_style_none),
# simplify use the same fp method as run
Argument("vasp", dict, fp_style_vasp_args(), doc=doc_fp_style_vasp),
Argument("gaussian", dict, fp_style_gaussian_args(),
doc=doc_fp_style_gaussian),
],
optional=True,
default_tag="none",
doc=doc_fp_style)


def fp_args() -> List[Argument]:
"""Generate arginfo for fp.
Returns
-------
List[Argument]
arginfo
"""
doc_fp_task_max = 'Maximum of structures to be calculated in 02.fp of each iteration.'
doc_fp_task_min = 'Minimum of structures to be calculated in 02.fp of each iteration.'

return [
Argument("fp_task_max", int, optional=True, doc=doc_fp_task_max),
Argument("fp_task_min", int, optional=True, doc=doc_fp_task_min),
]


def simplify_jdata_arginfo() -> Argument:
"""Generate arginfo for dpgen simplify jdata.
Returns
-------
Argument
arginfo
"""
doc_run_jdata = "Parameters for simplify.json, the first argument of `dpgen simplify`."
return Argument("simplify_jdata",
dict,
sub_fields=[
*basic_args(),
# TODO: we may remove sys_configs; it is required in train method
*data_args(),
*general_simplify_arginfo(),
# simplify use the same training method as run
*training_args(),
*fp_args(),
],
sub_variants=[
fp_style_variant_type_args(),
],
doc=doc_run_jdata,
)


def simplify_mdata_arginfo() -> Argument:
"""Generate arginfo for dpgen simplify mdata.
Returns
-------
Argument
Expand Down
10 changes: 2 additions & 8 deletions examples/simplify/qm7.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"auto"
],
"numb_models": 4,
"train_param": "input.json",
"default_training_param": {
"model": {
"type_map": [
Expand Down Expand Up @@ -92,11 +91,8 @@
},
"use_clusters": true,
"fp_style": "gaussian",
"shuffle_poscar": false,
"fp_task_max": 1000,
"fp_task_min": 10,
"fp_pp_path": "/home/jzzeng/",
"fp_pp_files": [],
"fp_params": {
"keywords": "mn15/6-31g** force nosymm scf(maxcyc=512)",
"nproc": 28,
Expand All @@ -105,9 +101,7 @@
},
"init_pick_number":100,
"iter_pick_number":100,
"e_trust_lo":1e10,
"e_trust_hi":1e10,
"f_trust_lo":0.25,
"f_trust_hi":0.45,
"model_devi_f_trust_lo":0.10,
"model_devi_f_trust_hi":0.30,
"_comment": " that's all "
}
5 changes: 5 additions & 0 deletions tests/test_check_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
from dpgen.data.arginfo import (
init_reaction_jdata_arginfo,
)
from dpgen.simplify.arginfo import (
simplify_jdata_arginfo,
)

init_reaction_jdata = init_reaction_jdata_arginfo()
simplify_jdata = simplify_jdata_arginfo()

# directory of examples
p_examples = Path(__file__).parent.parent / "examples"
Expand All @@ -19,6 +23,7 @@
# tuple of example list
input_files = (
(init_reaction_jdata, p_examples / "init" / "reaction.json"),
(simplify_jdata, p_examples / "simplify" / "qm7.json"),
)


Expand Down

0 comments on commit 34aac74

Please sign in to comment.