Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge devel branch into master #690

Merged
merged 14 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ jobs:
repository: ${{ env.GITHUB_REPOSITORY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-to-pypi:
uses: deepmodeling/workflows/.github/workflows/release-to-pypi.yml@main
secrets:
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ If you want to specify a structure as starting point for `init_bulk`, you may se
"from_poscar": true,
"from_poscar_path": "....../C_mp-47_conventional.POSCAR",
```
`init_bulk` support both VASP and ABACUS for first-principle calculation. You can choose the software by specifying the key `init_fp_style`. If `init_fp_style` is not specified, the default software will be VASP.

When using ABACUS for `init_fp_style`, the keys of the paths of `INPUT` files for relaxation and MD simulations are the same as `INCAR` for VASP, which are `relax_incar` and `md_incar` respectively. You have to additionally specify `relax_kspacing` and `md_kspacing` for k points spacing, and dpgen will automatically generate `KPT` files according to them. You may also use `relax_kpt` and `md_kpt` instead of them for the relative path for `KPT` files of relaxation and MD simulations. However, either `relax_kspacing` and `md_kspacing`, or `relax_kpt` and `md_kpt` is needed. If `from_poscar` is set to `false`, you have to specify `atom_masses` in the same order as `elements`.

The following table gives explicit descriptions on keys in `PARAM`.

The bold notation of key (such as **Elements**) means that it's a necessary key.
Expand All @@ -200,9 +204,9 @@ The bold notation of key (such as **Elements**) means that it's a necessary key.
| cell_type | String | "hcp" | Specifying which typical structure to be generated. **Options** include fcc, hcp, bcc, sc, diamond.
| latt | Float | 4.479 | Lattice constant for single cell.
| from_poscar | Boolean | True | Deciding whether to use a given poscar as the beginning of relaxation. If it's true, keys (`cell_type`, `latt`) will be aborted. Otherwise, these two keys are **necessary**.
| from_poscar_path | String | "....../C_mp-47_conventional.POSCAR" | Path of POSCAR. **Necessary** if `from_poscar` is true.
| relax_incar | String | "....../INCAR" | Path of INCAR for relaxation in VASP. **Necessary** if `stages` include 1.
| md_incar | String | "....../INCAR" | Path of INCAR for MD in VASP. **Necessary** if `stages` include 3.|
| from_poscar_path | String | "....../C_mp-47_conventional.POSCAR" | Path of POSCAR for VASP or STRU for ABACUS. **Necessary** if `from_poscar` is true.
| relax_incar | String | "....../INCAR" | Path of INCAR for VASP or INPUT for ABACUS for relaxation in VASP. **Necessary** if `stages` include 1.
| md_incar | String | "....../INCAR" | Path of INCAR for VASP or INPUT for ABACUS for MD in VASP. **Necessary** if `stages` include 3.|
| **scale** | List of float | [0.980, 1.000, 1.020] | Scales for transforming cells.
| **skip_relax** | Boolean | False | If it's true, you may directly run stage 2 (pertub and scale) using an unrelaxed POSCAR.
| **pert_numb** | Integer | 30 | Number of pertubations for each POSCAR.
Expand All @@ -211,6 +215,12 @@ The bold notation of key (such as **Elements**) means that it's a necessary key.
| **md_nstep** | Integer | 10 | Steps of AIMD in stage 3. If it's not equal to settings via `NSW` in `md_incar`, DP-GEN will follow `NSW`.
| **coll_ndata** | Integer | 5000 | Maximal number of collected data.
| type_map | List | [ "Mg", "Al"] | The indices of elements in deepmd formats will be set in this order.
| init_fp_style | String | "ABACUS" or "VASP" | First-principle software. If this key is abscent, the default value will be "VASP".
| relax_kpt | String | "....../KPT" | Path of `KPT` file for relaxation in stage 1. Only useful if `init_fp_style` is "ABACUS".
| relax_kspacing | Integer or List of 3 integers | 10 | kspacing parameter for relaxation in stage 1. Only useful if `init_fp_style` is "ABACUS".
| md_kpt | String | "....../KPT" | Path of `KPT` file for MD simulations in stage 3. Only useful if `init_fp_style` is "ABACUS".
| md_kspacing | Integer or List of 3 integers | 10 | kspacing parameter for MD simulations in stage 3. Only useful if `init_fp_style` is "ABACUS".
| atom_masses | List of float | [24] | List of atomic masses of elements. The order should be the same as `Elements`. Only useful if `init_fp_style` is "ABACUS".

### Init_surf

Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# ]

extensions = [
'deepmodeling_sphinx',
"sphinx_rtd_theme",
'myst_parser',
'sphinx.ext.autosummary',
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ recommonmark==0.7.1
sphinx_rtd_theme==0.5.2
sphinx_markdown_tables==0.0.15
myst-parser==0.13.7
deepmodeling_sphinx
4 changes: 2 additions & 2 deletions dpgen/auto_test/EOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def _compute_lower(self,
# vol = self.vol_start + ii * self.vol_step
vol = loadfn(os.path.join(all_tasks[ii], 'eos.json'))['volume']
task_result = loadfn(all_res[ii])
res_data[vol] = task_result['energies'][-1] / task_result['atom_numbs'].sum()
ptr_data += '%7.3f %8.4f \n' % (vol, task_result['energies'][-1] / task_result['atom_numbs'].sum())
res_data[vol] = task_result['energies'][-1] / sum(task_result['atom_numbs'])
ptr_data += '%7.3f %8.4f \n' % (vol, task_result['energies'][-1] / sum(task_result['atom_numbs']))
# res_data[vol] = all_res[ii]['energy'] / len(all_res[ii]['force'])
# ptr_data += '%7.3f %8.4f \n' % (vol, all_res[ii]['energy'] / len(all_res[ii]['force']))

Expand Down
112 changes: 40 additions & 72 deletions dpgen/auto_test/common_equi.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,46 +114,6 @@ def make_equi(confs,
inter.make_input_file(ii, 'relaxation', relax_param)


def worker(work_path,
run_task,
forward_common_files,
forward_files,
backward_files,
mdata,
inter_type):
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
disp = make_dispatcher(machine, resources, work_path, [run_task], group_size)
print("%s --> Runing... " % (work_path))

api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
disp.run_jobs(resources,
command,
work_path,
[run_task],
group_size,
forward_common_files,
forward_files,
backward_files,
outlog='outlog',
errlog='errlog')
elif LooseVersion(api_version) >= LooseVersion('1.0'):
submission = make_submission(
mdata_machine=machine,
mdata_resources=resources,
commands=[command],
work_path=work_path,
run_tasks=run_task,
group_size=group_size,
forward_common_files=forward_common_files,
forward_files=forward_files,
backward_files=backward_files,
outlog='outlog',
errlog='errlog'
)
submission.run_submission()

def run_equi(confs,
inter_param,
Expand All @@ -166,18 +126,16 @@ def run_equi(confs,
conf_dirs.sort()

processes = len(conf_dirs)
pool = Pool(processes=processes)
print("Submit job via %d processes" % processes)

# generate a list of task names like mp-xxx/relaxation/relax_task
# ...
work_path_list = []
for ii in conf_dirs:
work_path_list.append(os.path.abspath(os.path.join(ii, 'relaxation')))
work_path_list.append(os.path.join(ii, 'relaxation'))
all_task = []
for ii in work_path_list:
all_task.append(os.path.join(ii, 'relax_task'))

run_tasks = all_task
inter_type = inter_param['type']
# vasp
if inter_type == "vasp":
Expand All @@ -186,41 +144,51 @@ def run_equi(confs,
mdata = convert_mdata(mdata, ["model_devi"])
else:
raise RuntimeError("unknown task %s, something wrong" % inter_type)

# dispatch the tasks
# POSCAR here is useless
virtual_calculator = make_calculator(inter_param, "POSCAR")
forward_files = virtual_calculator.forward_files()
forward_common_files = virtual_calculator.forward_common_files()
backward_files = virtual_calculator.backward_files()
# backward_files += logs
# ...
run_tasks = util.collect_task(all_task, inter_type)
if len(run_tasks) == 0:
return
else:
run_tasks = [os.path.basename(ii) for ii in all_task]
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
print('%d tasks will be submited '%len(run_tasks))
multiple_ret = []
for ii in range(len(work_path_list)):
work_path = work_path_list[ii]

ret = pool.apply_async(worker, (work_path,
run_tasks[ii],
forward_common_files,
forward_files,
backward_files,
mdata,
inter_type,
))
multiple_ret.append(ret)
pool.close()
pool.join()
for ii in range(len(multiple_ret)):
if not multiple_ret[ii].successful():
raise RuntimeError("Task %d is not successful! work_path: %s " % (ii, work_path_list[ii]))
print('finished')
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
work_path = os.getcwd()
print("%s --> Runing... " % (work_path))

api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
disp.run_jobs(resources,
command,
work_path,
run_tasks,
group_size,
forward_common_files,
forward_files,
backward_files,
outlog='outlog',
errlog='errlog')
elif LooseVersion(api_version) >= LooseVersion('1.0'):

submission = make_submission(
mdata_machine=machine,
mdata_resources=resources,
commands=[command],
work_path=work_path,
run_tasks=run_tasks,
group_size=group_size,
forward_common_files=forward_common_files,
forward_files=forward_files,
backward_files=backward_files,
outlog='outlog',
errlog='errlog'
)
submission.run_submission()



def post_equi(confs, inter_param):
# find all POSCARs and their name like mp-xxx
Expand Down
3 changes: 2 additions & 1 deletion dpgen/auto_test/common_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def run_property(confs,
pool.join()
for ii in range(len(multiple_ret)):
if not multiple_ret[ii].successful():
print("ERROR:", multiple_ret[ii].get())
raise RuntimeError("Job %d is not successful!" % ii)
print('%d jobs are finished' % len(multiple_ret))

Expand All @@ -186,11 +187,11 @@ def worker(work_path,
inter_type):
run_tasks = [os.path.basename(ii) for ii in all_task]
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
disp.run_jobs(resources,
command,
work_path,
Expand Down
2 changes: 2 additions & 0 deletions dpgen/auto_test/lib/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ def make_lammps_equi(conf, type_map, interaction, param,
ret += "fix 1 all box/relax iso 0.0 \n"
ret += "minimize %e %e %d %d\n" % (etol, ftol, maxiter, maxeval)
ret += "fix 1 all box/relax aniso 0.0 \n"
ret += "minimize %e %e %d %d\n" % (etol, ftol, maxiter, maxeval)
ret += "fix 1 all box/relax tri 0.0 \n"
ret += "minimize %e %e %d %d\n" % (etol, ftol, maxiter, maxeval)
ret += "variable N equal count(all)\n"
ret += "variable V equal vol\n"
Expand Down
Loading