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

Calypso #663

Merged
merged 41 commits into from
Apr 20, 2022
Merged

Calypso #663

merged 41 commits into from
Apr 20, 2022

Conversation

wangzyphysics
Copy link
Contributor

  1. reorganize code structure
  2. add unitteset
  3. give some necessary explainations about new keys
  4. fix pbs script of gpu : from '#PBS -l nodes=%d:ppn=%d:gpus=%d\n' to '#PBS -l select=%d:ncpus=%d:ngpus=%d\n'

amcadmus and others added 25 commits August 27, 2021 21:56
fix typo in github actions release to conda
Change-Id: I17774bee345634e4e72bd783e8112eefaaf9f0d3

Co-authored-by: Zhengju Sha <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Mar 13, 2022

Codecov Report

Merging #663 (43ef866) into devel (6de10d0) will increase coverage by 0.13%.
The diff coverage is 35.93%.

@@            Coverage Diff             @@
##            devel     #663      +/-   ##
==========================================
+ Coverage   33.16%   33.30%   +0.13%     
==========================================
  Files          86       92       +6     
  Lines       14837    16270    +1433     
==========================================
+ Hits         4921     5418     +497     
- Misses       9916    10852     +936     
Impacted Files Coverage Δ
dpgen/auto_test/EOS.py 64.70% <0.00%> (ø)
dpgen/data/tools/bcc.py 21.05% <ø> (ø)
dpgen/data/tools/create_random_disturb.py 0.00% <0.00%> (ø)
dpgen/data/tools/diamond.py 20.00% <ø> (ø)
dpgen/data/tools/fcc.py 100.00% <ø> (ø)
dpgen/data/tools/hcp.py 20.00% <ø> (ø)
dpgen/data/tools/sc.py 22.22% <ø> (ø)
dpgen/generator/lib/calypso_check_outcar.py 0.00% <0.00%> (ø)
dpgen/generator/lib/calypso_run_model_devi.py 0.00% <0.00%> (ø)
dpgen/generator/lib/calypso_run_opt.py 0.00% <0.00%> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6de10d0...43ef866. Read the comment docs.

@AnguseZhang
Copy link
Collaborator

@amcadmus Should I start the code review?

@wanghan-iapcm
Copy link
Contributor

@amcadmus Should I start the code review?

No. I have personally contacted the contributor to clarify how to improve the PR.

