Exemple #1
0
'''

# Imports
from eosfit import EOS, EOSmodel
import numpy as np

# Data
V = np.array([8., 8.5, 9., 9.6, 10.2, 10.9, 11.6, 12.2, 13., 13.8, 14.5]) # [Ang^3]
E = np.array([-4.65, -5.05, -5.3, -5.48, -5.57, -5.59, -5.575, -5.5, -5.4, -5.3, -5.18]) # [eV/atom]

plotflag = True

# MU4 model
eos1 = EOS(V, E, ID='MU4')
p0 = [12., -3., 1., 5.] # Order [V0, E0, B0, B0']
V0_MU4, E0_MU4, B0_MU4 = eos1.fit(p0) # Initial guess required (nonlinear model)
ci_MU4 = eos1.get_ci()
E_MU4 = eos1.eval()
R2_MU4 = eos1.get_rsquared()
if plotflag:
    eos1.plot(filename='eosfit_example_MU4.png')
print '''MU4
===
V0 = {0} Ang^3
E0 = {1} eV/atom
B0 = {2} GPa
ci = {3}
E = {4} eV/atom
R^2 = {5}
'''.format(V0_MU4, E0_MU4, B0_MU4*160.217, ci_MU4, E_MU4, R2_MU4)
Exemple #2
0
===========================
- Fits data to linear EOS model
- Gets confidence intervals of fitting parameters for linear model
- Plots distribution (histogram) of physical parameters
'''

# Imports
from eosfit import EOS, EOSmodel
import numpy as np

# Data
V = np.array([8., 8.5, 9., 9.6, 10.2, 10.9, 11.6, 12.2, 13., 13.8, 14.5]) # [Ang^3]
E = np.array([-4.65, -5.05, -5.3, -5.48, -5.57, -5.59, -5.575, -5.5, -5.4, -5.3, -5.18]) # [eV/atom]

# Construct EOS model
eos = EOS(V, E, ID='BM4', model=EOSmodel.BM4)
V0_BM4, E0_BM4, B0_BM4 = eos.fit() # No need for initial guess (linear model)
ci_BM4 = eos.get_phys_ci() # Done via simulation (need many samples for good statistical representation)
print '''BM4
===
V0 = {0} Ang^3
E0 = {1} eV/atom
B0 = {2} GPa
phys ci = {3}
'''.format(V0_BM4, E0_BM4, B0_BM4*160.217, ci_BM4)

# Plot distributions
eos.plot_hist_V0('eosfit_example_BM4_V0_dist.png')
eos.plot_hist_E0('eosfit_example_BM4_E0_dist.png')
eos.plot_hist_B0('eosfit_example_BM4_B0_dist.png')
eos.plot_hist_B0p('eosfit_example_BM4_B0p_dist.png')
Exemple #3
0
'''
Test file for module eosfit
'''

# Imports
from eosfit import EOS, EOSmodel
import numpy as np
import matplotlib.pyplot as plt

V = np.array([8., 8.5, 9., 9.6, 10.2, 10.9, 11.6, 12.2, 13., 13.8, 14.5])
E = np.array([-4.65, -5.05, -5.3, -5.48, -5.57, -5.59, -5.575, -5.5, -5.4, -5.3, -5.18])

# MU4 model
eos = EOS(V, E)
p0 = [-6., 2., 5, 10.]
pMU4 = eos.fit(p0) # Initial guess required (nonlinear model)
ciMU4 = eos.get_ci()
EMU4 = eos.MU4(V, pMU4[0], pMU4[1], pMU4[2], pMU4[3])
print pMU4, ciMU4, EMU4

# BM5 model
eos.set_model(EOSmodel.BM5)
pBM5 = eos.fit() # No initial guess required (linear model)
ciBM5 = eos.get_ci()
EBM5 = eos.BM5(V, pBM5[0], pBM5[1], pBM5[2], pBM5[3], pBM5[4])
print pBM5, ciBM5, EBM5

# Plot results
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(V,E,marker='o',markersize=10,color='r',linestyle='')
Exemple #4
0
- Fits data to two EOS models (linear and nonlinear)
- Gets confidence intervals of physical parameters for linear model
- Uses physical parameters estimated from linear model as initial guess for fitting nonlinear model
'''

# Imports
from eosfit import EOS, EOSmodel
import numpy as np

# Data
V = np.array([8., 8.5, 9., 9.6, 10.2, 10.9, 11.6, 12.2, 13., 13.8, 14.5]) # [Ang^3]
E = np.array([-4.65, -5.05, -5.3, -5.48, -5.57, -5.59, -5.575, -5.5, -5.4, -5.3, -5.18]) # [eV/atom]

# Linear EOS model
eos1 = EOS(V, E, ID='mBM4', model=EOSmodel.mBM4)
V0_mBM4, E0_mBM4, B0_mBM4 = eos1.fit() # No need for initial guess (linear model)
ci_mBM4 = eos1.get_phys_ci()
print '''mBM4
===
V0 = {0} Ang^3
E0 = {1} eV/atom
B0 = {2} GPa
phys ci = {3}
'''.format(V0_mBM4, E0_mBM4, B0_mBM4*160.217, ci_mBM4)

# Nonlinear EOS model
eos2 = EOS(V, E, ID='VI4', model=EOSmodel.VI4)
p0 = [V0_mBM4, E0_mBM4, B0_mBM4, eos1.get_B0p()] # Initial guesses from fitting linear model
V0_VI4, E0_VI4, B0_VI4 = eos2.fit(p0) # Provide custom initial guesses
ci_VI4 = eos2.get_ci()
print '''VI4