@@ -45,13 +45,12 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
4545 fp_params ["kspacing" ] = [
4646 float (i ) for i in fp_params ["kspacing" ].split ()
4747 ]
48- assert (
49- len (fp_params ["kspacing" ])
50- in [
51- 1 ,
52- 3 ,
53- ]
54- ), "'kspacing' only accept a float, or a list of one or three float, or a string of one or three float"
48+ assert len (fp_params ["kspacing" ]) in [
49+ 1 ,
50+ 3 ,
51+ ], (
52+ "'kspacing' only accept a float, or a list of one or three float, or a string of one or three float"
53+ )
5554 ret += "kspacing "
5655 for ikspacing in fp_params ["kspacing" ]:
5756 assert ikspacing >= 0 , "'kspacing' should be non-negative."
@@ -78,9 +77,9 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
7877 elif key == "gamma_only" :
7978 if isinstance (fp_params ["gamma_only" ], str ):
8079 fp_params ["gamma_only" ] = int (eval (fp_params ["gamma_only" ]))
81- assert (
82- fp_params [ " gamma_only" ] == 0 or fp_params [ "gamma_only" ] == 1
83- ), "'gamma_only' should be either 0 or 1."
80+ assert fp_params [ "gamma_only" ] == 0 or fp_params [ "gamma_only" ] == 1 , (
81+ "' gamma_only' should be either 0 or 1."
82+ )
8483 ret += "gamma_only %d\n " % fp_params ["gamma_only" ] # noqa: UP031
8584 elif key == "mixing_type" :
8685 assert fp_params ["mixing_type" ] in [
@@ -93,22 +92,22 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
9392 ret += "mixing_type {}\n " .format (fp_params ["mixing_type" ])
9493 elif key == "mixing_beta" :
9594 fp_params ["mixing_beta" ] = float (fp_params ["mixing_beta" ])
96- assert (
97- fp_params [ " mixing_beta" ] >= 0 and fp_params [ "mixing_beta" ] < 1
98- ), "'mixing_beta' should between 0 and 1."
95+ assert fp_params [ "mixing_beta" ] >= 0 and fp_params [ "mixing_beta" ] < 1 , (
96+ "' mixing_beta' should between 0 and 1."
97+ )
9998 ret += "mixing_beta {:f}\n " .format (fp_params ["mixing_beta" ])
10099 elif key == "symmetry" :
101100 if isinstance (fp_params ["symmetry" ], str ):
102101 fp_params ["symmetry" ] = int (eval (fp_params ["symmetry" ]))
103- assert (
104- fp_params [ " symmetry" ] == 0 or fp_params [ "symmetry" ] == 1
105- ), "'symmetry' should be either 0 or 1."
102+ assert fp_params [ "symmetry" ] == 0 or fp_params [ "symmetry" ] == 1 , (
103+ "' symmetry' should be either 0 or 1."
104+ )
106105 ret += "symmetry %d\n " % fp_params ["symmetry" ] # noqa: UP031
107106 elif key == "nbands" :
108107 fp_params ["nbands" ] = int (fp_params ["nbands" ])
109- assert fp_params ["nbands" ] > 0 and isinstance (
110- fp_params [ " nbands" ], int
111- ), "'nbands' should be a positive integer."
108+ assert fp_params ["nbands" ] > 0 and isinstance (fp_params [ "nbands" ], int ), (
109+ "' nbands' should be a positive integer."
110+ )
112111 ret += "nbands %d\n " % fp_params ["nbands" ] # noqa: UP031
113112 elif key == "nspin" :
114113 fp_params ["nspin" ] = int (fp_params ["nspin" ])
@@ -119,51 +118,49 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
119118 ), "'nspin' can anly take 1, 2 or 4"
120119 ret += "nspin %d\n " % fp_params ["nspin" ] # noqa: UP031
121120 elif key == "ks_solver" :
122- assert (
123- fp_params ["ks_solver" ]
124- in [
125- "cg" ,
126- "dav" ,
127- "lapack" ,
128- "genelpa" ,
129- "hpseps" ,
130- "scalapack_gvx" ,
131- ]
132- ), "'ks_sover' should in 'cgx', 'dav', 'lapack', 'genelpa', 'hpseps', 'scalapack_gvx'."
121+ assert fp_params ["ks_solver" ] in [
122+ "cg" ,
123+ "dav" ,
124+ "lapack" ,
125+ "genelpa" ,
126+ "hpseps" ,
127+ "scalapack_gvx" ,
128+ ], (
129+ "'ks_sover' should in 'cgx', 'dav', 'lapack', 'genelpa', 'hpseps', 'scalapack_gvx'."
130+ )
133131 ret += "ks_solver {}\n " .format (fp_params ["ks_solver" ])
134132 elif key == "smearing_method" :
135- assert (
136- fp_params ["smearing_method" ]
137- in [
138- "gauss" ,
139- "gaussian" ,
140- "fd" ,
141- "fixed" ,
142- "mp" ,
143- "mp2" ,
144- "mv" ,
145- ]
146- ), "'smearing_method' should in 'gauss', 'gaussian', 'fd', 'fixed', 'mp', 'mp2', 'mv'. "
133+ assert fp_params ["smearing_method" ] in [
134+ "gauss" ,
135+ "gaussian" ,
136+ "fd" ,
137+ "fixed" ,
138+ "mp" ,
139+ "mp2" ,
140+ "mv" ,
141+ ], (
142+ "'smearing_method' should in 'gauss', 'gaussian', 'fd', 'fixed', 'mp', 'mp2', 'mv'. "
143+ )
147144 ret += "smearing_method {}\n " .format (fp_params ["smearing_method" ])
148145 elif key == "smearing_sigma" :
149146 fp_params ["smearing_sigma" ] = float (fp_params ["smearing_sigma" ])
150- assert (
151- fp_params [ " smearing_sigma" ] >= 0
152- ), "'smearing_sigma' should be non-negative."
147+ assert fp_params [ "smearing_sigma" ] >= 0 , (
148+ "' smearing_sigma' should be non-negative."
149+ )
153150 ret += "smearing_sigma {:f}\n " .format (fp_params ["smearing_sigma" ])
154151 elif key == "cal_force" :
155152 if isinstance (fp_params ["cal_force" ], str ):
156153 fp_params ["cal_force" ] = int (eval (fp_params ["cal_force" ]))
157- assert (
158- fp_params [ " cal_force" ] == 0 or fp_params [ "cal_force" ] == 1
159- ), "'cal_force' should be either 0 or 1."
154+ assert fp_params [ "cal_force" ] == 0 or fp_params [ "cal_force" ] == 1 , (
155+ "' cal_force' should be either 0 or 1."
156+ )
160157 ret += "cal_force %d\n " % fp_params ["cal_force" ] # noqa: UP031
161158 elif key == "cal_stress" :
162159 if isinstance (fp_params ["cal_stress" ], str ):
163160 fp_params ["cal_stress" ] = int (eval (fp_params ["cal_stress" ]))
164- assert (
165- fp_params [ " cal_stress" ] == 0 or fp_params [ "cal_stress" ] == 1
166- ), "'cal_stress' should be either 0 or 1."
161+ assert fp_params [ "cal_stress" ] == 0 or fp_params [ "cal_stress" ] == 1 , (
162+ "' cal_stress' should be either 0 or 1."
163+ )
167164 ret += "cal_stress %d\n " % fp_params ["cal_stress" ] # noqa: UP031
168165 # paras for deepks
169166 elif key == "deepks_out_labels" :
@@ -180,16 +177,16 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
180177 fp_params ["deepks_descriptor_lmax" ] = int (
181178 fp_params ["deepks_descriptor_lmax" ]
182179 )
183- assert (
184- fp_params [ " deepks_descriptor_lmax" ] >= 0
185- ), "'deepks_descriptor_lmax' should be a positive integer."
180+ assert fp_params [ "deepks_descriptor_lmax" ] >= 0 , (
181+ "' deepks_descriptor_lmax' should be a positive integer."
182+ )
186183 ret += "deepks_descriptor_lmax %d\n " % fp_params ["deepks_descriptor_lmax" ] # noqa: UP031
187184 elif key == "deepks_scf" :
188185 if isinstance (fp_params ["deepks_scf" ], str ):
189186 fp_params ["deepks_scf" ] = int (eval (fp_params ["deepks_scf" ]))
190- assert (
191- fp_params [ " deepks_scf" ] == 0 or fp_params [ "deepks_scf" ] == 1
192- ), "'deepks_scf' should be either 0 or 1."
187+ assert fp_params [ "deepks_scf" ] == 0 or fp_params [ "deepks_scf" ] == 1 , (
188+ "' deepks_scf' should be either 0 or 1."
189+ )
193190 ret += "deepks_scf %d\n " % fp_params ["deepks_scf" ] # noqa: UP031
194191 elif key == "deepks_model" :
195192 ret += "deepks_model {}\n " .format (
@@ -228,9 +225,9 @@ def make_abacus_scf_stru(
228225
229226 ret = "ATOMIC_SPECIES\n "
230227 for iatom in range (len (atom_names )):
231- assert (
232- atom_names [iatom ] in type_map
233- ), f"element { atom_names [ iatom ] } is not defined in type_map"
228+ assert atom_names [ iatom ] in type_map , (
229+ f"element { atom_names [iatom ]} is not defined in type_map"
230+ )
234231 idx = type_map .index (atom_names [iatom ])
235232 if "atom_masses" not in sys_data :
236233 ret += (
0 commit comments