def fcn2min(params, x, data): shape = params['shape'].value scale = params['scale'].value loc = params['loc'].value # m = params['f_shape'].value # sV0 = params['f_scale'].value sV0 = 0.0076 m = 6.7 tau = RV('gamma', shape=shape, scale=scale, loc=loc) n_int = 500 p_arr = np.linspace(0.5 / n_int, 1 - 0.5 / n_int, n_int) tau_arr = tau.ppf(p_arr) + 1e-10 r = 3.5e-3 E_f = 182e3 T = 2. * tau_arr / r # scale parameter with respect to a reference volume s = ((T * (m + 1.) * sV0 ** m) / (2. * E_f * pi * r ** 2)) ** (1. / (m + 1.)) ef0 = np.sqrt(x[:, np.newaxis] * T[np.newaxis, :] / E_f) Gxi = 1 - np.exp(-(ef0 / s) ** (m + 1.)) mu_int = ef0 * (1 - Gxi) sigma = mu_int * E_f return np.sum(sigma, axis=1) / n_int * (11. * 0.445) / 1000 - data
def fcn2min(shape, scale, loc, x): # shape = params['shape'].value # scale = params['scale'].value # loc = params['loc'].value # m = params['f_shape'].value # sV0 = params['f_scale'].value sV0 = 0.0069 m = 7.1 tau = RV('gamma', shape=shape, scale=scale, loc=loc) n_int = 500 p_arr = np.linspace(0.5 / n_int, 1 - 0.5 / n_int, n_int) tau_arr = tau.ppf(p_arr) + 1e-10 r = 3.5e-3 E_f = 180e3 # lm = 1000 # # def cdf(e, depsf, r, lm, m, sV0): # '''weibull_fibers_cdf_mc''' # s = ((depsf * (m + 1.) * sV0 ** m) / # (2. * pi * r ** 2.)) ** (1. / (m + 1.)) # a0 = (e + 1e-15) / depsf # expfree = (e / s) ** (m + 1.) # expfixed = a0 / \ # (lm / 2.0) * (e / s) ** (m + 1) * \ # (1. - (1. - lm / 2.0 / a0) ** (m + 1.)) # print expfree # print expfixed # mask = a0 < lm / 2.0 # exp = expfree * mask + \ # np.nan_to_num(expfixed * (mask == False)) # return 1. - np.exp(- exp) # # T = 2. * tau_arr / r + 1e-10 # ef0cb = np.sqrt(x[:, np.newaxis] * T[np.newaxis, :] / E_f) # ef0lin = x[:, np.newaxis] / lm + \ # T[np.newaxis, :] * lm / 4. / E_f # depsf = T / E_f # a0 = ef0cb / depsf # mask = a0 < lm / 2.0 # e = ef0cb * mask + ef0lin * (mask == False) # Gxi = cdf(e, depsf, r, lm, m, sV0) # mu_int = e * (1. - Gxi) # sigma = mu_int * E_f T = 2. * tau_arr / r # scale parameter with respect to a reference volume s = ((T * (m + 1.) * sV0 ** m) / (2. * E_f * pi * r ** 2)) ** (1. / (m + 1.)) ef0 = np.sqrt(x[:, np.newaxis] * T[np.newaxis, :] / E_f) Gxi = 1 - np.exp(-(ef0 / s) ** (m + 1.)) mu_int = ef0 * (1 - Gxi) sigma = mu_int * E_f return np.sum(sigma, axis=1) / n_int * (11. * 0.445) / 1000
def fcn2min(params, x, data): """ model decaying sine wave, subtract data""" shape = params['shape'].value scale = params['scale'].value m = params['f_shape'].value sV0 = params['f_scale'].value # m = 8.806672387136711 # sV0 = 0.013415768576509945 # sV0 = 3243. / \ # (182e3 * (pi * 3.5e-3 ** 2 * 50.) ** (-1. / m) * gamma(1 + 1. / m)) # shape = 0.0505 # scale = 2.276 # CS = 12. # mu_tau = 1.3 * 3.5e-3 * 3.6 * (1. - 0.01) / (2. * 0.01 * CS) # scale = mu_tau / shape tau = RV('gamma', shape=shape, scale=scale, loc=0.) n_int = 500 p_arr = np.linspace(0.5 / n_int, 1 - 0.5 / n_int, n_int) tau_arr = tau.ppf(p_arr) + 1e-10 r = 3.5e-3 E_f = 180e3 lm = 1000. def cdf(e, depsf, r, lm, m, sV0): '''weibull_fibers_cdf_mc''' s = ((depsf * (m + 1.) * sV0 ** m) / (2. * pi * r ** 2.)) ** (1. / (m + 1.)) a0 = (e + 1e-15) / depsf expfree = (e / s) ** (m + 1) expfixed = a0 / \ (lm / 2.0) * (e / s) ** (m + 1) * \ (1. - (1. - lm / 2.0 / a0) ** (m + 1.)) mask = a0 < lm / 2.0 exp = expfree * mask + \ np.nan_to_num(expfixed * (mask == False)) return 1. - np.exp(- exp) T = 2. * tau_arr / r + 1e-10 ef0cb = np.sqrt(x[:, np.newaxis] * T[np.newaxis, :] / E_f) ef0lin = x[:, np.newaxis] / lm + \ T[np.newaxis, :] * lm / 4. / E_f depsf = T / E_f a0 = ef0cb / depsf mask = a0 < lm / 2.0 e = ef0cb * mask + ef0lin * (mask == False) Gxi = cdf(e, depsf, r, lm, m, sV0) mu_int = e * (1. - Gxi) sigma = mu_int * E_f return np.sum(sigma, axis=1) / n_int * (11. * 0.445) / 1000 - data
def func1(w_arr, k): tau = RV('gamma', shape=k, scale=scale, loc=0.) n_int = 500 p_arr = np.linspace(0.5 / n_int, 1 - 0.5 / n_int, n_int) tau_arr = tau.ppf(p_arr) + 1e-10 # sV0 = sV0 # m = m r = 3.5e-3 E_f = 180e3 lm = 1000. def cdf(e, depsf, r, lm, m, sV0): '''weibull_fibers_cdf_mc''' s = ((depsf * (m + 1.) * sV0 ** m) / (2. * pi * r ** 2.)) ** (1. / (m + 1.)) a0 = (e + 1e-15) / depsf expfree = (e / s) ** (m + 1.) expfixed = a0 / \ (lm / 2.0) * (e / s) ** (m + 1.) * \ (1. - (1. - lm / 2.0 / a0) ** (m + 1.)) mask = a0 < lm / 2.0 exp = expfree * mask + \ np.nan_to_num(expfixed * (mask == False)) return 1. - np.exp(- exp) T = 2. * tau_arr / r + 1e-10 ef0cb = np.sqrt(w_arr[:, np.newaxis] * T[np.newaxis, :] / E_f) ef0lin = w_arr[:, np.newaxis] / lm + \ T[np.newaxis, :] * lm / 4. / E_f depsf = T / E_f a0 = ef0cb / depsf mask = a0 < lm / 2.0 e = ef0cb * mask + ef0lin * (mask == False) Gxi = cdf(e, depsf, r, lm, m, sV0) # plt.plot(w_arr, np.average(Gxi, axis=1), label='s='+str(s)+'m='+str(m)) mu_int = e * (1. - Gxi) sigma = mu_int * E_f return np.sum(sigma, axis=1) / n_int * (11. * 0.445) / 1000
def lackoffit(m, sV0, shape, scale, x, data): """ model decaying sine wave, subtract data""" tau = RV('gamma', shape=shape, scale=scale, loc=0.) n_int = 500 p_arr = np.linspace(0.5 / n_int, 1 - 0.5 / n_int, n_int) tau_arr = tau.ppf(p_arr) + 1e-10 r = 3.5e-3 E_f = 180e3 lm = 1000. def cdf(e, depsf, r, lm, m, sV0): '''weibull_fibers_cdf_mc''' s = ((depsf * (m + 1.) * sV0 ** m) / (2. * pi * r ** 2.)) ** (1. / (m + 1.)) a0 = (e + 1e-15) / depsf expfree = (e / s) ** (m + 1.) expfixed = a0 / \ (lm / 2.0) * (e / s) ** (m + 1.) * \ (1. - (1. - lm / 2.0 / a0) ** (m + 1.)) mask = a0 < lm / 2.0 exp = expfree * mask + \ np.nan_to_num(expfixed * (mask == False)) return 1. - np.exp(- exp) T = 2. * tau_arr / r + 1e-10 ef0cb = np.sqrt(x[:, np.newaxis] * T[np.newaxis, :] / E_f) ef0lin = x[:, np.newaxis] / lm + \ T[np.newaxis, :] * lm / 4. / E_f depsf = T / E_f a0 = ef0cb / depsf mask = a0 < lm / 2.0 e = ef0cb * mask + ef0lin * (mask == False) Gxi = cdf(e, depsf, r, lm, m, sV0) mu_int = e * (1. - Gxi) sigma = mu_int * E_f residual = np.sum(sigma, axis=1) / n_int * (11. * 0.445) / 1000 - data return np.sum(residual ** 2)
def fcn2min(x): """ model decaying sine wave, subtract data""" shape = 0.0539 scale = 1.44 loc = 0.00126 m = 6.7 sV0 = 0.0076 tau = RV('gamma', shape=shape, scale=scale, loc=loc) n_int = 500 p_arr = np.linspace(0.5 / n_int, 1 - 0.5 / n_int, n_int) tau_arr = tau.ppf(p_arr) + 1e-10 r = 3.5e-3 E_f = 180e3 T = 2. * tau_arr / r # scale parameter with respect to a reference volume s = ((T * (m + 1.) * sV0 ** m) / (2. * E_f * pi * r ** 2)) ** (1. / (m + 1.)) ef0 = np.sqrt(x[:, np.newaxis] * T[np.newaxis, :] / E_f) Gxi = 1 - np.exp(-(ef0 / s) ** (m + 1.)) mu_int = ef0 * (1 - Gxi) sigma = mu_int * E_f return np.sum(sigma, axis=1) / n_int * (11. * 0.445) / 1000