def lacor(): from stats.misc.random_field.random_field_1D import RandomField rf = RandomField() x = np.linspace(0,30, 200) y = rf.acor(x,10.) yy = rf.acor(x,3.0) plt.plot(x, y, color = 'black', lw = 2) plt.plot(x, yy, color = 'black', lw = 2) plt.xticks(fontsize = 20) plt.yticks(fontsize = 20) plt.show()
def random_field(): rf = RandomField(lacor=3., length=500., nx=500, distr_type='Weibull', shape=12., scale=5.0, loc=0.0) plt.plot(rf.xgrid, rf.random_field, lw=1, color='grey', label='Weibull') rf.lacor = 10.0 plt.plot(rf.xgrid, rf.random_field, lw=2, color='black', label='Weibull') plt.ylim(0)
def strength(): length = 2000. nx = 2000 cracks = [] strengths = [] maxsigma = [12., 15., 20., 22., 24.] Vfs = [0.05, 0.01, 0.013, 0.017, 0.02] for i, Vf in enumerate(Vfs): random_field = RandomField( seed=False, lacor=5.0, length=length, nx=800, nsim=1, loc=.0, shape=8., scale=3.2, ) reinf1 = ContinuousFibers(r=0.0035, tau=RV('weibull_min', loc=0.0, shape=1., scale=0.03), V_f=Vf, E_f=180e3, xi=fibers_MC(m=5.0, sV0=0.003), label='carbon', n_int=500) CB_model = CompositeCrackBridge( E_m=25e3, reinforcement_lst=[reinf1], ) scm = SCM( length=length, nx=nx, random_field=random_field, CB_model=CB_model, load_sigma_c_arr=np.linspace(0.01, maxsigma[i], 100), ) scm_view = SCMView(model=scm) scm_view.model.evaluate() eps, sigma = scm_view.eps_sigma plt.plot(eps, sigma, lw=1, label=str(Vf)) strengths.append(np.max(sigma)) cracks.append(len(scm_view.model.cracks_list[-1])) plt.legend(loc='best') plt.xlabel('composite strain [-]') plt.ylabel('composite stress [MPa]') plt.figure() plt.plot(Vfs, strengths, label='strengths') plt.figure() plt.plot(Vfs, cracks, label='cracks') print strengths print cracks
def mtrx_shape(): # shapes: 1000, 16.5, 8.0; scales: 3.0 3.1, 3.2 length = 2000. nx = 2000 random_field = RandomField(seed=False, lacor=5., length=length, nx=1000, nsim=1, loc=.0, shape=8., scale=3.2, distr_type='Weibull') plt.plot(random_field.xgrid, random_field.random_field, lw=1, color='black') plt.ylim(0) plt.show() reinf1 = ContinuousFibers( r=0.0035, tau=0.03, #RV('weibull_min', loc=0.0, shape=3., scale=0.03), V_f=0.01, E_f=180e3, xi=fibers_MC(m=5.0, sV0=10.003), label='carbon', n_int=500) CB_model = CompositeCrackBridge( E_m=25e3, reinforcement_lst=[reinf1], ) scm = SCM( length=length, nx=nx, random_field=random_field, CB_model=CB_model, load_sigma_c_arr=np.linspace(0.01, 8., 100), ) scm_view = SCMView(model=scm) scm_view.model.evaluate() eps, sigma = scm_view.eps_sigma plt.figure() plt.plot(eps, sigma, color='black', lw=2, label='model') plt.legend(loc='best') plt.xlabel('composite strain [-]') plt.ylabel('composite stress [MPa]')
def sigmamu_shape_study(): length = 2000. nx = 3000 lacor = 1.0 sigmamumin = 3.0 reinf = ContinuousFibers(r=0.0035, tau=RV('gamma', shape=0.2, scale=0.5), V_f=0.01, E_f=180e3, xi=1000., label='carbon', n_int=500) ccb = CompositeCrackBridge(E_m=25e3, reinforcement_lst=[reinf], ) #for mm in [5., 10., 15., 20., 25., 30., 35.]: for mm in [5., 10., 15., 20., 30.]: fLc = (lacor/(lacor+length))**(1./mm) sm = sigmamumin / (fLc * gamma(1. + 1 / mm)) random_field = RandomField(seed=True, lacor=1., length=length, nx=500, nsim=1, loc=.0, shape=mm, scale=sm, distr_type='Weibull') scm = SCM(length=length, nx=nx, random_field=random_field, CB_model=ccb, load_sigma_c_arr=np.linspace(0.01, 20., 200), n_BC_CB=15) scm_view = SCMView(model=scm) scm_view.model.evaluate() eps, sigma = scm_view.eps_sigma plt.plot(eps, sigma, label='mm = ' + str(mm) + ' sm = ' + str(sm)) plt.xlabel('composite strain [-]') plt.ylabel('composite stress [MPa]') plt.legend(loc='best') plt.xlim(0) plt.ylim(0) plt.show()
def p_tau(): length = 5000. nx = 5000 for tau_shape in [1.0, 2.0, 1000.]: random_field = RandomField(seed=False, lacor=5.0, length=length, nx=1000, nsim=1, loc=.0, shape=8., scale=3.2, distribution='Weibull') reinf1 = ContinuousFibers(r=0.0035, tau=RV('weibull_min', loc=0.0, shape=tau_shape, scale=0.03), V_f=0.01, E_f=180e3, xi=fibers_MC(m=5.0, sV0=10.003), label='carbon', n_int=500) CB_model = CompositeCrackBridge( E_m=25e3, reinforcement_lst=[reinf1], ) scm = SCM( length=length, nx=nx, random_field=random_field, CB_model=CB_model, load_sigma_c_arr=np.linspace(0.01, 8., 100), ) scm_view = SCMView(model=scm) scm_view.model.evaluate() eps, sigma = scm_view.eps_sigma plt.plot(eps, sigma, lw=1, label=str(tau_shape)) plt.legend(loc='best') plt.xlabel('composite strain [-]') plt.ylabel('composite stress [MPa]')
def r_field(): from stats.misc.random_field.random_field_1D import RandomField rf = RandomField(xgrid = np.linspace(0, 1000, 500)) rf.distribution = 'Weibull' rf.lacor = 3.0 rf.shape = 10. rf.scale = 5. rf.loc = 0.0 x = rf.xgrid y = rf.random_field plt.plot(x,y, color = 'grey', lw = 1, label = 'lacor = %.1f' %rf.lacor) rf.lacor = 10. y = rf.random_field plt.plot(x,y, color = 'black', lw = 2, label = 'lacor = %.1f' %rf.lacor) plt.legend(loc = 'best') plt.xticks(fontsize = 20) plt.yticks(fontsize = 20) plt.show()
def ld(): length = 1000. nx = 3000 random_field = RandomField(seed=True, lacor=1., length=length, nx=1000, nsim=1, loc=.0, shape=45., scale=3.360, distr_type='Weibull') reinf_cont = ContinuousFibers(r=3.5e-3, tau=RV('gamma', loc=0.0, scale=1.534, shape=.0615), V_f=0.01, E_f=181e3, xi=fibers_MC(m=8.6, sV0=11.4e-3), label='carbon', n_int=100) CB_model = CompositeCrackBridge(E_m=25e3, reinforcement_lst=[reinf_cont], ) scm = SCM(length=length, nx=nx, random_field=random_field, CB_model=CB_model, load_sigma_c_arr=np.linspace(0.01, 30., 200), n_BC_CB = 12) scm_view = SCMView(model=scm) scm_view.model.evaluate() eps, sigma = scm_view.eps_sigma plt.plot(eps, sigma, color='black', lw=2, label='continuous fibers') plt.legend(loc='best') plt.xlabel('composite strain [-]') plt.ylabel('composite stress [MPa]') plt.show()
cb = NonLinearCB( A_c=9. * 95., tstepper=ts, max_w_p=r * 1.84 * 18 * 1500, # [N] slip=[ 0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2. ], bond=bond_18, n_BC=100) random_field = RandomField(seed=False, lacor=1., length=2000, nx=1000, nsim=1, loc=.0, stdev=0.05, mean=5., distr_type='Gauss') ctt = CompositeTensileTest(n_x=1000, L=2000, cb=cb, sig_mu_x=random_field.random_field, strength=r * 1.84 * 18. * 1500. / 9. / 95.) sig_c_i, z_x_i, BC_x_i, sig_c_u, n_crack = ctt.get_cracking_history() load_arr1 = np.unique( np.hstack((np.linspace(0, sig_c_u, 100), sig_c_i))) eps_c_arr1 = ctt.get_eps_c_arr(sig_c_i, z_x_i, BC_x_i, load_arr1)
plt.savefig(savepath) plt.clf() return eps_arr if __name__ == '__main__': cb = NonLinearCB(slip=[0, 0.1, 0.2, 0.3, 0.4, 0.5], bond=[0., 10., 20., 30., 40., 50.], n_BC=100) random_field = RandomField(seed=False, lacor=1., length=500, nx=1000, nsim=1, loc=.0, shape=60., scale=1.5, distr_type='Weibull') ctt = CompositeTensileTest(n_x=1000, L=500, cb=cb, sig_mu_x=random_field.random_field) sig_c_i, z_x_i, BC_x_i, sig_c_u, n_crack = ctt.get_cracking_history() load_arr = np.unique(np.hstack((np.linspace(0, sig_c_u, 100), sig_c_i))) eps_c_arr = ctt.get_eps_c_arr(sig_c_i, z_x_i, BC_x_i, load_arr) plt.plot(eps_c_arr, load_arr, 'k', lw=2, label='v_f=1.5%') plt.show()
raise ValueError('''got stuck in loop, try to adapt x, w, BC ranges''') last_pos = float(crack_position) if __name__ == '__main__': from quaducom.meso.homogenized_crack_bridge.elastic_matrix.reinforcement import ContinuousFibers, ShortFibers from stats.pdistrib.weibull_fibers_composite_distr import fibers_MC from matplotlib import pyplot as plt length = 100. nx = 500 random_field = RandomField(seed=True, lacor=1., length=length, nx=500, nsim=1, loc=.0, shape=15., scale=4.0, distr_type='Weibull') reinf1 = ContinuousFibers(r=3.5e-3, tau=RV('weibull_min', loc=0.01, scale=.01, shape=2.), V_f=0.05, E_f=200e3, xi=fibers_MC(m=7., sV0=0.01), label='carbon', n_int=100)
sigc_max = new_sigc_max if float(crack_position) == last_pos: raise ValueError('''got stuck in loop, try to adapt x, w, BC ranges''') last_pos = float(crack_position) print sigc_min if __name__ == '__main__': length = 2000. nx = 2000 random_field = RandomField(seed=True, lacor=10., xgrid=np.linspace(0., length, 400), nsim=1, loc=.0, shape=15., scale=6., non_negative_check=True, distribution='Weibull') reinf = Reinforcement(r=0.01, tau=RV('uniform', loc=0.01, scale=.5), V_f=0.05, E_f=200e3, xi=WeibullFibers(shape=5., sV0=0.00618983207723), n_int=50, label='carbon') model = CompositeCrackBridge( E_m=25e3,
max_w_p=1.84 * 8 * 2167, # [N] slip=slip, bond=bond, n_BC=100) ''' uncomment this loop in order to run multiple random simulations at once ''' # n_crack_end = 0 # while n_crack_end < 3: random_field = RandomField( seed=False, lacor=4, length=350, nx=1000, nsim=1, loc=.0, # stdev=0.2, # mean=3.22, shape=5, scale=8.60718591, distr_type='Weibull') ctt = CompositeTensileTest(n_x=1000, L=350, cb=cb, sig_mu_x=random_field.random_field, strength=21.26) sig_c_i, z_x_i, BC_x_i, sig_c_u, n_crack = ctt.get_cracking_history() # print n_crack
def valid(CS, param_set, w_max): plt.figure() TT() from quaducom.meso.homogenized_crack_bridge.elastic_matrix.reinforcement import ContinuousFibers from stats.pdistrib.weibull_fibers_composite_distr import fibers_MC length = 250. nx = 5000 tau_loc, tau_shape, xi_shape = param_set E_f = 182e3 mu_tau = 1.3 * 3.5e-3 * 3.6 * (1. - 0.01) / (2. * 0.01 * CS) tau_scale = (mu_tau - tau_loc) / tau_shape xi_scale = 3243. / (182e3 * (pi * 3.5e-3**2 * 50.)**(-1. / xi_shape) * gamma(1 + 1. / xi_shape)) #xi_scale = 1578. / (182e3 * (pi * 3.5e-3 **2 * 500. * e)**(-1./xi_shape)) n_CB = 8 ld = False w_width = False w_density = False random_field1 = RandomField(seed=False, lacor=1., length=length, nx=800, nsim=1, loc=.0, shape=45., scale=3.6, distr_type='Weibull') reinf1 = ContinuousFibers(r=3.5e-3, tau=RV('gamma', loc=tau_loc, scale=tau_scale, shape=tau_shape), V_f=0.01, E_f=E_f, xi=fibers_MC(m=xi_shape, sV0=xi_scale), label='carbon', n_int=500) CB_model1 = CompositeCrackBridge( E_m=25e3, reinforcement_lst=[reinf1], ) scm1 = SCM(length=length, nx=nx, random_field=random_field1, CB_model=CB_model1, load_sigma_c_arr=np.linspace(0.01, 35., 100), n_BC_CB=n_CB) scm_view1 = SCMView(model=scm1) scm_view1.model.evaluate() eps1, sigma1 = scm_view1.eps_sigma eps11, sigma11 = scm_view1.eps_sigma_altern cr_lst1 = scm_view1.model.cracking_stress_lst interp1 = interp1d(sigma1, eps1) plt.plot(eps11, sigma11, color='red', lw=2, label='Vf=1.0, crack spacing = ' + str(length / float(len(cr_lst1)))) #plt.plot(eps11, sigma11, color='black', ls='dashed', lw=2, label='altern eps') plt.plot(interp1(np.array(cr_lst1) - np.max(sigma1) / 100.), np.array(cr_lst1) - np.max(sigma1) / 100., 'ro') if len(cr_lst1) > 2: random_field2 = RandomField(seed=False, lacor=1., length=length, nx=700, nsim=1, loc=.0, shape=45., scale=4.38, distr_type='Weibull') reinf2 = ContinuousFibers(r=3.5e-3, tau=RV('gamma', loc=tau_loc, scale=tau_scale, shape=tau_shape), V_f=0.015, E_f=E_f, xi=fibers_MC(m=xi_shape, sV0=xi_scale), label='carbon', n_int=500) CB_model2 = CompositeCrackBridge( E_m=25e3, reinforcement_lst=[reinf2], ) scm2 = SCM(length=length, nx=nx, random_field=random_field2, CB_model=CB_model2, load_sigma_c_arr=np.linspace(0.01, 40., 100), n_BC_CB=n_CB) scm_view2 = SCMView(model=scm2) scm_view2.model.evaluate() eps2, sigma2 = scm_view2.eps_sigma cr_lst2 = scm_view2.model.cracking_stress_lst interp2 = interp1d(sigma2, eps2) plt.plot(eps2, sigma2, color='blue', lw=2, label='Vf=1.5, crack spacing = ' + str(length / float(len(cr_lst2)))) plt.plot(interp2(np.array(cr_lst2) - np.max(sigma2) / 100.), np.array(cr_lst2) - np.max(sigma2) / 100., 'bo') plt.xlabel('composite strain [-]') plt.ylabel('composite stress [MPa]') plt.xlim(0., np.max(eps1) * 1.15) plt.legend(loc='best') plt.savefig('validation_figsCS%1.f/w_max%.1f.png' % (CS, w_max)) plt.close() if ld == True: plt.plot(eps1, sigma1, color='red', lw=2, label='Vf=1.0, crack spacing = ' + str(length / float(len(cr_lst1)))) #plt.plot(eps11, sigma11, color='black', ls='dashed', lw=2, label='altern eps') plt.plot(interp1(np.array(cr_lst1) - np.max(sigma1) / 100.), np.array(cr_lst1) - np.max(sigma1) / 100., 'ro') plt.plot(eps2, sigma2, color='blue', lw=2, label='Vf=1.5, crack spacing = ' + str(length / float(len(cr_lst2)))) plt.plot(interp2(np.array(cr_lst2) - np.max(sigma2) / 100.), np.array(cr_lst2) - np.max(sigma2) / 100., 'bo') plt.xlabel('composite strain [-]') plt.ylabel('composite stress [MPa]') plt.xlim(0., np.max(eps1) * 1.1) plt.legend(loc='best') if w_width == True: plt.figure() plt.plot(scm_view1.model.load_sigma_c_arr, scm_view1.w_mean) plt.plot(scm_view1.model.load_sigma_c_arr, scm_view1.w_max) # plt.plot(scm_view2.model.load_sigma_c_arr, scm_view2.w_mean) # plt.plot(scm_view2.model.load_sigma_c_arr, scm_view2.w_max) if w_density == True: plt.figure() plt.plot(scm_view1.model.load_sigma_c_arr, scm_view1.w_density)
plt.rcParams.update(params) fig = p.figure(facecolor='white', figsize=(15.6 / 2.54, 7.8 / 2.54), dpi=100) fig.subplots_adjust(left=0.1, right=0.96, bottom=0.18, top=0.94, wspace=0.3, hspace=0.3) for s, m in zip(s_arr, m_arr): random_field = RandomField(seed=False, lacor=l_rho, length=length, nx=1000, nsim=1, loc=.0, scale=s, shape=m, distr_type='Weibull') p.subplot(121) p.plot(random_field.xgrid, random_field.random_field) p.ylim(ymin=0.0) p.subplot(122) p.subplot(122).set_ylabel('Probability') p.subplot(122).set_xlabel('Composite Stress [MPa]') sig_pdf_arr = weibull_min.pdf(sig_arr, m, 0, s) p.plot(sig_arr, sig_pdf_arr, label='m = %1.0f ' % random_field.shape) p.legend()