from hecss.monitor import plot_stats, plot_xs_stat
from hecss.monitor import plot_acceptance_history, plot_dofmu_stat
from hecss.util import select_asap_model, create_asap_calculator
from hecss.util import calc_init_xscale
from tqdm.auto import tqdm
Amplitude correction extraction
This module provides a way to extract amplitude correction matrix from the eta calculation data generated by the
estimate_width_scale
method.
LAMPS data on olivine
plot_virial_stat
plot_virial_stat (cryst, smpl, normal=True)
= select_asap_model('Universal')
model print(f'Using potential model: {model}')
= ase.io.read('data/spinel.POSCAR')
oliv = create_asap_calculator(model)
oliv.calc print(f'Space group: {spglib.get_spacegroup(get_cell_data(oliv))}')
Using potential model: LJ_ElliottAkerson_2015_Universal__MO_959249795837_003
Space group: Fd-3m (227)
= 100
N
= HECSS(oliv, lambda : create_asap_calculator(model))
sampler = sampler.estimate_width_scale(N, Tmax=1000) m, s, xscl
= np.array(sampler._eta_list).T
wm = np.sqrt((3*wm[1]*un.kB)/(2*wm[2]))
y '', 0, normal=False, df=3*len(oliv))
plot_hist(y,
plt.legend() plt.show()
plt.semilogx()=False); plot_virial_stat(oliv, sampler._eta_samples, normal
= 600
T = 1_000
N = []
dofmu = []
xsl = xscl.copy()
sampler.xscale_init = sampler.sample(T, N, dofmu_list=dofmu, xscale_list=xsl)
osamples # osamples = [s for s in tqdm(sampler._sampler(T, N,
# dofmu_list=dofmu, xscale_list=xsl), total=N)]
=False); plot_virial_stat(oliv, osamples, normal
=0, window=10) plot_dofmu_stat(oliv, dofmu, skip
=0, window=10) plot_xs_stat(oliv, xsl, skip
VASP calculations
Here we use pre-calculated vasp data for 3C-SiC 2x2x2 suprecell
# Use more realistic pre-calculated data
= '2x2x2' supercell
= ase.io.read(f'example/VASP_3C-SiC/{supercell}/sc_{supercell}/vasprun.xml') sc
= sc.get_potential_energy() e0
=0.05
eqdelta=0.2
eqsigma
= len(sc)
nat = (nat, 3)
dim =1e-5
symprec= get_symmetry_dataset(get_cell_data(sc), symprec=symprec)
symm = symm['mapping_to_primitive']
dofmap = list(sorted(set(dofmap)))
dof = np.ones((len(dof), 3))
dofmu = np.ones(dim) mu
/home/jochym/.conda/envs/dev/lib/python3.11/site-packages/spglib/spglib.py:115: DeprecationWarning: dict interface (SpglibDataset['mapping_to_primitive']) is deprecated.Use attribute interface ({self.__class__.__name__}.{key}) instead
warnings.warn(
= np.ones(dim)
xscale = np.array([xscale[dofmap==d,:].mean(axis=0) for d in dof])
dofxs = []
vt
# for i, sfn in enumerate(sorted(glob(f'TMP/calc_{supercell}/w_est/*/vasprun.xml'))):
for i, sfn in enumerate(sorted(glob(f'example/VASP_3C-SiC_calculated/calc_{supercell}/w_est/*/vasprun.xml'))):
= ase.io.read(sfn)
s = normalize_conf(s, sc)[0] - sc.get_positions()
dx try :
= s.get_forces()
f = (s.get_potential_energy() - e0)/nat
e = np.abs(dx*f)
v = dx*f
v /= v.mean()
v = np.array([v[dofmap==d,:].mean(axis=0) for d in dof])
dofv # dofxs *= (1-2*eqdelta*(expit((np.sqrt(dofmu)-1)/eqsigma)-0.5))
# dofxs /= np.sqrt((dofxs**2).mean())
-1))
vt.append(dofv.reshape(except RuntimeError:
continue
= np.array(vt).reshape(-1,2,3)
vt = vt.reshape(-1,2,3).mean(axis=-1)
vta = vta.cumsum(axis=0)
mu /= np.arange(1,len(mu)+1)[:, None] mu
# plt.semilogy()
'-')
plt.plot(mu, '.', ms=1)
plt.plot(vta, for dofn in 0, 1:
= vta[:,dofn].mean()
m = vta[:,dofn].std()
s =':', color=f'C{dofn}')
plt.axhline(m, ls-s, m+s, color=f'C{dofn}', alpha=0.2)
plt.axhspan(m-1] mu[
array([1.01036281, 0.98963719])
=np.linspace(0.5,1.5,100)
xfor dofn in 0, 1:
= vt[:,dofn,:].mean(axis=-1).reshape(-1)
rv =True, bins='auto',
plt.hist(rv, density=f'C{dofn}', alpha=0.33, label=f'{dofn}')
color= chi.fit(rv, f0=12)
fit *fit), ls=':', color=f'C{dofn}')
plt.plot(x, chi.pdf(x, = norm.fit(rv)
fit *fit), ls='-', color=f'C{dofn}') plt.plot(x, norm.pdf(x,