Skip to content

Commit

Permalink
Fixed qha-extract script
Browse files Browse the repository at this point in the history
  • Loading branch information
abelcarreras committed May 6, 2021
1 parent 6d59d92 commit 0a8da10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dynaphopy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.17.7'
__version__ = '1.17.8'

import numpy as np
import matplotlib.pyplot as plt
Expand Down
4 changes: 3 additions & 1 deletion dynaphopy/interface/iofile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,9 @@ def read_parameters_from_input_file(file_name, number_of_dimensions=3):
print (file_name + ' file does not exist')
exit()

input_file = open(file_name, "r").readlines()
with open(file_name, "r") as f:
input_file = f.readlines()

for i, line in enumerate(input_file):
if line[0] == '#':
continue
Expand Down
10 changes: 7 additions & 3 deletions scripts/qha_extract
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ if args.p:
phonopy_qha.plot_qha().show()

volume_temperature = phonopy_qha.get_volume_temperature()
qha_temperatures = phonopy_qha._qha._temperatures[:phonopy_qha._qha._max_t_index]

qha_temperatures = phonopy_qha._qha._all_temperatures[:len(volume_temperature)]

# Fit force constants as a function of the temperature
fit_vt = interp1d(qha_temperatures, volume_temperature, kind='quadratic')
Expand Down Expand Up @@ -129,7 +128,12 @@ force_constants_mat = np.array(force_constants_mat).T
f_temperature = interp1d(volumes, force_constants_mat, kind='quadratic')

# Get force constants at the requested temperature
target_fc = f_temperature(target_volume).T
try:
target_fc = f_temperature(target_volume).T
except ValueError:
print('Error interpolating minimum volume!\n'
'Make sure the free energy-volume curve has a minimum ')
exit()

phonopy_link.write_FORCE_CONSTANTS(target_fc,filename=args.sfc)

Expand Down

0 comments on commit 0a8da10

Please sign in to comment.