@@ -45,13 +45,12 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
45
45
fp_params ["kspacing" ] = [
46
46
float (i ) for i in fp_params ["kspacing" ].split ()
47
47
]
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
+ )
55
54
ret += "kspacing "
56
55
for ikspacing in fp_params ["kspacing" ]:
57
56
assert ikspacing >= 0 , "'kspacing' should be non-negative."
@@ -78,9 +77,9 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
78
77
elif key == "gamma_only" :
79
78
if isinstance (fp_params ["gamma_only" ], str ):
80
79
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
+ )
84
83
ret += "gamma_only %d\n " % fp_params ["gamma_only" ] # noqa: UP031
85
84
elif key == "mixing_type" :
86
85
assert fp_params ["mixing_type" ] in [
@@ -93,22 +92,22 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
93
92
ret += "mixing_type {}\n " .format (fp_params ["mixing_type" ])
94
93
elif key == "mixing_beta" :
95
94
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
+ )
99
98
ret += "mixing_beta {:f}\n " .format (fp_params ["mixing_beta" ])
100
99
elif key == "symmetry" :
101
100
if isinstance (fp_params ["symmetry" ], str ):
102
101
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
+ )
106
105
ret += "symmetry %d\n " % fp_params ["symmetry" ] # noqa: UP031
107
106
elif key == "nbands" :
108
107
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
+ )
112
111
ret += "nbands %d\n " % fp_params ["nbands" ] # noqa: UP031
113
112
elif key == "nspin" :
114
113
fp_params ["nspin" ] = int (fp_params ["nspin" ])
@@ -119,51 +118,49 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
119
118
), "'nspin' can anly take 1, 2 or 4"
120
119
ret += "nspin %d\n " % fp_params ["nspin" ] # noqa: UP031
121
120
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
+ )
133
131
ret += "ks_solver {}\n " .format (fp_params ["ks_solver" ])
134
132
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
+ )
147
144
ret += "smearing_method {}\n " .format (fp_params ["smearing_method" ])
148
145
elif key == "smearing_sigma" :
149
146
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
+ )
153
150
ret += "smearing_sigma {:f}\n " .format (fp_params ["smearing_sigma" ])
154
151
elif key == "cal_force" :
155
152
if isinstance (fp_params ["cal_force" ], str ):
156
153
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
+ )
160
157
ret += "cal_force %d\n " % fp_params ["cal_force" ] # noqa: UP031
161
158
elif key == "cal_stress" :
162
159
if isinstance (fp_params ["cal_stress" ], str ):
163
160
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
+ )
167
164
ret += "cal_stress %d\n " % fp_params ["cal_stress" ] # noqa: UP031
168
165
# paras for deepks
169
166
elif key == "deepks_out_labels" :
@@ -180,16 +177,16 @@ def make_abacus_scf_input(fp_params, extra_file_path=""):
180
177
fp_params ["deepks_descriptor_lmax" ] = int (
181
178
fp_params ["deepks_descriptor_lmax" ]
182
179
)
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
+ )
186
183
ret += "deepks_descriptor_lmax %d\n " % fp_params ["deepks_descriptor_lmax" ] # noqa: UP031
187
184
elif key == "deepks_scf" :
188
185
if isinstance (fp_params ["deepks_scf" ], str ):
189
186
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
+ )
193
190
ret += "deepks_scf %d\n " % fp_params ["deepks_scf" ] # noqa: UP031
194
191
elif key == "deepks_model" :
195
192
ret += "deepks_model {}\n " .format (
@@ -228,9 +225,9 @@ def make_abacus_scf_stru(
228
225
229
226
ret = "ATOMIC_SPECIES\n "
230
227
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
+ )
234
231
idx = type_map .index (atom_names [iatom ])
235
232
if "atom_masses" not in sys_data :
236
233
ret += (
0 commit comments