From b9b0e46ffde02cc7ac252b9be3a0f8e08cbfb60d Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 26 Jun 2019 15:38:55 +0800 Subject: [PATCH 1/2] add gaussian support --- generator/lib/gaussian.py | 23 ++++++++++ generator/run.py | 89 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 generator/lib/gaussian.py diff --git a/generator/lib/gaussian.py b/generator/lib/gaussian.py new file mode 100644 index 000000000..d8c3bba53 --- /dev/null +++ b/generator/lib/gaussian.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 + + +def make_gaussian_input(sys_data, fp_params): + # keywords, e.g., force b3lyp/6-31g** + keywords = fp_params['keywords'] + nproc = fp_params['nproc'] + # assume charge is zero and spin multiplicity is 1 + buff = ['%{:d}'.format(nproc), '#force {}'.format( + keywords), '', 'dpgen', '', '0 1'] + coordinates = sys_data['coords'][0] + atom_names = (sys_data['atom_names']) + atom_numbs = (sys_data['atom_numbs']) + cc = 0 + for ii, atom_name in enumerate(atom_names): + for _ in range(atom_numbs[ii]): + buff.append("%s %f %f %f" % (atom_name, *coordinates[cc])) + cc += 1 + if 'basis_set' in fp_params: + # custom basis set + buff.extend(['', fp_params['basis_set'], '']) + buff.append('\n') + return '\n'.join(buff) diff --git a/generator/run.py b/generator/run.py index 57f1053ce..c7f1d90c5 100644 --- a/generator/run.py +++ b/generator/run.py @@ -35,6 +35,7 @@ from lib.vasp import make_vasp_incar_user_dict from lib.pwscf import make_pwscf_input from lib.pwscf import cvt_1frame +from lib.gaussian import make_gaussian_input from lib.RemoteJob import SSHSession, JobStatus, SlurmJob, PBSJob, CloudMachineJob template_name = 'template' @@ -1118,6 +1119,40 @@ def make_fp_pwscf(iter_index, md_trajs = glob.glob(os.path.join(modd_path, 'task*/traj')) for ii in md_trajs : shutil.rmtree(ii) + + +def make_fp_gaussian(iter_index, + jdata): + # make config + fp_tasks = _make_fp_vasp_configs(iter_index, jdata) + if len(fp_tasks) == 0 : + return + # make gaussian gjf file + iter_name = make_iter_name(iter_index) + work_path = os.path.join(iter_name, fp_name) + if 'user_fp_params' in jdata.keys() : + fp_params = jdata['user_fp_params'] + else: + fp_params = jdata['fp_params'] + cwd = os.getcwd() + for ii in fp_tasks: + os.chdir(ii) + sys_data = dpdata.System('POSCAR').data + ret = make_gaussian_input(sys_data, fp_params) + with open('input', 'w') as fp: + fp.write(ret) + os.chdir(cwd) + # link pp files + _link_fp_vasp_pp(iter_index, jdata) + # clean traj + clean_traj = True + if 'model_devi_clean_traj' in jdata : + clean_traj = jdata['model_devi_clean_traj'] + if clean_traj: + modd_path = os.path.join(iter_name, model_devi_name) + md_trajs = glob.glob(os.path.join(modd_path, 'task*/traj')) + for ii in md_trajs : + shutil.rmtree(ii) def make_fp (iter_index, jdata, @@ -1128,6 +1163,8 @@ def make_fp (iter_index, make_fp_vasp(iter_index, jdata) elif fp_style == "pwscf" : make_fp_pwscf(iter_index, jdata) + elif fp_style == "gaussian" : + make_fp_gaussian(iter_index, jdata) else : raise RuntimeError ("unsupported fp style") @@ -1152,6 +1189,17 @@ def _qe_check_fin(ii) : else : return False return True + +def _gaussian_check_fin(ii): + if os.path.isfile(os.path.join(ii, 'output')) : + with open(os.path.join(ii, 'output'), 'r') as fp : + content = fp.read() + count = content.count('Normal termination of Gaussian') + if count != 1 : + return False + else : + return False + return True def run_fp_inner (iter_index, @@ -1257,6 +1305,10 @@ def run_fp (iter_index, forward_files = ['input'] + fp_pp_files backward_files = ['output'] run_fp_inner(iter_index, jdata, mdata, ssh_sess, forward_files, backward_files, _qe_check_fin, log_file = 'output') + elif fp_style == "gaussian": + forward_files = ['input'] + backward_files = ['output'] + run_fp_inner(iter_index, jdata, mdata, ssh_sess, forward_files, backward_files, _gaussian_check_fin, log_file = 'output') else : raise RuntimeError ("unsupported fp style") @@ -1337,6 +1389,41 @@ def post_fp_pwscf (iter_index, all_sys.to_deepmd_npy(sys_data_path, set_size = len(sys_output)) +def post_fp_gaussian (iter_index, + jdata): + model_devi_jobs = jdata['model_devi_jobs'] + assert (iter_index < len(model_devi_jobs)) + + iter_name = make_iter_name(iter_index) + work_path = os.path.join(iter_name, fp_name) + fp_tasks = glob.glob(os.path.join(work_path, 'task.*')) + fp_tasks.sort() + if len(fp_tasks) == 0 : + return + + system_index = [] + for ii in fp_tasks : + system_index.append(os.path.basename(ii).split('.')[1]) + system_index.sort() + set_tmp = set(system_index) + system_index = list(set_tmp) + system_index.sort() + + cwd = os.getcwd() + for ss in system_index : + sys_output = glob.glob(os.path.join(work_path, "task.%s.*/output"%ss)) + sys_output.sort() + for idx,oo in enumerate(sys_output) : + if idx == 0: + all_sys = dpdata.LabeledSystem(oo, fmt = 'gaussian/log') + else: + sys = dpdata.LabeledSystem(oo, fmt = 'gaussian/log') + all_sys.append(sys) + sys_data_path = os.path.join(work_path, 'data.%s'%ss) + all_sys.to_deepmd_raw(sys_data_path) + all_sys.to_deepmd_npy(sys_data_path, set_size = len(sys_output)) + + def post_fp (iter_index, jdata) : fp_style = jdata['fp_style'] @@ -1345,6 +1432,8 @@ def post_fp (iter_index, post_fp_vasp(iter_index, jdata) elif fp_style == "pwscf" : post_fp_pwscf(iter_index, jdata) + elif fp_style == 'gaussian' : + post_fp_gaussian(iter_index, jdata) else : raise RuntimeError ("unsupported fp style") From d35639b7cb3ba587ba412848be87fd7a10903348 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 26 Jun 2019 20:21:48 +0800 Subject: [PATCH 2/2] add unittests for gaussian --- generator/lib/gaussian.py | 2 +- generator/tests/context.py | 1 + .../02.fp/task.000.000000/info | 1 + .../02.fp/task.000.000000/input | 12 + .../02.fp/task.000.000000/output | 342 ++++++++++++++++++ .../out_data_post_fp_gaussian/orig/box.raw | 1 + .../out_data_post_fp_gaussian/orig/coord.raw | 1 + .../out_data_post_fp_gaussian/orig/energy.raw | 1 + .../out_data_post_fp_gaussian/orig/force.raw | 1 + .../out_data_post_fp_gaussian/orig/type.raw | 1 + generator/tests/param-pyridine-gaussian.json | 108 ++++++ generator/tests/test_make_fp.py | 49 +++ generator/tests/test_post_fp.py | 21 +- 13 files changed, 539 insertions(+), 2 deletions(-) create mode 100644 generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/info create mode 100644 generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/input create mode 100644 generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/output create mode 100644 generator/tests/out_data_post_fp_gaussian/orig/box.raw create mode 100644 generator/tests/out_data_post_fp_gaussian/orig/coord.raw create mode 100644 generator/tests/out_data_post_fp_gaussian/orig/energy.raw create mode 100644 generator/tests/out_data_post_fp_gaussian/orig/force.raw create mode 100644 generator/tests/out_data_post_fp_gaussian/orig/type.raw create mode 100644 generator/tests/param-pyridine-gaussian.json diff --git a/generator/lib/gaussian.py b/generator/lib/gaussian.py index d8c3bba53..76ca5626e 100644 --- a/generator/lib/gaussian.py +++ b/generator/lib/gaussian.py @@ -6,7 +6,7 @@ def make_gaussian_input(sys_data, fp_params): keywords = fp_params['keywords'] nproc = fp_params['nproc'] # assume charge is zero and spin multiplicity is 1 - buff = ['%{:d}'.format(nproc), '#force {}'.format( + buff = ['%nproc={:d}'.format(nproc), '#force {}'.format( keywords), '', 'dpgen', '', '0 1'] coordinates = sys_data['coords'][0] atom_names = (sys_data['atom_names']) diff --git a/generator/tests/context.py b/generator/tests/context.py index 35279ce54..803c3cf3d 100644 --- a/generator/tests/context.py +++ b/generator/tests/context.py @@ -6,5 +6,6 @@ param_old_file = 'param-mg-vasp-old.json' param_pwscf_file = 'param-pyridine-pwscf.json' param_pwscf_old_file = 'param-pyridine-pwscf-old.json' +param_gaussian_file = 'param-pyridine-gaussian.json' machine_file = 'machine-local.json' diff --git a/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/info b/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/info new file mode 100644 index 000000000..5da529c30 --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/info @@ -0,0 +1 @@ +/home/jzzeng/test/0626/02.fp/task.000.000000 diff --git a/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/input b/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/input new file mode 100644 index 000000000..3f85efba4 --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/input @@ -0,0 +1,12 @@ +%nproc=28 +#force b3lyp/6-31g** + +methane + +0 1 +C 1.07422 -0.06034 0.02917 +H 2.16642 -0.06034 0.02917 +H 0.71015 -0.92887 -0.52401 +H 0.71015 0.85299 -0.44641 +H 0.71015 -0.10514 1.05793 + diff --git a/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/output b/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/output new file mode 100644 index 000000000..f1fc9821b --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/02.fp/task.000.000000/output @@ -0,0 +1,342 @@ + Entering Gaussian System, Link 0=g16 + Initial command: + /home/jzzeng/soft/g16/l1.exe "/home/jzzeng/test/Gau-15026.inp" -scrdir="/home/jzzeng/test/" + Entering Link 1 = /home/jzzeng/soft/g16/l1.exe PID= 15028. + + Copyright (c) 1988,1990,1992,1993,1995,1998,2003,2009,2016, + Gaussian, Inc. All Rights Reserved. + + This is part of the Gaussian(R) 16 program. It is based on + the Gaussian(R) 09 system (copyright 2009, Gaussian, Inc.), + the Gaussian(R) 03 system (copyright 2003, Gaussian, Inc.), + the Gaussian(R) 98 system (copyright 1998, Gaussian, Inc.), + the Gaussian(R) 94 system (copyright 1995, Gaussian, Inc.), + the Gaussian 92(TM) system (copyright 1992, Gaussian, Inc.), + the Gaussian 90(TM) system (copyright 1990, Gaussian, Inc.), + the Gaussian 88(TM) system (copyright 1988, Gaussian, Inc.), + the Gaussian 86(TM) system (copyright 1986, Carnegie Mellon + University), and the Gaussian 82(TM) system (copyright 1983, + Carnegie Mellon University). Gaussian is a federally registered + trademark of Gaussian, Inc. + + This software contains proprietary and confidential information, + including trade secrets, belonging to Gaussian, Inc. + + This software is provided under written license and may be + used, copied, transmitted, or stored only in accord with that + written license. + + The following legend is applicable only to US Government + contracts under FAR: + + RESTRICTED RIGHTS LEGEND + + Use, reproduction and disclosure by the US Government is + subject to restrictions as set forth in subparagraphs (a) + and (c) of the Commercial Computer Software - Restricted + Rights clause in FAR 52.227-19. + + Gaussian, Inc. + 340 Quinnipiac St., Bldg. 40, Wallingford CT 06492 + + + --------------------------------------------------------------- + Warning -- This program may not be used in any manner that + competes with the business of Gaussian, Inc. or will provide + assistance to any competitor of Gaussian, Inc. The licensee + of this program is prohibited from giving any competitor of + Gaussian, Inc. access to this program. By using this program, + the user acknowledges that Gaussian, Inc. is engaged in the + business of creating and licensing software in the field of + computational chemistry and represents and warrants to the + licensee that it is not a competitor of Gaussian, Inc. and that + it will not use this program in any manner prohibited above. + --------------------------------------------------------------- + + + Cite this work as: + Gaussian 16, Revision A.03, + M. J. Frisch, G. W. Trucks, H. B. Schlegel, G. E. Scuseria, + M. A. Robb, J. R. Cheeseman, G. Scalmani, V. Barone, + G. A. Petersson, H. Nakatsuji, X. Li, M. Caricato, A. V. Marenich, + J. Bloino, B. G. Janesko, R. Gomperts, B. Mennucci, H. P. Hratchian, + J. V. Ortiz, A. F. Izmaylov, J. L. Sonnenberg, D. Williams-Young, + F. Ding, F. Lipparini, F. Egidi, J. Goings, B. Peng, A. Petrone, + T. Henderson, D. Ranasinghe, V. G. Zakrzewski, J. Gao, N. Rega, + G. Zheng, W. Liang, M. Hada, M. Ehara, K. Toyota, R. Fukuda, + J. Hasegawa, M. Ishida, T. Nakajima, Y. Honda, O. Kitao, H. Nakai, + T. Vreven, K. Throssell, J. A. Montgomery, Jr., J. E. Peralta, + F. Ogliaro, M. J. Bearpark, J. J. Heyd, E. N. Brothers, K. N. Kudin, + V. N. Staroverov, T. A. Keith, R. Kobayashi, J. Normand, + K. Raghavachari, A. P. Rendell, J. C. Burant, S. S. Iyengar, + J. Tomasi, M. Cossi, J. M. Millam, M. Klene, C. Adamo, R. Cammi, + J. W. Ochterski, R. L. Martin, K. Morokuma, O. Farkas, + J. B. Foresman, and D. J. Fox, Gaussian, Inc., Wallingford CT, 2016. + + ****************************************** + Gaussian 16: ES64L-G16RevA.03 25-Dec-2016 + 25-Jun-2019 + ****************************************** + %nproc=28 + Will use up to 28 processors via shared memory. + -------------------- + #force b3lyp/6-31g** + -------------------- + 1/10=7,30=1,38=1/1,3; + 2/12=2,17=6,18=5,40=1/2; + 3/5=1,6=6,7=101,11=2,25=1,30=1,71=1,74=-5/1,2,3; + 4//1; + 5/5=2,38=5/2; + 6/7=2,8=2,9=2,10=2,28=1/1; + 7/29=1/1,2,3,16; + 1/10=7,30=1/3; + 99//99; + ------- + methane + ------- + Symbolic Z-matrix: + Charge = 0 Multiplicity = 1 + C 1.07422 -0.06034 0.02917 + H 2.16642 -0.06034 0.02917 + H 0.71015 -0.92887 -0.52401 + H 0.71015 0.85299 -0.44641 + H 0.71015 -0.10514 1.05793 + + + GradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGrad + Berny optimization. + Initialization pass. + Trust Radius=3.00D-01 FncErr=1.00D-07 GrdErr=1.00D-07 EigMax=2.50D+02 EigMin=1.00D-04 + Number of steps in this run= 2 maximum allowed number of steps= 2. + GradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGrad + + Input orientation: + --------------------------------------------------------------------- + Center Atomic Atomic Coordinates (Angstroms) + Number Number Type X Y Z + --------------------------------------------------------------------- + 1 6 0 1.074220 -0.060340 0.029170 + 2 1 0 2.166420 -0.060340 0.029170 + 3 1 0 0.710150 -0.928870 -0.524010 + 4 1 0 0.710150 0.852990 -0.446410 + 5 1 0 0.710150 -0.105140 1.057930 + --------------------------------------------------------------------- + Distance matrix (angstroms): + 1 2 3 4 5 + 1 C 0.000000 + 2 H 1.092200 0.000000 + 3 H 1.092199 1.783557 0.000000 + 4 H 1.092197 1.783556 1.783549 0.000000 + 5 H 1.092200 1.783557 1.783554 1.783550 0.000000 + Stoichiometry CH4 + Framework group C1[X(CH4)] + Deg. of freedom 9 + Full point group C1 NOp 1 + Largest Abelian subgroup C1 NOp 1 + Largest concise Abelian subgroup C1 NOp 1 + Standard orientation: + --------------------------------------------------------------------- + Center Atomic Atomic Coordinates (Angstroms) + Number Number Type X Y Z + --------------------------------------------------------------------- + 1 6 0 -0.000001 0.000000 0.000000 + 2 1 0 -1.092201 0.000000 0.000000 + 3 1 0 0.364069 -0.813864 -0.630855 + 4 1 0 0.364069 -0.139406 1.020252 + 5 1 0 0.364069 0.953270 -0.389397 + --------------------------------------------------------------------- + Rotational constants (GHZ): 157.6380023 157.6375616 157.6370163 + Standard basis: 6-31G(d,p) (6D, 7F) + There are 35 symmetry adapted cartesian basis functions of A symmetry. + There are 35 symmetry adapted basis functions of A symmetry. + 35 basis functions, 56 primitive gaussians, 35 cartesian basis functions + 5 alpha electrons 5 beta electrons + nuclear repulsion energy 13.4083363407 Hartrees. + NAtoms= 5 NActive= 5 NUniq= 5 SFac= 1.00D+00 NAtFMM= 60 NAOKFM=F Big=F + Integral buffers will be 131072 words long. + Raffenetti 2 integral format. + Two-electron integral symmetry is turned on. + One-electron integrals computed using PRISM. + NBasis= 35 RedAO= T EigKep= 1.79D-02 NBF= 35 + NBsUse= 35 1.00D-06 EigRej= -1.00D+00 NBFU= 35 + ExpMin= 1.61D-01 ExpMax= 3.05D+03 ExpMxC= 4.57D+02 IAcc=3 IRadAn= 5 AccDes= 0.00D+00 + Harris functional with IExCor= 402 and IRadAn= 5 diagonalized for initial guess. + HarFok: IExCor= 402 AccDes= 0.00D+00 IRadAn= 5 IDoV= 1 UseB2=F ITyADJ=14 + ICtDFT= 3500011 ScaDFX= 1.000000 1.000000 1.000000 1.000000 + FoFCou: FMM=F IPFlag= 0 FMFlag= 100000 FMFlg1= 0 + NFxFlg= 0 DoJE=T BraDBF=F KetDBF=T FulRan=T + wScrn= 0.000000 ICntrl= 500 IOpCl= 0 I1Cent= 200000004 NGrid= 0 + NMat0= 1 NMatS0= 1 NMatT0= 0 NMatD0= 1 NMtDS0= 0 NMtDT0= 0 + Petite list used in FoFCou. + Keep R1 ints in memory in canonical form, NReq=24354403. + Requested convergence on RMS density matrix=1.00D-08 within 128 cycles. + Requested convergence on MAX density matrix=1.00D-06. + Requested convergence on energy=1.00D-06. + No special actions if energy rises. + Integral accuracy reduced to 1.0D-05 until final iterations. + Initial convergence to 1.0D-05 achieved. Increase integral accuracy. + SCF Done: E(RB3LYP) = -40.5240137309 A.U. after 8 cycles + NFock= 8 Conv=0.23D-08 -V/T= 2.0111 + + ********************************************************************** + + Population analysis using the SCF density. + + ********************************************************************** + + Orbital symmetries: + Occupied (A) (A) (A) (A) (A) + Virtual (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) + (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) (A) + (A) (A) (A) (A) (A) (A) + The electronic state is 1-A. + Alpha occ. eigenvalues -- -10.16717 -0.69034 -0.38827 -0.38827 -0.38827 + Alpha virt. eigenvalues -- 0.11818 0.17670 0.17670 0.17670 0.52921 + Alpha virt. eigenvalues -- 0.52921 0.52921 0.87424 0.87424 0.87424 + Alpha virt. eigenvalues -- 0.92208 1.10023 1.36345 1.36345 2.04806 + Alpha virt. eigenvalues -- 2.04806 2.04806 2.05141 2.05142 2.05142 + Alpha virt. eigenvalues -- 2.62952 2.62953 2.62953 2.91074 2.91074 + Alpha virt. eigenvalues -- 3.11458 3.41994 3.41994 3.41994 4.42248 + Condensed to atoms (all electrons): + 1 2 3 4 5 + 1 C 4.899051 0.392830 0.392830 0.392830 0.392830 + 2 H 0.392830 0.573073 -0.027832 -0.027832 -0.027832 + 3 H 0.392830 -0.027832 0.573075 -0.027833 -0.027832 + 4 H 0.392830 -0.027832 -0.027833 0.573074 -0.027833 + 5 H 0.392830 -0.027832 -0.027832 -0.027833 0.573075 + Mulliken charges: + 1 + 1 C -0.470371 + 2 H 0.117593 + 3 H 0.117593 + 4 H 0.117593 + 5 H 0.117593 + Sum of Mulliken charges = 0.00000 + Mulliken charges with hydrogens summed into heavy atoms: + 1 + 1 C 0.000000 + Electronic spatial extent (au): = 35.4329 + Charge= 0.0000 electrons + Dipole moment (field-independent basis, Debye): + X= 0.0000 Y= -0.0000 Z= 0.0000 Tot= 0.0000 + Quadrupole moment (field-independent basis, Debye-Ang): + XX= -8.2465 YY= -8.2465 ZZ= -8.2465 + XY= -0.0000 XZ= 0.0000 YZ= 0.0000 + Traceless Quadrupole moment (field-independent basis, Debye-Ang): + XX= 0.0000 YY= -0.0000 ZZ= -0.0000 + XY= -0.0000 XZ= 0.0000 YZ= 0.0000 + Octapole moment (field-independent basis, Debye-Ang**2): + XXX= -0.7604 YYY= 0.2130 ZZZ= 0.4937 XYY= 0.3802 + XXY= -0.0000 XXZ= 0.0000 XZZ= 0.3802 YZZ= -0.2130 + YYZ= -0.4937 XYZ= 0.0000 + Hexadecapole moment (field-independent basis, Debye-Ang**3): + XXXX= -14.9429 YYYY= -15.1704 ZZZZ= -15.1704 XXXY= -0.0000 + XXXZ= 0.0000 YYYX= 0.1275 YYYZ= 0.0000 ZZZX= 0.2954 + ZZZY= -0.0000 XXYY= -5.2843 XXZZ= -5.2843 YYZZ= -5.0568 + XXYZ= 0.0000 YYXZ= -0.2954 ZZXY= -0.1275 + N-N= 1.340833634068D+01 E-N=-1.198747475070D+02 KE= 4.007727827872D+01 + Calling FoFJK, ICntrl= 2127 FMM=F ISym2X=0 I1Cent= 0 IOpClX= 0 NMat=1 NMatS=1 NMatT=0. + ***** Axes restored to original set ***** + ------------------------------------------------------------------- + Center Atomic Forces (Hartrees/Bohr) + Number Number X Y Z + ------------------------------------------------------------------- + 1 6 -0.000000623 -0.000000654 0.000000794 + 2 1 -0.000215948 -0.000000016 -0.000000010 + 3 1 0.000072325 0.000170842 0.000109258 + 4 1 0.000071925 -0.000178640 0.000093176 + 5 1 0.000072322 0.000008469 -0.000203220 + ------------------------------------------------------------------- + Cartesian Forces: Max 0.000215948 RMS 0.000111163 + + GradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGrad + Berny optimization. + Search for a local minimum. + Step number 1 out of a maximum of 2 + All quantities printed in internal units (Hartrees-Bohrs-Radians) + Second derivative matrix not updated -- first step. + The second derivative matrix: + X1 Y1 Z1 X2 Y2 + X1 0.66422 + Y1 -0.00000 0.66422 + Z1 0.00000 -0.00000 0.66422 + X2 -0.34560 -0.00000 0.00000 0.34560 + Y2 -0.00000 -0.07628 -0.00000 0.00000 0.05678 + Z2 0.00000 -0.00000 -0.07628 -0.00000 0.00000 + X3 -0.10621 -0.07139 -0.04547 -0.00000 -0.02998 + Y3 -0.07139 -0.24659 -0.10847 0.00000 0.00907 + Z3 -0.04547 -0.10847 -0.14537 0.00000 0.00550 + X4 -0.10621 0.07507 -0.03909 -0.00000 0.03153 + Y4 0.07507 -0.26461 0.09806 -0.00000 0.00998 + Z4 -0.03909 0.09806 -0.12735 0.00000 -0.00497 + X5 -0.10621 -0.00368 0.08456 0.00000 -0.00155 + Y5 -0.00368 -0.07674 0.01040 -0.00000 0.00046 + Z5 0.08456 0.01041 -0.31522 0.00000 -0.00053 + Z2 X3 Y3 Z3 X4 + Z2 0.05678 + X3 -0.01910 0.08887 + Y3 0.00550 0.07656 0.23942 + Z3 0.00394 0.04876 0.11633 0.13087 + X4 -0.01642 0.00867 -0.01076 0.01119 0.08887 + Y4 -0.00497 0.00975 -0.01251 0.01323 -0.08051 + Z4 0.00302 0.01208 -0.01579 0.01685 0.04192 + X5 0.03551 0.00867 0.00559 -0.01448 0.00867 + Y5 -0.00053 0.01507 0.01062 -0.02659 -0.01533 + Z5 0.01255 0.00372 0.00244 -0.00628 0.00240 + Y4 Z4 X5 Y5 Z5 + Y4 0.25875 + Z4 -0.10517 0.11154 + X5 -0.00431 -0.01491 0.08887 + Y5 0.00840 0.02787 0.00395 0.05726 + Z5 -0.00116 -0.00406 -0.09068 -0.01116 0.31302 + ITU= 0 + Eigenvalues --- 0.11268 0.11268 0.13515 0.13515 0.13515 + Eigenvalues --- 0.34560 0.81139 0.81139 0.81140 + Angle between quadratic step and forces= 0.37 degrees. + Linear search not attempted -- first point. + B after Tr= -0.000001 0.000000 -0.000000 + Rot= 1.000000 0.000000 -0.000000 -0.000000 Ang= 0.00 deg. + Variable Old X -DE/DX Delta X Delta X Delta X New X + (Linear) (Quad) (Total) + X1 2.02998 -0.00000 0.00000 -0.00000 -0.00000 2.02998 + Y1 -0.11403 -0.00000 0.00000 0.00000 0.00000 -0.11403 + Z1 0.05512 0.00000 0.00000 -0.00000 -0.00000 0.05512 + X2 4.09394 -0.00022 0.00000 -0.00063 -0.00063 4.09331 + Y2 -0.11403 -0.00000 0.00000 -0.00000 -0.00000 -0.11403 + Z2 0.05512 -0.00000 0.00000 0.00000 -0.00000 0.05512 + X3 1.34199 0.00007 0.00000 0.00021 0.00021 1.34220 + Y3 -1.75531 0.00017 0.00000 0.00049 0.00049 -1.75482 + Z3 -0.99024 0.00011 0.00000 0.00032 0.00032 -0.98992 + X4 1.34199 0.00007 0.00000 0.00021 0.00021 1.34220 + Y4 1.61192 -0.00018 0.00000 -0.00051 -0.00051 1.61140 + Z4 -0.84359 0.00009 0.00000 0.00027 0.00027 -0.84332 + X5 1.34199 0.00007 0.00000 0.00021 0.00021 1.34220 + Y5 -0.19869 0.00001 0.00000 0.00002 0.00002 -0.19866 + Z5 1.99920 -0.00020 0.00000 -0.00059 -0.00059 1.99861 + Item Value Threshold Converged? + Maximum Force 0.000216 0.000450 YES + RMS Force 0.000111 0.000300 YES + Maximum Displacement 0.000628 0.001800 YES + RMS Displacement 0.000322 0.001200 YES + Predicted change in Energy=-2.681743D-07 + Optimization completed. + -- Stationary point found. + GradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGrad + + 1\1\GINC-LOCALHOST\Force\RB3LYP\6-31G(d,p)\C1H4\JZZENG\25-Jun-2019\0\\ + #force b3lyp/6-31g**\\methane\\0,1\C,1.07422,-0.06034,0.02917\H,2.1664 + 2,-0.06034,0.02917\H,0.71015,-0.92887,-0.52401\H,0.71015,0.85299,-0.44 + 641\H,0.71015,-0.10514,1.05793\\Version=ES64L-G16RevA.03\State=1-A\HF= + -40.5240137\RMSD=2.291e-09\RMSF=1.112e-04\Dipole=-0.0000018,0.0000007, + -0.0000007\Quadrupole=0.0000105,-0.0000083,-0.0000022,-0.000001,0.0000 + 01,0.0000025\PG=C01 [X(C1H4)]\\@ + + + SEE YOU NOW, + YOUR BAIT OF FALSEHOOD TAKES THIS CARP OF TRUTH. + AND THUS DO WE OF WISDOM AND OF REACH... + BY INDIRECTIONS FIND DIRECTIONS OUT. -- HAMLET, II, 1 + Job cpu time: 0 days 0 hours 1 minutes 11.1 seconds. + Elapsed time: 0 days 0 hours 0 minutes 3.2 seconds. + File lengths (MBytes): RWF= 6 Int= 0 D2E= 0 Chk= 1 Scr= 1 + Normal termination of Gaussian 16 at Tue Jun 25 00:14:07 2019. diff --git a/generator/tests/out_data_post_fp_gaussian/orig/box.raw b/generator/tests/out_data_post_fp_gaussian/orig/box.raw new file mode 100644 index 000000000..9486fe47c --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/orig/box.raw @@ -0,0 +1 @@ +100 0 0 0 100 0 0 0 100 diff --git a/generator/tests/out_data_post_fp_gaussian/orig/coord.raw b/generator/tests/out_data_post_fp_gaussian/orig/coord.raw new file mode 100644 index 000000000..40650042a --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/orig/coord.raw @@ -0,0 +1 @@ +1.07422 -0.06034 0.02917 2.16642 -0.06034 0.02917 0.71015 -0.92887 -0.52401 0.71015 0.85299 -0.44641 0.71015 -0.10514 1.05793 diff --git a/generator/tests/out_data_post_fp_gaussian/orig/energy.raw b/generator/tests/out_data_post_fp_gaussian/orig/energy.raw new file mode 100644 index 000000000..fd4a649a7 --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/orig/energy.raw @@ -0,0 +1 @@ +-1102.7145808882785 diff --git a/generator/tests/out_data_post_fp_gaussian/orig/force.raw b/generator/tests/out_data_post_fp_gaussian/orig/force.raw new file mode 100644 index 000000000..3d9142cc3 --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/orig/force.raw @@ -0,0 +1 @@ +-3.2035947797369445e-05 -3.363003187717434e-05 4.082912126984163e-05 -0.011104492544055116 -8.227530734476904e-07 -5.142206709048064e-07 0.0037191010023190124 0.008785048785871894 0.005618272206171735 0.0036985321754828206 -0.009186038065043462 0.004791302523222625 0.0037189467361177413 0.0004354934861892806 -0.010449992474127477 diff --git a/generator/tests/out_data_post_fp_gaussian/orig/type.raw b/generator/tests/out_data_post_fp_gaussian/orig/type.raw new file mode 100644 index 000000000..91d744938 --- /dev/null +++ b/generator/tests/out_data_post_fp_gaussian/orig/type.raw @@ -0,0 +1 @@ +0 1 1 1 1 \ No newline at end of file diff --git a/generator/tests/param-pyridine-gaussian.json b/generator/tests/param-pyridine-gaussian.json new file mode 100644 index 000000000..697d79604 --- /dev/null +++ b/generator/tests/param-pyridine-gaussian.json @@ -0,0 +1,108 @@ +{ + "type_map": ["C", "H", "N"], + "mass_map": [16, 2, 14], + + "init_data_prefix": "/home/linfengz/SCR/wanghan/deepgen.pyridine/init", + "init_data_sys": ["Pyridine-I", + "Pyridine-II" + ], + "init_batch_size": [1, 1], + "sys_configs": [ + ["/home/linfengz/SCR/wanghan/data/pyridine/pyI.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/00009?/POSCAR"], + ["/home/linfengz/SCR/wanghan/data/pyridine/pyI.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/0000[7-8]?/POSCAR"], + ["/home/linfengz/SCR/wanghan/data/pyridine/pyI.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/0000[5-6]?/POSCAR"], + ["/home/linfengz/SCR/wanghan/data/pyridine/pyI.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/0000[0-4]?/POSCAR"], + ["/home/linfengz/SCR/wanghan/data/pyridine/pyII.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/00009?/POSCAR"], + ["/home/linfengz/SCR/wanghan/data/pyridine/pyII.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/0000[7-8]?/POSCAR"], + ["/home/linfengz/SCR/wanghan/data/pyridine/pyII.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/0000[5-6]?/POSCAR"], + ["/home/linfengz/SCR/wanghan/data/pyridine/pyII.POSCAR.01x01x01/01.scale_pert/sys-0080-0080-0016/scale-1.000/0000[0-4]?/POSCAR"] + ], + "_comment": "0 1 2 3", + "_comment": "4 5 6 7", + "sys_batch_size": [1, 1, 1, 1, + 1, 1, 1, 1 + ], + + "_comment": " 00.train ", + "numb_models": 4, + "train_param": "input.json", + "default_training_param" : { + "_comment": " model parameters", + "use_smooth": true, + "sel_a": [81, 81, 20], + "rcut_smth": 0.50, + "rcut": 6.50, + "filter_neuron": [25, 50, 100], + "filter_resnet_dt": false, + "n_axis_neuron": 12, + "n_neuron": [240, 240, 240], + "resnet_dt": true, + "coord_norm": true, + "type_fitting_net": false, + + "_comment": " traing controls", + "systems": [], + "set_prefix": "set", + "stop_batch": 400000, + "batch_size": 1, + "start_lr": 0.002, + "decay_steps": 2000, + "decay_rate": 0.95, + "seed": 0, + + "start_pref_e": 0.02, + "limit_pref_e": 2, + "start_pref_f": 1000, + "limit_pref_f": 1, + "start_pref_v": 0.0, + "limit_pref_v": 0.0, + + "_comment": " display and restart", + "_comment": " frequencies counted in batch", + "disp_file": "lcurve.out", + "disp_freq": 2000, + "numb_test": 10, + "save_freq": 20000, + "save_ckpt": "model.ckpt", + "load_ckpt": "model.ckpt", + "disp_training": true, + "time_training": true, + "profiling": false, + "profiling_file": "timeline.json", + + "_comment": "that's all" + }, + + "_comment": " 01.model_devi ", + "_comment": "model_devi_skip: the first x of the recorded frames", + "model_devi_dt": 0.001, + "model_devi_skip": 0, + "model_devi_f_trust_lo": 0.050, + "model_devi_f_trust_hi": 0.150, + "model_devi_e_trust_lo": 1e10, + "model_devi_e_trust_hi": 1e10, + "model_devi_clean_traj": false, + "model_devi_jobs": [ + {"sys_idx": [0,4], "temps": [ 50], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "00"}, + {"sys_idx": [1,5], "temps": [ 50], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "01"}, + {"sys_idx": [0,4], "temps": [ 50], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "02"}, + {"sys_idx": [1,5], "temps": [ 50], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "03"}, + {"sys_idx": [0,4], "temps": [ 100], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "04"}, + {"sys_idx": [1,5], "temps": [ 100], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "05"}, + {"sys_idx": [0,4], "temps": [ 100], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "06"}, + {"sys_idx": [1,5], "temps": [ 100], "press": [1e0,1e1,1e2,1e3,1e4,2e4,4e4], "trj_freq": 10, "nsteps": 1000, "ensemble": "npt", "_idx": "07"} + ], + + "_comment": " 02.fp ", + "fp_style": "gaussian", + "shuffle_poscar": false, + "fp_task_max": 100, + "fp_task_min": 10, + "fp_pp_path": ".", + "fp_pp_files": [], + "user_fp_params": { + "nproc": 14, + "keywords": "b3lyp/6-31g*" + }, + "_comment": " that's all " +} diff --git a/generator/tests/test_make_fp.py b/generator/tests/test_make_fp.py index a7004c30e..d422efa5c 100644 --- a/generator/tests/test_make_fp.py +++ b/generator/tests/test_make_fp.py @@ -5,11 +5,13 @@ from context import make_fp_vasp from context import make_fp_pwscf +from context import make_fp_gaussian from context import parse_cur_job from context import param_file from context import param_old_file from context import param_pwscf_file from context import param_pwscf_old_file +from context import param_gaussian_file from context import machine_file from comp_sys import test_atom_names from comp_sys import test_atom_types @@ -58,6 +60,11 @@ conv_thr=1e-08,\n\ /\n" +gaussian_input_ref="""%nproc=14 +#force b3lyp/6-31g* + +dpgen +""" def _box2lmpbox(orig, box) : lohi = np.zeros([3,2]) @@ -235,6 +242,20 @@ def _check_pwscf_input_head(testCase, idx) : lines = lines[:idx] testCase.assertEqual(('\n'.join(lines)).strip(), pwscf_input_ref.strip()) +def _check_gaussian_input_head(testCase, idx) : + fp_path = os.path.join('iter.%06d' % idx, '02.fp') + tasks = glob.glob(os.path.join(fp_path, 'task.*')) + for ii in tasks : + ifile = os.path.join(ii, 'input') + testCase.assertTrue(os.path.isfile(ifile)) + with open(ifile) as fp: + lines = fp.read().split('\n') + for idx, jj in enumerate(lines) : + if '0 1' in jj : + break + lines = lines[:idx] + testCase.assertEqual(('\n'.join(lines)).strip(), gaussian_input_ref.strip()) + class TestMakeFPPwscf(unittest.TestCase): def test_make_fp_pwscf(self): @@ -373,6 +394,34 @@ def test_make_fp_vasp_less_sel(self): shutil.rmtree('iter.000000') +class TestMakeFPGaussian(unittest.TestCase): + def test_make_fp_gaussian(self): + if os.path.isdir('iter.000000') : + shutil.rmtree('iter.000000') + with open (param_gaussian_file, 'r') as fp : + jdata = json.load (fp) + with open (machine_file, 'r') as fp: + mdata = json.load (fp) + md_descript = [] + nsys = 2 + nmd = 3 + n_frame = 10 + for ii in range(nsys) : + tmp = [] + for jj in range(nmd) : + tmp.append(np.arange(0, 0.29, 0.29/10)) + md_descript.append(tmp) + atom_types = [0, 1, 2, 2, 0, 1] + type_map = jdata['type_map'] + _make_fake_md(0, md_descript, atom_types, type_map) + make_fp_gaussian(0, jdata) + _check_sel(self, 0, jdata['fp_task_max'], jdata['model_devi_f_trust_lo'], jdata['model_devi_f_trust_hi']) + _check_poscars(self, 0, jdata['fp_task_max'], jdata['type_map']) + _check_gaussian_input_head(self, 0) + _check_potcar(self, 0, jdata['fp_pp_path'], jdata['fp_pp_files']) + shutil.rmtree('iter.000000') + + if __name__ == '__main__': unittest.main() diff --git a/generator/tests/test_post_fp.py b/generator/tests/test_post_fp.py index df7a7fbb0..bf1778b35 100644 --- a/generator/tests/test_post_fp.py +++ b/generator/tests/test_post_fp.py @@ -6,10 +6,12 @@ from context import post_fp from context import post_fp_pwscf from context import post_fp_vasp +from context import post_fp_gaussian from context import param_file from context import param_old_file from context import param_pwscf_file from context import param_pwscf_old_file +from context import param_gaussian_file from context import machine_file from comp_sys import test_atom_names from comp_sys import test_atom_types @@ -144,6 +146,23 @@ def setUp(self): post_fp(0, jdata) self.system_1 = dpdata.LabeledSystem('iter.000000/orig', fmt = 'deepmd/raw') self.system_2 = dpdata.LabeledSystem('iter.000000/02.fp/data.000', fmt = 'deepmd/raw') - + +class TestPostGaussian(unittest.TestCase, CompLabeledSys): + def setUp(self): + self.places = 5 + self.e_places = 5 + self.f_places = 5 + self.v_places = 5 + assert os.path.isdir('out_data_post_fp_gaussian'), 'out data for post fp gaussian should exist' + if os.path.isdir('iter.000000') : + shutil.rmtree('iter.000000') + shutil.copytree('out_data_post_fp_gaussian', 'iter.000000') + with open (param_gaussian_file, 'r') as fp : + jdata = json.load (fp) + post_fp(0, jdata) + self.system_1 = dpdata.LabeledSystem('iter.000000/orig', fmt = 'deepmd/raw') + self.system_2 = dpdata.LabeledSystem('iter.000000/02.fp/data.000', fmt = 'deepmd/raw') +if __name__ == '__main__': + unittest.main() \ No newline at end of file