Unable to read force_constant

Dear hiPhive developer,

I am a new user of hiPhive and would like to apply the rotational sum rule on the 2nd order force constant of two-dimensional material. After getting the force_constants.hdf5 file by phonopy I used the following script to generate a further corrected force file.

from ase.io import read
from hiphive import ClusterSpace, ForceConstantPotential, enforce_rotational_sum_rules
from hiphive.cutoffs import estimate_maximum_cutoff
from hiphive.utilities import extract_parameters
from hiphive import ForceConstants, ClusterSpace, ForceConstantPotential
from hiphive import enforce_rotational_sum_rules
from hiphive.utilities import extract_parameters

prim = read(‘POSCAR’)
supercell = read(‘SPOSCAR’)
max_cutoff = estimate_maximum_cutoff(supercell) - 0.01
cutoffs = [max_cutoff] # only second order needed
cs = ClusterSpace(prim, cutoffs)
fcs = ForceConstants.read_phonopy(supercell,‘force_constants.hdf5’)
parameters = extract_parameters(fcs, cs)
parameters_rot = enforce_rotational_sum_rules(cs, parameters, [‘Huang’, ‘Born-Huang’])
fcp = ForceConstantPotential(cs, parameters_rot)
fcs = fcp.get_force_constants(supercell)
fcs.write_to_phonopy(‘fc2_rotinv.hdf5’, format=‘hdf5’)

But error occurred
Traceback (most recent call last):
** File “Fconversion”, line 18, in **
** fcs = ForceConstants.read_phonopy(supercell,‘force_constants.hdf5’)**
** File “/iitjhome/kukreti1/.local/lib/python3.8/site-packages/hiphive-1.1-py3.8.egg/hiphive/force_constants.py”, line 348, in read_phonopy**
** File “/iitjhome/kukreti1/.local/lib/python3.8/site-packages/hiphive-1.1-py3.8.egg/hiphive/force_constants.py”, line 288, in from_arrays**
ValueError: fc2 array has wrong shape

I am unable to solve this issue. Kindly tell me the way so that I can get corrected force constants.

Thank You

Sumit Kukreti
Ph.D. Scholar

The ValueError comes from the fc2_array.shape != (n_atoms, n_atoms, 3, 3).
So I think its likely that your force_constants.hdf5 is written in a compact format and can be fixed in phonopy by adding a flag, see the phonopy doc.

If this is not the problem then it could be due to providing the wrong (too large or small) supercell which could cause this error.

Thank you, sir,
Now it worked after considering full force constants.
Yes, I took compact format which is a default that is why the error occurred.

1 Like