Skip to content

Commit

Permalink
Merge pull request #473 from amcadmus/master
Browse files Browse the repository at this point in the history
merge devel into master
  • Loading branch information
amcadmus committed Jul 20, 2021
2 parents cc816d5 + ea8a419 commit da49465
Show file tree
Hide file tree
Showing 143 changed files with 9,070 additions and 569 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/mirror_gitee.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Mirror to Gitee Repo

on: [ push, delete, create ]

# Ensures that only one mirror task will run at a time.
concurrency:
group: git-mirror

jobs:
git-mirror:
runs-on: ubuntu-latest
steps:
- uses: wearerequired/git-mirror-action@v1
env:
ORGANIZATION: deepmodeling
SSH_PRIVATE_KEY: ${{ secrets.SYNC_GITEE_PRIVATE_KEY }}
with:
source-repo: "git@github.com:deepmodeling/dpgen.git"
destination-repo: "git@gitee.com:deepmodeling/dpgen.git"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ dpgen.egg-info
dbconfig.json
.vscode/*
.idea/*
_build
284 changes: 199 additions & 85 deletions README.md

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 4 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# How to contribute

- If you want to add the documentation of a toy model, simply put your file in the directory doc/toymodels/ and push;
- If you want to add a new directory for a new category of instructions, make a new directory and add it in doc/index.rst.
80 changes: 80 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import subprocess
# import sys
import recommonmark
from recommonmark.transform import AutoStructify


# -- Project information -----------------------------------------------------

project = 'DPGEN'
copyright = '2020, Deep Potential'
author = 'Deep Potential'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# extensions = [
# 'recommonmark',
# "sphinx_rtd_theme",
# 'myst_parser',
# 'sphinx_markdown_tables',
# 'sphinx.ext.autosummary'
# ]

extensions = [
"sphinx_rtd_theme",
'myst_parser',
'sphinx.ext.autosummary',
]


# Tell sphinx what the primary language being documented is.
primary_domain = 'cpp'

# Tell sphinx what the pygments highlight language should be.
highlight_language = 'cpp'

#
myst_heading_anchors = 4

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']
# html_css_files = ['css/custom.css']

autodoc_default_flags = ['members']
autosummary_generate = True
master_doc = 'index'
28 changes: 28 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
==========================
DPGEN's documentation
==========================

.. _tutorial:

.. toctree::
:maxdepth: 2
:caption: Tutorial
:glob:

toymodels/*


.. _Contribution:

.. toctree::
:maxdepth: 2
:caption: Contribution Guild

README.md

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

.. _feedback:
.. _affiliated packages:
35 changes: 35 additions & 0 deletions doc/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
5 changes: 5 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sphinx==3.2.1
recommonmark==0.7.1
sphinx_rtd_theme==0.5.2
sphinx_markdown_tables==0.0.15
myst-parser==0.13.7
1 change: 1 addition & 0 deletions doc/toymodels/black.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a blank file to test sphinx-build
20 changes: 11 additions & 9 deletions dpgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ def info():
print('Date: ' + __date__)
print('Path: ' + ROOT_PATH)
print('')
# print('Dependency')
# print('------------')
# for modui in ['numpy', 'dpdata', 'pymatgen', 'monty', 'ase', 'paramiko', 'custodian' ]:
# try:
# mm = __import__(modui)
# print('%10s %10s %s' % (modui, mm.__version__, mm.__path__[0]))
# except ImportError:
# print('%10s %10s Not Found' % (modui, ''))
# print()
print('Dependency')
print('------------')
for modui in ['numpy', 'dpdata', 'pymatgen', 'monty', 'ase', 'paramiko', 'custodian' ]:
try:
mm = __import__(modui)
print('%10s %10s %s' % (modui, mm.__version__, mm.__path__[0]))
except ImportError:
print('%10s %10s Not Found' % (modui, ''))
except AttributeError:
print('%10s %10s unknown version or path' %(modui, ''))
print()

# reference
print("""Reference
Expand Down
6 changes: 3 additions & 3 deletions dpgen/auto_test/Surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ def _compute_lower(self,
ptr_data += "Miller_Indices: \tSurf_E(J/m^2) EpA(eV) equi_EpA(eV)\n"
for ii in all_tasks:
task_result = loadfn(os.path.join(ii, 'result_task.json'))
natoms = task_result['atom_numbs'][0]
epa = task_result['energies'][-1] / task_result['atom_numbs'][0]
natoms = np.sum(task_result['atom_numbs'])
epa = task_result['energies'][-1] / natoms
AA = np.linalg.norm(np.cross(task_result['cells'][0][0], task_result['cells'][0][1]))

equi_path = os.path.abspath(os.path.join(os.path.dirname(output_file), '../relaxation/relax_task'))
equi_result = loadfn(os.path.join(equi_path, 'result.json'))
equi_epa = equi_result['energies'][-1] / equi_result['atom_numbs'][0]
equi_epa = equi_result['energies'][-1] / np.sum(equi_result['atom_numbs'])
structure_dir = os.path.basename(ii)

Cf = 1.60217657e-16 / (1e-20 * 2) * 0.001
Expand Down
43 changes: 33 additions & 10 deletions dpgen/auto_test/common_equi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import glob
import os

import warnings
from monty.serialization import dumpfn

import dpgen.auto_test.lib.crys as crys
Expand All @@ -10,6 +10,8 @@
from dpgen.auto_test.mpdb import get_structure
from dpgen.dispatcher.Dispatcher import make_dispatcher
from dpgen.remote.decide_machine import decide_fp_machine, decide_model_devi_machine
from distutils.version import LooseVersion
from dpgen.dispatcher.Dispatcher import make_submission

lammps_task_type = ['deepmd', 'meam', 'eam_fs', 'eam_alloy']

Expand Down Expand Up @@ -149,23 +151,44 @@ def run_equi(confs,
if len(run_tasks) == 0:
return
else:
# if LooseVersion()
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))
for ii in range(len(work_path_list)):
work_path = work_path_list[ii]
disp = make_dispatcher(machine, resources, work_path, [run_tasks[ii]], 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_tasks[ii]],
group_size,
forward_common_files,
forward_files,
backward_files,
outlog='outlog',
errlog='errlog')
command,
work_path,
[run_tasks[ii]],
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_resource=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):
Expand Down
25 changes: 23 additions & 2 deletions dpgen/auto_test/common_prop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from distutils.version import LooseVersion
import glob
import os
import warnings
from multiprocessing import Pool
import dpgen.auto_test.lib.util as util
from dpgen import dlog
Expand All @@ -12,6 +14,7 @@
from dpgen.auto_test.calculator import make_calculator
from dpgen.dispatcher.Dispatcher import make_dispatcher
from dpgen.remote.decide_machine import decide_fp_machine, decide_model_devi_machine
from dpgen.dispatcher.Dispatcher import make_submission

lammps_task_type = ['deepmd', 'meam', 'eam_fs', 'eam_alloy']

Expand Down Expand Up @@ -196,7 +199,11 @@ def worker(work_path,
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)
disp.run_jobs(resources,
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_tasks,
Expand All @@ -206,7 +213,21 @@ def worker(work_path,
backward_files,
outlog='outlog',
errlog='errlog')

elif LooseVersion(api_version) >= LooseVersion('1.0'):
submission = make_submission(
mdata_machine=machine,
mdata_resource=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_property(confs,
# inter_param,
Expand Down

0 comments on commit da49465

Please sign in to comment.