Created
June 9, 2016 23:07
-
-
Save nicoguaro/31ca0a972a8cf1fc728251302ae08f60 to your computer and use it in GitHub Desktop.
Fitting experimental data to a Neo-Hookean solid.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Compute the material parameters for a neo-hookean solid from | |
data obtained from a uniaxial stress test. The used expressions | |
are from _[1] | |
@author: Nicolas Guarin-Zapata | |
References | |
---------- | |
..[1] Neo-Hookean solid. (2016, April 9). In Wikipedia, The Free | |
Encyclopedia. Retrieved 22:28, June 9, 2016, from | |
https://en.wikipedia.org/w/index.php?title=Neo-Hookean_solid&oldid=714459225 | |
""" | |
from __future__ import division | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.optimize import fsolve, minimize | |
def jaco(J, C1, D1, lam): | |
return D1*J**5 - D1*J**2 + C1/(3*lam)*J - C1*lam**2/3 | |
def fun(C1, D1, lams): | |
J_vec = np.ones_like((lams)) | |
for k, lam in enumerate(lams): | |
aux = fsolve(jaco, 1.0, args=(C1, D1, lam)) | |
J_vec[k] = aux | |
return 4*C1/(3*J_vec**(5/3))*(lams - J_vec/lams) +\ | |
2*D1*(J_vec - 1) | |
def error_fun(x, lams, sigmas): | |
C1, D1 = x | |
S = fun(C1, D1, lams) | |
return np.linalg.norm(S - sigmas)**2 | |
C1, D1 = [3/4, 1/4] | |
lams = np.linspace(1, 5, 50) | |
sigmas = fun(C1, D1, lams) | |
sol = minimize(error_fun, (2, 2), args=(lams, sigmas), method='Nelder-Mead') | |
sigmas_fit = fun(sol.x[0], sol.x[1], lams) | |
plt.plot(lams, sigmas, 'ko') | |
plt.plot(lams, sigmas_fit, 'r') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment