# semilogx()
=(10,6))
plt.figure(figsize= stats.norm
rv = 100_000
N = plan_T_scan(50, 250, 32, N)
plan
= np.zeros(0)
el for c, (l, s, n) in enumerate(tqdm(plan)):
= np.append(el, rv.rvs(loc=l, scale=s, size=n))
el
= len(el)//2000
skip = int(max(1, skip))
skip for s in el[::skip]:
=0.95, ymax=0.98, ls='-', color='r', alpha=0.1)
plt.axvline(s, ymin
= sum([sf for _, _, sf in plan])
NF = np.histogram(el, bins='auto', density=True)
counts, bins -1], bins, weights=NF*counts, color='C0', alpha=0.3); plt.hist(bins[:
Temperature scan planner
plan_T_scan
plan_T_scan (Tlo, Thi, nat, N=1, plot_dist=True)
Simulate with stats.normal
random variable
Run with HECSS
sampler
from hecss.core import HECSS
from hecss.util import select_asap_model, create_asap_calculator
from hecss.optimize import make_sampling
from hecss.monitor import plot_stats
= select_asap_model('SiC')
model print(f'Using potential model: {model}')
= '3x3x3'
sys_size = [int(v) for v in sys_size.split('x')]
sc
= bulk('SiC', crystalstructure='zincblende',
cryst =4.38120844, cubic=True).repeat(tuple(sc))
a= create_asap_calculator(model)
cryst.calc = HECSS(cryst, lambda : create_asap_calculator(model), pbar=False)
hecss 10, Tmax=1000); hecss.estimate_width_scale(
Using potential model: MEAM_LAMMPS_KangEunJun_2014_SiC__MO_477506997611_000
= 1_000
N =(10,6))
plt.figure(figsize= plan_T_scan(150, 250, len(cryst), N) plan
= {}
smpls for T, sig, n in tqdm(plan):
# sampler = HECSS_Sampler(cryst, asap3.OpenKIMcalculator(model),
# T, N=int(n), pbar=tqdm(total=n))
=np.array([s[-1] for s in hecss._sampler_ser(T, n)])
smpls[T]# ell = [np.array([s[-1] for s in sl]) for sl in smpls.values()]
= np.concatenate(list(smpls.values()))
ell = ell.min()
e_min = ell.max() e_max
for T, el in smpls.items():
=50, histtype='step', label=f'{T=:.0f}K', range=(e_min, e_max))
plt.hist(el, bins=50, stacked=True, color='C0', alpha=0.25, range=(e_min, e_max))
plt.hist(ell, bins; plt.legend()
=(10,6))
plt.figure(figsizeif N < 10_000:
= np.linspace(e_min, e_max, 50)*2/un.kB/3
bins else :
= 'auto'
bins = plt.hist(ell*2/un.kB/3,
cnt, bins, _ =bins, density=False, alpha=0.6, label='Total');
bins= np.linspace(bins[0], bins[-1], 300)
x = np.zeros(x.shape)
y = bins[1]-bins[0]
tdx for c, ((T, el), (Tp, sig, n)) in enumerate(zip(smpls.items(), plan)):
# bins = 'auto'
= el*2/un.kB/3
e = plt.hist(e, bins=bins, density=False,
Tc, Tb, _ ='step', color=f'C{c+1}');
histtype= Tb[1]-Tb[0]
dx # plt.plot(x, dx*n*stats.norm.pdf(x, loc=T, scale=sig), color=f'C{c+1}',
# label=f'{T=:.1f}K (N={int(Tc.sum())})')
# y += tdx*n*stats.norm.pdf(x, loc=T, scale=sig)
= stats.norm.fit(e)
fit *n*stats.norm.pdf(x, *fit), color=f'C{c+1}',
plt.plot(x, dx=f'{T=:.1f}K (N={int(Tc.sum())})')
label
+= tdx*n*stats.norm.pdf(x, *fit)
y
= len(el)//500
skip = max(1, skip)
skip for v in e[::skip]:
=0.95, ymax=0.98, ls='-', color='r', alpha=0.05)
plt.axvline(v, ymin
'--', label='Total')
plt.plot(x, y, 'Temperature (K)')
plt.xlabel(='upper right')
plt.legend(loc'Temperature scan - HECSS generated energies.')
plt.title(
plt.grid()f'AUX/T_scan_{N=}.pdf') plt.savefig(
Test temperature scanning planner
= 1000
N =(8,4))
plt.figure(figsize= plan_T_scan(200, 400, len(cryst), N)
plan 'AUX/T_scan_plan.pdf', bbox_inches='tight') plt.savefig(
= []
smpll for T, sig, n in tqdm(plan):
for s in hecss.sample(T, n)])
smpll.append([s = [[s[-1] for s in sl] for sl in smpll] ell
= []
usmp for sl in smpll:
+= sl usmp
=(8,4))
plt.figure(figsize-1] for s in usmp], bins='auto', density=True)
plt.hist([s['Potential energy (meV/at)')
plt.xlabel('Probability density (meV/at)$^{-1}$')
plt.ylabel('Temperatures: 200-400K')
plt.title(f'AUX/uniform.pdf', bbox_inches='tight') plt.savefig(
= 273
T = make_sampling(usmp, T, N=4*N, nonzero_w=False, debug=True)
wd print(len(usmp), len(wd))
='upper right', bbox_to_anchor=(1.0, 0.95))
plt.legend(loc;
plt.show()=True, show=False)
plot_stats(wd, T, sqrNf'AUX/T_scan_{T=:.0f}K.pdf', bbox_inches='tight') plt.savefig(
3448 3945
=(10,6))
plt.figure(figsizeif N < 1_000:
= np.linspace(min(flatten(ell)), max(flatten(ell)), 40)*2/un.kB/3
bins else :
= 'auto'
bins = plt.hist(np.array(list(flatten(ell)))*2/un.kB/3,
cnt, bins, _ =50, density=False, alpha=0.3, label='Total');
bins= np.linspace(bins[0], bins[-1], 300)
x = np.zeros(x.shape)
y = bins[1]-bins[0]
tdx for c, (el, (T, sig, n)) in enumerate(zip(ell, plan)):
= np.array(el)
e = 'auto'
bins = plt.hist(e*2/un.kB/3, bins=bins, density=False,
Tc, Tb, _ ='step', color=f'C{c+1}');
histtype= Tb[1]-Tb[0]
dx = np.sum(Tc)*dx
nf # plt.plot(x, dx*n*stats.norm.pdf(x, loc=T, scale=sig), color=f'C{c+1}',
# label=f'{T=:.1f}K (N={int(Tc.sum())})')
# y += tdx*n*stats.norm.pdf(x, loc=T, scale=sig)
= stats.logistic.fit(e*2/un.kB/3)
fit *stats.logistic.pdf(x, *fit), color=f'C{c+1}',
plt.plot(x, nf=f'{T=:.1f}K (N={int(Tc.sum())})')
label+= nf*stats.logistic.pdf(x, *fit)
y
= len(el)//1000
skip = max(1, skip)
skip for v in e[::skip]*2/un.kB/3:
=0.95, ymax=0.98, ls='-', color='r', alpha=0.05)
plt.axvline(v, ymin
'--', label='Plan (total)')
plt.plot(x, y, 'Temperature (K)')
plt.xlabel(='upper right')
plt.legend(loc'Temperature scan - HECSS generated energies.')
plt.title(
plt.grid()f'AUX/T_scan_{N=}.pdf') plt.savefig(
= np.linspace(-5, 5, 100)
x
plt.plot(x, stats.norm.pdf(x))
plt.grid()1/8)
plt.axhline(3+2*np.sqrt(2)))
plt.axvline(np.log(3-2*np.sqrt(2)))
plt.axvline(np.log(
plt.plot(x, stats.logistic.pdf(x))=2
s=s))
plt.plot(x, stats.logistic.pdf(x, scale1/(8*s))
plt.axhline(*np.log(3+2*np.sqrt(2)))
plt.axvline(s*np.log(3-2*np.sqrt(2))) plt.axvline(s
= np.linspace(0, 15, 300)
x = np.zeros(x.shape)
y = np.log(3+2*np.sqrt(2))
a = 1.4
a = 3
x0 = 1/8
b = 1
nf while x0 < 15:
= x0*b
s if x0*(1+b*a)/(1-b*a) > 15:
= 1.3
nf *= 1.05
x0 =nf*s*stats.logistic.pdf(x, loc=x0, scale=s)
yy
plt.plot(x,yy)+= yy
y *= (1+a*b)/(1-a*b)
x0
plt.plot(x,y)1/4); plt.axhline(1/8) plt.axhline(
# semilogx()
=(10,6))
plt.figure(figsize= stats.norm
rv = 1_000_000
N = plan_T_scan(50, 250, 32, N)
plan
= np.zeros(0)
el for c, (l, s, n) in enumerate(tqdm(plan)):
= np.append(el, rv.rvs(loc=l, scale=s, size=n))
el
= len(el)//2000
skip = int(max(1, skip))
skip for s in el[::skip]:
=0.95, ymax=0.98, ls='-', color='r', alpha=0.1)
plt.axvline(s, ymin
= sum([sf for _, _, sf in plan])
NF = np.histogram(el, bins='auto', density=True)
counts, bins -1], bins, weights=NF*counts, color='C0', alpha=0.3); plt.hist(bins[: