@@ -591,21 +591,21 @@ def make_train(iter_index, jdata, mdata):
591591 if (
592592 len (np .array (model_devi_activation_func ).shape ) == 2
593593 ): # 2-dim list for emd/fitting net-resolved assignment of actF
594- jinput ["model" ]["descriptor" ][
595- "activation_function"
596- ] = model_devi_activation_func [ ii ][ 0 ]
597- jinput ["model" ]["fitting_net" ][
598- "activation_function"
599- ] = model_devi_activation_func [ ii ][ 1 ]
594+ jinput ["model" ]["descriptor" ]["activation_function" ] = (
595+ model_devi_activation_func [ ii ][ 0 ]
596+ )
597+ jinput ["model" ]["fitting_net" ]["activation_function" ] = (
598+ model_devi_activation_func [ ii ][ 1 ]
599+ )
600600 if (
601601 len (np .array (model_devi_activation_func ).shape ) == 1
602602 ): # for backward compatibility, 1-dim list, not net-resolved
603- jinput ["model" ]["descriptor" ][
604- "activation_function"
605- ] = model_devi_activation_func [ ii ]
606- jinput ["model" ]["fitting_net" ][
607- "activation_function"
608- ] = model_devi_activation_func [ ii ]
603+ jinput ["model" ]["descriptor" ]["activation_function" ] = (
604+ model_devi_activation_func [ ii ]
605+ )
606+ jinput ["model" ]["fitting_net" ]["activation_function" ] = (
607+ model_devi_activation_func [ ii ]
608+ )
609609 # dump the input.json
610610 with open (os .path .join (task_path , train_input_file ), "w" ) as outfile :
611611 json .dump (jinput , outfile , indent = 4 )
@@ -1042,9 +1042,9 @@ def revise_lmp_input_dump(lmp_lines, trj_freq, model_devi_merge_traj=False):
10421042
10431043def revise_lmp_input_plm (lmp_lines , in_plm , out_plm = "output.plumed" ):
10441044 idx = find_only_one_key (lmp_lines , ["fix" , "dpgen_plm" ])
1045- lmp_lines [
1046- idx
1047- ] = f"fix dpgen_plm all plumed plumedfile { in_plm } outfile { out_plm } \n "
1045+ lmp_lines [idx ] = (
1046+ f"fix dpgen_plm all plumed plumedfile { in_plm } outfile { out_plm } \n "
1047+ )
10481048 return lmp_lines
10491049
10501050
@@ -1815,9 +1815,10 @@ def _make_model_devi_amber(
18151815 nsteps = jdata ["nsteps" ]
18161816
18171817 for ii , pp in enumerate (mdin ):
1818- with open (pp ) as f , open (
1819- os .path .join (work_path , "init%d.mdin" % ii ), "w"
1820- ) as fw :
1818+ with (
1819+ open (pp ) as f ,
1820+ open (os .path .join (work_path , "init%d.mdin" % ii ), "w" ) as fw ,
1821+ ):
18211822 mdin_str = f .read ()
18221823 # freq, nstlim, qm_region, qm_theory, qm_charge, rcut, graph
18231824 mdin_str = (
@@ -1883,9 +1884,10 @@ def _make_model_devi_amber(
18831884 if not isinstance (r , Iterable ) or isinstance (r , str ):
18841885 r = [r ]
18851886 # disang file should include RVAL, RVAL2, ...
1886- with open (disang [sys_idx [sys_counter ]]) as f , open (
1887- "TEMPLATE.disang" , "w"
1888- ) as fw :
1887+ with (
1888+ open (disang [sys_idx [sys_counter ]]) as f ,
1889+ open ("TEMPLATE.disang" , "w" ) as fw ,
1890+ ):
18891891 tl = f .read ()
18901892 for ii , rr in enumerate (r ):
18911893 if isinstance (rr , Iterable ) and not isinstance (rr , str ):
@@ -1999,14 +2001,7 @@ def run_md_model_devi(iter_index, jdata, mdata):
19992001 if ndx_filename :
20002002 command += f'&& echo -e "{ grp_name } \\ n{ grp_name } \\ n" | { model_devi_exec } trjconv -s { ref_filename } -f { deffnm } .trr -n { ndx_filename } -o { traj_filename } -pbc mol -ur compact -center'
20012003 else :
2002- command += '&& echo -e "{}\\ n{}\\ n" | {} trjconv -s {} -f {}.trr -o {} -pbc mol -ur compact -center' .format (
2003- grp_name ,
2004- grp_name ,
2005- model_devi_exec ,
2006- ref_filename ,
2007- deffnm ,
2008- traj_filename ,
2009- )
2004+ command += f'&& echo -e "{ grp_name } \\ n{ grp_name } \\ n" | { model_devi_exec } trjconv -s { ref_filename } -f { deffnm } .trr -o { traj_filename } -pbc mol -ur compact -center'
20102005 command += "&& if [ ! -d traj ]; then \n mkdir traj; fi\n "
20112006 command += f"python -c \" import dpdata;system = dpdata.System('{ traj_filename } ', fmt='gromacs/gro'); [system.to_gromacs_gro('traj/%d.gromacstrj' % (i * { trj_freq } ), frame_idx=i) for i in range(system.get_nframes())]; system.to_deepmd_npy('traj_deepmd')\" "
20122007 command += f"&& dp model-devi -m ../graph.000.pb ../graph.001.pb ../graph.002.pb ../graph.003.pb -s traj_deepmd -o model_devi.out -f { trj_freq } "
@@ -2508,9 +2503,7 @@ def _make_fp_vasp_inner(
25082503 tot = len (summaryfmax ) - nan_num
25092504 candi_num = tot - acc_num - fail_num
25102505 dlog .info (
2511- "summary accurate_ratio: {:8.4f}% candidata_ratio: {:8.4f}% failed_ratio: {:8.4f}% in {:d} structures" .format (
2512- acc_num * 100 / tot , candi_num * 100 / tot , fail_num * 100 / tot , tot
2513- )
2506+ f"summary accurate_ratio: { acc_num * 100 / tot :8.4f} % candidata_ratio: { candi_num * 100 / tot :8.4f} % failed_ratio: { fail_num * 100 / tot :8.4f} % in { tot :d} structures"
25142507 )
25152508 # --------------------------------------------------------------------------------------------------------------------------------------
25162509
@@ -2662,9 +2655,7 @@ def _trust_limitation_check(sys_idx, lim):
26622655 continue
26632656 for cc_key , cc_value in counter .items ():
26642657 dlog .info (
2665- "system {:s} {:9s} : {:6d} in {:6d} {:6.2f} %" .format (
2666- ss , cc_key , cc_value , fp_sum , cc_value / fp_sum * 100
2667- )
2658+ f"system { ss :s} { cc_key :9s} : { cc_value :6d} in { fp_sum :6d} { cc_value / fp_sum * 100 :6.2f} %"
26682659 )
26692660 random .shuffle (fp_candidate )
26702661 if detailed_report_make_fp :
@@ -2738,15 +2729,7 @@ def _trust_limitation_check(sys_idx, lim):
27382729 numb_task = 0
27392730 # ----------------------------------------------------------------------------
27402731 dlog .info (
2741- "system {:s} accurate_ratio: {:8.4f} thresholds: {:6.4f} and {:6.4f} eff. task min and max {:4d} {:4d} number of fp tasks: {:6d}" .format (
2742- ss ,
2743- accurate_ratio ,
2744- fp_accurate_soft_threshold ,
2745- fp_accurate_threshold ,
2746- fp_task_min ,
2747- this_fp_task_max ,
2748- numb_task ,
2749- )
2732+ f"system { ss :s} accurate_ratio: { accurate_ratio :8.4f} thresholds: { fp_accurate_soft_threshold :6.4f} and { fp_accurate_threshold :6.4f} eff. task min and max { fp_task_min :4d} { this_fp_task_max :4d} number of fp tasks: { numb_task :6d} "
27502733 )
27512734 # make fp tasks
27522735
@@ -2878,21 +2861,15 @@ def _trust_limitation_check(sys_idx, lim):
28782861 os .chdir (cwd )
28792862 if count_bad_box > 0 :
28802863 dlog .info (
2881- "system {:s} skipped {:6d} confs with bad box, {:6d} remains" .format (
2882- ss , count_bad_box , numb_task - count_bad_box
2883- )
2864+ f"system { ss :s} skipped { count_bad_box :6d} confs with bad box, { numb_task - count_bad_box :6d} remains"
28842865 )
28852866 if count_bad_cluster > 0 :
28862867 dlog .info (
2887- "system {:s} skipped {:6d} confs with bad cluster, {:6d} remains" .format (
2888- ss , count_bad_cluster , numb_task - count_bad_cluster
2889- )
2868+ f"system { ss :s} skipped { count_bad_cluster :6d} confs with bad cluster, { numb_task - count_bad_cluster :6d} remains"
28902869 )
28912870 if model_devi_engine == "calypso" :
28922871 dlog .info (
2893- "summary accurate_ratio: {:8.4f}% candidata_ratio: {:8.4f}% failed_ratio: {:8.4f}% in {:d} structures" .format (
2894- acc_num * 100 / tot , candi_num * 100 / tot , fail_num * 100 / tot , tot
2895- )
2872+ f"summary accurate_ratio: { acc_num * 100 / tot :8.4f} % candidata_ratio: { candi_num * 100 / tot :8.4f} % failed_ratio: { fail_num * 100 / tot :8.4f} % in { tot :d} structures"
28962873 )
28972874 if cluster_cutoff is None :
28982875 cwd = os .getcwd ()
0 commit comments