|
| 1 | +(inputscript)= |
| 2 | +# Guide on writing input scripts for dpgen2 commands |
| 3 | + |
| 4 | +## Preliminaries |
| 5 | + |
| 6 | +The reader of this doc is assumed to be familiar with the concurrent learning algorithm that the dpgen2 implements. If not, one may check [this paper](https://doi.org/10.1016/j.cpc.2020.107206). |
| 7 | + |
| 8 | +## The input script for all dpgen2 commands |
| 9 | + |
| 10 | +For all the dpgen2 commands, one need to provide `dflow2` global configurations. For example, |
| 11 | +```json |
| 12 | + "dflow_config" : { |
| 13 | + "host" : "http://address.of.the.host:port" |
| 14 | + }, |
| 15 | + "dflow_s3_config" : { |
| 16 | + "s3_endpoint" : "address.of.the.s3.sever:port" |
| 17 | + }, |
| 18 | +``` |
| 19 | +The `dpgen` simply pass all keys of `"dflow_config"` to `dflow.config` and all keys of `"dflow_s3_config"` to `dflow.s3_config`. |
| 20 | + |
| 21 | + |
| 22 | +## The input script for `submit` and `resubmit` |
| 23 | + |
| 24 | +The full documentation of the `submit` and `resubmit` script can be [found here](submitargs). This documentation provides a fast guide on how to write the input script. |
| 25 | + |
| 26 | +In the input script of `dpgen2 submit` and `dpgen2 resubmit`, one needs to provide the definition of the workflow and how they are executed in the input script. One may find an example input script in the [dpgen2 Al-Mg alloy example](../examples/almg/input.json). |
| 27 | + |
| 28 | +The definition of the workflow can be provided by the following sections: |
| 29 | + |
| 30 | +### Inputs |
| 31 | + |
| 32 | +This section provides the inputs to start a dpgen2 workflow. An example for the Al-Mg alloy |
| 33 | +```json |
| 34 | +"inputs": { |
| 35 | + "type_map": ["Al", "Mg"], |
| 36 | + "mass_map": [27, 24], |
| 37 | + "init_data_sys": [ |
| 38 | + "path/to/init/data/system/0", |
| 39 | + "path/to/init/data/system/1" |
| 40 | + ], |
| 41 | +} |
| 42 | +``` |
| 43 | +The key `"init_data_sys"` provides the initial training data to kick-off the training of deep potential (DP) models. |
| 44 | + |
| 45 | + |
| 46 | +### Training |
| 47 | + |
| 48 | +This section defines how a model is trained. |
| 49 | +```json |
| 50 | +"train" : { |
| 51 | + "type" : "dp", |
| 52 | + "numb_models" : 4, |
| 53 | + "config" : {}, |
| 54 | + "template_script" : { |
| 55 | + "_comment" : "omitted content of tempalte script" |
| 56 | + }, |
| 57 | + "_comment" : "all" |
| 58 | +} |
| 59 | +``` |
| 60 | +The `"type" : "dp"` tell the traning method is `"dp"`, i.e. calling [DeePMD-kit](https://github.com/deepmodeling/deepmd-kit) to train DP models. |
| 61 | +The `"config"` key defines the training configs, see [the full documentation](rundptrainargs). |
| 62 | +The `"template_script"` provides the template training script in `json` format. |
| 63 | + |
| 64 | + |
| 65 | +### Exploration |
| 66 | + |
| 67 | +This section defines how the configuration space is explored. |
| 68 | +```json |
| 69 | +"explore" : { |
| 70 | + "type" : "lmp", |
| 71 | + "config" : { |
| 72 | + "command": "lmp -var restart 0" |
| 73 | + }, |
| 74 | + "max_numb_iter" : 5, |
| 75 | + "conv_accuracy" : 0.9, |
| 76 | + "fatal_at_max" : false, |
| 77 | + "f_trust_lo": 0.05, |
| 78 | + "f_trust_hi": 0.50, |
| 79 | + "configurations": [ |
| 80 | + { |
| 81 | + "lattice" : ["fcc", 4.57], |
| 82 | + "replicate" : [2, 2, 2], |
| 83 | + "numb_confs" : 30, |
| 84 | + "concentration" : [[1.0, 0.0], [0.5, 0.5], [0.0, 1.0]] |
| 85 | + } |
| 86 | + { |
| 87 | + "lattice" : ["fcc", 4.57], |
| 88 | + "replicate" : [3, 3, 3], |
| 89 | + "numb_confs" : 30, |
| 90 | + "concentration" : [[1.0, 0.0], [0.5, 0.5], [0.0, 1.0]] |
| 91 | + } |
| 92 | + ], |
| 93 | + "stages": [ |
| 94 | + { "_idx": 0, "ensemble": "nvt", "nsteps": 20, "press": null, "conf_idx": [0], "temps": [50,100], "trj_freq": 10, "n_sample" : 3 }, |
| 95 | + { "_idx": 1, "ensemble": "nvt", "nsteps": 20, "press": null, "conf_idx": [1], "temps": [50,100], "trj_freq": 10, "n_sample" : 3 } |
| 96 | + ], |
| 97 | +} |
| 98 | +``` |
| 99 | +The `"type" : "lmp"` means that configurations are explored by LAMMPS DPMD runs. |
| 100 | +The `"config"` key defines the lmp configs, see [the full documentation](runlmpargs). |
| 101 | +The `"configurations"` provides the initial configurations (coordinates of atoms and the simulation cell) of the DPMD simulations. It is a list. The elements of the list can be |
| 102 | + |
| 103 | +- `list[str]`: The strings provides the path to the configuration files. |
| 104 | +- `dict`: Automatic alloy configuration generator. See [the detailed doc](alloy_configs) of the allowed keys. |
| 105 | + |
| 106 | +The `"stages"` defines the exploration stages. It is a list of `dict`s, with each `dict` defining a stage. The `"ensemble"`, `"nsteps"`, `"press"`, `"temps"`, `"traj_freq"` keys are self-explanatory. `"conf_idx"` pickes initial configurations of DPMD simulations from the `"configurations"` list, it provides the index of the element in the `"configurations"` list. `"n_sample"` tells the number of confgiruations randomly sampled from the set picked by `"conf_idx"` for each thermodynamic state. All configurations picked by `"conf_idx"` has the same possibility to be sampled. The default value of `"n_sample"` is `null`, in this case all picked configurations are sampled. In the example, each stage have 3 samples and 2 thermodynamic states (NVT, T=50 and 100K), then each iteration run 3x2=6 NVT DPMD simulatins. |
| 107 | + |
| 108 | + |
| 109 | +### FP |
| 110 | + |
| 111 | +This section defines the first-principle (FP) calculation . |
| 112 | + |
| 113 | +```json |
| 114 | +"fp" : { |
| 115 | + "type" : "vasp", |
| 116 | + "config" : { |
| 117 | + "command": "source /opt/intel/oneapi/setvars.sh && mpirun -n 16 vasp_std" |
| 118 | + }, |
| 119 | + "task_max": 2, |
| 120 | + "pp_files": {"Al" : "vasp/POTCAR.Al", "Mg" : "vasp/POTCAR.Mg"}, |
| 121 | + "incar": "vasp/INCAR", |
| 122 | + "_comment" : "all" |
| 123 | +} |
| 124 | +``` |
| 125 | +The `"type" : "vasp"` means that first-principles are VASP calculations. |
| 126 | +The `"config"` key defines the vasp configs, see [the full documentation](runvaspargs). |
| 127 | +The `"task_max"` key defines the maximal number of vasp calculations in each dpgen2 iteration. |
| 128 | +The `"pp_files"` and `"incar"` keys provides the pseudopotential files and the template incar file. |
| 129 | + |
| 130 | + |
| 131 | +### Configuration of dflow step |
| 132 | + |
| 133 | +The execution units of the dpgen2 are the dflow `Step`s. How each step is executed is defined by the `"step_configs"`. |
| 134 | +```json |
| 135 | +"step_configs":{ |
| 136 | + "prep_train_config" : { |
| 137 | + "_comment" : "content omitted" |
| 138 | + }, |
| 139 | + "run_train_config" : { |
| 140 | + "_comment" : "content omitted" |
| 141 | + }, |
| 142 | + "prep_explore_config" : { |
| 143 | + "_comment" : "content omitted" |
| 144 | + }, |
| 145 | + "run_explore_config" : { |
| 146 | + "_comment" : "content omitted" |
| 147 | + }, |
| 148 | + "prep_fp_config" : { |
| 149 | + "_comment" : "content omitted" |
| 150 | + }, |
| 151 | + "run_fp_config" : { |
| 152 | + "_comment" : "content omitted" |
| 153 | + }, |
| 154 | + "select_confs_config" : { |
| 155 | + "_comment" : "content omitted" |
| 156 | + }, |
| 157 | + "collect_data_config" : { |
| 158 | + "_comment" : "content omitted" |
| 159 | + }, |
| 160 | + "cl_step_config" : { |
| 161 | + "_comment" : "content omitted" |
| 162 | + }, |
| 163 | + "_comment" : "all" |
| 164 | +}, |
| 165 | +``` |
| 166 | +The configs for prepare training, run training, prepare exploration, run exploration, prepare fp, run fp, select configurations, collect data and concurrent learning steps are given correspondingly. |
| 167 | + |
| 168 | +The readers are refered to [this page](stepconfigargs) for a full documentation of the step configs. |
| 169 | + |
| 170 | +Any of the config in the `step_configs` can be ommitted. If so, the configs of the step is set to the default step configs, which is provided by the following section, for example, |
| 171 | +```json |
| 172 | +"default_step_config" : { |
| 173 | + "template_config" : { |
| 174 | + "image" : "dpgen2:x.x.x" |
| 175 | + } |
| 176 | +}, |
| 177 | +``` |
| 178 | +The way of writing the `default_step_config` is the same as any step config in the `step_configs`. One may refer to [this page](stepconfigargs) for full documentation. |
0 commit comments