4th order effective harmonic model

Dear developers,
I want to calculate thermal conductivity based on the renormalized IFCs, so I wonder if we can construct a 4th order effective harmonic model from MD snapshots using Hiphive?
Kind regards,
Junwei

What do you mean by 4th order effective harmonic model?
Harmonic models are by definition only second order.

Sorry, I didn’t make my question clear. I got the renormalized 2nd and 3rd order IFCs with the script below, so can we get the renormalized 4th order IFCs in Hiphive?

import os
import numpy as np
import warnings
from ase.io import read
from hiphive import ClusterSpace, StructureContainer, ForceConstantPotential
from trainstation import Optimizer

warnings.filterwarnings(“ignore”, category=DeprecationWarning)

temperatures = [1500, 1600, 1700, 1800]
cutoffs = [8.0, 5.0]

for T in temperatures:
structures = read(‘md_runs/snapshots_T{:}.xyz’.format(T), index=‘:’)

cs = ClusterSpace(structures[0], cutoffs)
sc = StructureContainer(cs)
for s in structures:
    sc.add_structure(s)

# set up
inds2 = cs.get_parameter_indices(order=2)
inds3 = cs.get_parameter_indices(order=3)
assert cs.n_dofs == len(inds2) + len(inds3)
A, y = sc.get_fit_data()

# train fc2
opt = Optimizer((A[:, inds2], y), train_size=1.0)
opt.train()
print(opt)
params_2 = opt.parameters
y2 = y - np.dot(A[:, inds2], opt.parameters)

# train fc3
opt = Optimizer((A[:, inds3], y2), train_size=1.0)
opt.train()
print(opt)
params_3 = opt.parameters

# combine parameters from both fits
params = np.zeros(cs.n_dofs)
params[inds2] = params_2
params[inds3] = params_3

# make fcp
fcp = ForceConstantPotential(cs, params)

# save fcp file
output_directory = 'fcps'
if not os.path.exists(output_directory):
   os.makedirs(output_directory)

fcp.write(os.path.join(output_directory, '3rd_ehm_T{}.fcp'.format(T)))

Yes thats possible, you just need to make the ClusterSpace bigger to contain fourth-order terms, see documention

and if you’re doing sequential fitting then you would need to add similar code snippet for the fourth-order parameters as you already have in your script.

Thank you so much.