Skip to content

Commit fa1c0fc

Browse files
committed
Unify return value in postprocess of vibration model
1 parent e4b0286 commit fa1c0fc

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

abacustest/lib_model/model_019_vibration.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def run_postprocess(self,params):
106106
raise ValueError("No job specified, please use -j or --job to specify the job paths.")
107107

108108
if len(params.temperature) == 1:
109-
temperature = params.temperature[0]
109+
temperature = [params.temperature[0]]
110110
elif len(params.temperature) == 3:
111111
t_start, t_end, t_num = params.temperature
112112
t_num = int(t_num)
@@ -179,7 +179,7 @@ def prepare_abacus_vibration_analysis(job_path: Path,
179179
copy_abacusjob(job_path, disped_stru_job_path, input_file=False, stru=False)
180180

181181
displaced_stru_coord[selected_atom][dire_idx] = original_stru_coord[selected_atom][dire_idx] + stepsize * STEP_MAP[step]
182-
displaced_stru.set_coords(displaced_stru_coord, direct=False)
182+
displaced_stru.coords = displaced_stru_coord
183183
WriteInput(input_params, os.path.join(disped_stru_job_path, "INPUT"))
184184
displaced_stru.write(os.path.join(disped_stru_job_path, stru_file))
185185

@@ -241,7 +241,7 @@ def dump_cache_forces_json(stru: AbacusSTRU,
241241
return vib_cache_dir
242242

243243
def post_abacus_vibration_analysis_onejob(work_dir: Path,
244-
temperature: float = 298.15):
244+
temperature: List[float] = [298.15]):
245245
"""
246246
Post-process ABACUS vibration analysis results for one job.
247247
"""
@@ -284,23 +284,14 @@ def post_abacus_vibration_analysis_onejob(work_dir: Path,
284284
vib_energies_float = [float(np.linalg.norm(i)) for i in vib_energies]
285285
zero_point_energy = sum(vib_energies_float) / 2
286286
thermo = HarmonicThermo(vib_energies, ignore_imag_modes=True)
287-
288-
if isinstance(temperature, float):
289-
entropy = thermo.get_entropy(temperature)
290-
free_energy = thermo.get_helmholtz_energy(temperature)
291287

292-
return {'frequencies': freqs,
293-
'zero_point_energy': float(zero_point_energy),
294-
'vib_entropy': float(entropy),
295-
'vib_free_energy': float(free_energy)}
296-
else:
297-
thermo_corr = {}
298-
for t in temperature:
299-
entropy = thermo.get_entropy(t)
300-
free_energy = thermo.get_helmholtz_energy(t)
301-
thermo_corr[f'{t}K'] = {'entropy': float(entropy),
302-
'free_energy': float(free_energy)}
303-
304-
return {'frequencies': freqs,
305-
'zero_point_energy': float(zero_point_energy),
306-
'thermo_corr': thermo_corr}
288+
thermo_corr = {}
289+
for t in temperature:
290+
entropy = thermo.get_entropy(t)
291+
free_energy = thermo.get_helmholtz_energy(t)
292+
thermo_corr[f'{t}K'] = {'entropy': float(entropy),
293+
'free_energy': float(free_energy)}
294+
295+
return {'frequencies': freqs,
296+
'zero_point_energy': float(zero_point_energy),
297+
'thermo_corr': thermo_corr}

0 commit comments

Comments
 (0)