3rd order force constant(Order not in order)

Dear Hiphive users,
I was trying to read the 3rd order force constants generated from phono3py in the format of [N,N,N,3,3,3] but I am getting error that “Order not in orders”.
File “/home/sharma_ji/hiphive/3py/tst/3ord.py”, line 33, in
parameters = extract_parameters(fcs, cs)
File “/home/sharma_ji/miniconda3/lib/python3.9/site-packages/hiphive/utilities.py”, line 353, in extract_parameters
fc_original = fcs.get_fc_array(order=order)
File “/home/sharma_ji/miniconda3/lib/python3.9/site-packages/hiphive/force_constants.py”, line 116, in get_fc_array
raise ValueError(‘Order not in orders’)
ValueError: Order not in orders
I have attached the script which I am using. What is the reason for this error?
Thanks in advance.
3ord.py.txt (1.4 KB)

Note that the error is not coming from reading the force-constants but instead when your trying to extract the parameters of these force constants.

I think the error is due to the fact that you only read 3rd order FCs but your ClusterSpace is 2nd and 3rd order, meaning you are trying to extract the second order parameters but you dont have any second order FCs.

Dear @erikfransson thanks for the reply but I am still getting the same error(Order not in order). I have changed the script and tried to read both 2nd and 3rd-order force constants. I tried to extract the parameters from 2nd-order force constants this time only while reading 3rd-order force constants. Is there any way so that I can extract the parameters for the 2nd and 3rd-order force constant simultaneously?
for example parameters = extract_parameters(fcs,cs) . Can we define both force constants here as we have defined cluster space for both the second and third order? Please find the attached script below.
3ord.py.txt (1.6 KB)

You can merge the force constants into a single object and then run the extract_parameters.

So e.g. this should work for only second order

# only second order
cutoffs = [4.0]
cs = ClusterSpace(prim, cutoffs)
fcs2 = ForceConstants.read_phonopy(supercell, 'fc2.hdf5')
parameters = extract_parameters(fcs2, cs)

and I think this would work for both second and third-order fcs

# both second and third order
cutoffs = [4.0, 5.0]
cs = ClusterSpace(prim, cutoffs)
fcs2 = ForceConstants.read_phonopy(supercell, 'fc2.hdf5')
fcs3 = ForceConstants.read_phono3py(supercell, 'fc3.hdf5')
fcs_total = fcs2 + fcs3
parameters = extract_parameters(fcs_total, cs)

Note that it is probably advisable to use maximum cutoffs to extract the parameters, see here.

Dear @erikfransson thanks for the suggestion. Now, I can reconstruct the third-order force constants(FCs). After the reconstruction of FCs, I am getting the thermal conductivity at 300 K of a bulk system almost three times before reconstruction so I have a few doubts which are as follows:

  1. Force constant (FC) reconstruction error in 2nd and 3rd order is the difference between the FCs calculated without hiPhive and with hiPhive?
  2. If the Rotational sum rules after reconstruction are close to zero, does it signify better accuracy?
  3. In our calculation the reconstruction error for 2nd and 3rd-order FCs are 4.5 and 9.5 %, are these errors in acceptable limits?
  4. The calculation has been done with 2x2x2 supercell still getting 9.5 % error in 3rd-order FCs reconstruction with a maximum cut-off of 6 Å. Is there any way to reduce this error without increasing the supercell size?
  1. Yes, if you look into the code it is calculated as np.linalg.norm(fc_original-fc_reconstructed) / np.linalg.norm(fc_original)
  2. I dont understand what you mean.
  3. Those look rather large, if y ou are using the maximum cutoff for both then it suggest that your supercell may be too small.
  4. Again this suggest you may need a bigger supercell to converge the calculations. There is no quick/easy way to reduce the reconstruction error without increasing supercell size.