@amcadmus amcadmus requested a review from AnguseZhang March 20, 2022 03:42
@@ -94,7 +94,7 @@ def sub_script_head(self, res):
if res['numb_gpu'] == 0:
ret += '#PBS -l nodes=%d:ppn=%d\n' % (res['numb_node'], res['task_per_node'])
else :
ret += '#PBS -l nodes=%d:ppn=%d:gpus=%d\n' % (res['numb_node'], res['task_per_node'], res['numb_gpu'])
ret += '#PBS -l select=%d:ncpus=%d:ngpus=%d\n' % (res['numb_node'], res['task_per_node'], res['numb_gpu'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not recommend change the PBS resource list here. Moreover, it is better to use deepmodeling/dpdispatcher package instead of the dispatcher in dpgen.

f.close()
os.chdir(cwd)

def Analysis(iter_index,jdata,calypso_run_opt_path,calypso_model_devi_path):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function names should be in lower case. Analysis -> analysis

calypso_run_opt_name = 'gen_stru_analy'
calypso_model_devi_name = 'model_devi_results'

def GenStructures(iter_index,jdata,mdata):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function names should be in lower case. GenStructures -> gen_structures

@@ -0,0 +1,424 @@
"""
calypso model devi:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend changing the name of the file to "model_devi_calypso.py", so the name is self-explanatory. modd is not a standard abbreviation in dpgen.

return devi


def Modd(all_models,type_map):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function names should be in lower case. Modd -> model_devi

return devi


def Modd(all_models,type_map):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that Modd only works for the case of calypso. Please move it to module model_devi_calypso

if model_devi_engine != 'calypso':
sys_batch_size = ["auto" for aa in range(len(jdata['sys_configs']))]
else:
sys_batch_size = ["auto" for aa in range(3000)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the "3000" come from?

else:
try:
maxiter = max(model_devi_jobs[-1].get('times'))
except Exception as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to specify which exception you want to catch.

all_sys.append(_sys)
try:
all_sys.append(_sys)
except:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to specify which exception you want to catch.

try:
all_sys.append(_sys)
except:
dlog.info('%s has different formula, so pass in line 3518'%oo)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a good idea to hard coding the line number.

Please check the solutions : https://stackoverflow.com/questions/3056048/filename-and-line-number-of-python-script

@wangzyphysics wangzyphysics requested a review from amcadmus March 22, 2022 08:13
Copy link
Collaborator

@AnguseZhang AnguseZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wangzyphysics @wanghan-iapcm Please see my comments. Actually I have a lot of concerns. We may have a talk if necessary.

README.md Outdated
@@ -378,7 +378,7 @@ In each iteration, there are three stages of work, namely, `00.train 01.model_d

+ 00.train: DP-GEN will train several (default 4) models based on initial and generated data. The only difference between these models is the random seed for neural network initialization.

+ 01.model_devi : represent for model-deviation. DP-GEN will use models obtained from 00.train to run Molecular Dynamics(default LAMMPS). Larger deviation for structure properties (default is force of atoms) means less accuracy of the models. Using this criterion, a few fructures will be selected and put into next stage `02.fp` for more accurate calculation based on First Principles.
+ 01.model_devi : represent for model-deviation. Model-deviation engine in `01.model_devi` can be chosen between Molecular Dynamics(default LAMMPS) or Structures Prediction(CALYPSO). DP-GEN will use models obtained from 00.train to run Molecular Dynamics or to run structure optimization with ASE in CALYPSO. Larger deviation for structure properties (default is force of atoms) means less accuracy of the models. Using this criterion, a few fructures will be selected and put into next stage `02.fp` for more accurate calculation based on First Principles.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please change "default LAMMPS" to "LAMMPS and GROMACS" ?

ret+=" f.write('in kB') \n"
ret+=" f.write('%15.6f' % stress[0]) \n"
ret+=" f.write('%15.6f' % stress[1]) \n"
ret+=" f.write('%15.6f' % stress[2]) \n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly suggest put these codes in a complete script, like lib/xxx.py, instead of making them strings like you did. On the one hand, the code is easier to read and maintain. On the other hand, users can directly run the script if they have needs.
If you need to execute the script, you can copy the script to you current path.
You can refer to

shutil.copyfile(cvasp_file, 'cvasp.py')

from dpgen.generator.lib.calypso import make_run_opt_script,make_check_outcar_script
from dpgen.generator.lib.calypso import _make_model_devi_native_calypso,write_model_devi_out,_make_model_devi_buffet
from dpgen.generator.lib.model_devi_calypso import gen_structures,analysis
from dpgen.generator.lib.write_modd import write_modd
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @amcadmus suggests, such functions should be named write_model_devi_calypso, etc.

calypso_model_devi_path = os.path.join(work_path,calypso_model_devi_name)
#

calypso_path = jdata.get('calypso_path')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameters about machines and environment variables should be added to machine.json, not param.json

# write_model_devi_out(Devis,'Model_Devi.out')
# os.chdir(cwd)
#
# os.chdir(work_path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete all commented codes.

@@ -1327,6 +1385,68 @@ def run_model_devi (iter_index,
errlog = 'model_devi.log')
submission.run_submission()

def run_model_devi(iter_index,jdata,mdata):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These codes will fundamentally change DP-GEN's protocol by adding a while loop in run_model_devi. Is it possible to put all calypso commands to one single script, instead of DP-GEN's main process?

- rename model_devi_calypso.py run_calypso.py
- rename calypso.py make_calypso.py
- add new file calypso_check_outcar.py calypso_run_opt.py
- add new file calypso_run_model_devi.py
- delete write_modd.py
- modify README.md and run.py
@@ -2537,8 +2708,13 @@ def post_fp_vasp (iter_index,
if all_sys is None:
all_sys = _sys
else:
#try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to remove the commented code.

# save ele_temp, if any
# need to check
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is needed to check?

Copy link
Contributor

@wanghan-iapcm wanghan-iapcm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a few comments are left. I agree the merging of this PR.

@amcadmus
Copy link
Member

Please fix the failure in the UTs.

@amcadmus amcadmus requested a review from AnguseZhang March 28, 2022 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants