def simple_ex(): E = 92000.0 nu = 0.3 s0 = 180.0 Kp = 1000.0 H = 1000.0 elastic = elasticity.IsotropicLinearElasticModel(E, "youngs", nu, "poissons") surface = surfaces.IsoKinJ2() iso = hardening.LinearIsotropicHardeningRule(s0, Kp) kin = hardening.LinearKinematicHardeningRule(H) hrule = hardening.CombinedHardeningRule(iso, kin) flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule) bmodel = models.SmallStrainRateIndependentPlasticity(elastic, flow) A = 0.0e-6 a = 2.2 model_off = damage.NEMLPowerLawDamagedModel_sd(elastic, A, a, bmodel) A = 2e-5 model_on = damage.NEMLPowerLawDamagedModel_sd(elastic, A, a, bmodel) res_off = drivers.uniaxial_test(model_off, 1.0e-2, emax=0.13) res_on = drivers.uniaxial_test(model_on, 1.0e-2, emax=0.13) plt.plot(res_off['strain'], res_off['stress'], 'k-') plt.plot(res_on['strain'], res_on['stress'], 'r-') plt.show()
def verify_Q(): E = 30000.0 nu = 0.3 sy = 100.0 Q = 50.0 b = 100.0 C = 0.0 g = 0.0 mu = E / (2 * (1.0 + nu)) K = E / (3 * (1 - 2 * nu)) elastic = elasticity.IsotropicLinearElasticModel(mu, "shear", K, "bulk") surface = surfaces.IsoKinJ2() iso = hardening.VoceIsotropicHardeningRule(sy, Q, b) gmodels = [hardening.ConstantGamma(g)] hrule = hardening.Chaboche(iso, [C], gmodels, [0.0], [1.0]) flow = ri_flow.RateIndependentNonAssociativeHardening(surface, hrule) model = models.SmallStrainRateIndependentPlasticity(elastic, flow, verbose=False) res = drivers.uniaxial_test(model, 1.0e-2, emax=0.2) stress = res['stress'] print("Q: %f / %f" % (Q, stress[-1] - sy))
def check_regression(model): nmodel = parse.parse_xml(xml, model) res = drivers.uniaxial_test(nmodel, strain_rate) reference = pickle.load(open(os.path.join('test/regression', model+'.pickle'), 'rb')) assert(np.allclose(res['strain'], reference['strain'])) assert(np.allclose(res['stress'], reference['stress'])) assert(np.allclose(res['energy_density'], reference['energy_density'])) assert(np.allclose(res['plastic_work'], reference['plastic_work']))
def run_model(model_name, xml_file, repeat): model = parse.parse_xml(xml_file, model_name) fstr = " Running %s..." % model_name print(fstr, end='') start = time.time() for i in range(repeat): res = drivers.uniaxial_test(model, strain_rate) end = time.time() avg = (end - start) / repeat pad = " " * (align - len(fstr)) print(pad + "%f s (avg)" % avg) return res
frule2 = walker.WalkerKremplSwitchRule(emodel, vmodel, 0.0, eps_ref) model2 = models.GeneralIntegrator(emodel, frule2) frule3 = walker.WalkerKremplSwitchRule(emodel, vmodel, 0.99, eps_ref) model3 = models.GeneralIntegrator(emodel, frule3) rates = [1.0e-6, 1.0e-4, 1.0e-2, 1.0] surface = surfaces.IsoJ2() iso = hardening.LinearIsotropicHardeningRule(s0, K) flow = ri_flow.RateIndependentAssociativeFlow(surface, iso) model4 = models.SmallStrainRateIndependentPlasticity(emodel, flow) for r in rates: res1 = drivers.uniaxial_test(model1, r) l, = plt.plot(res1['strain'], res1['stress']) res2 = drivers.uniaxial_test(model2, r) plt.plot(res2['strain'], res2['stress'], color=l.get_color(), ls='--', lw=2) res3 = drivers.uniaxial_test(model3, r) plt.plot(res3['strain'], res3['stress'], color=l.get_color(), ls=':', lw=3) res4 = drivers.uniaxial_test(model4, r) plt.plot(res4['strain'], res4['stress'], color='k', ls='-')
es = [en] ss = [sn] n = 100 emax = 0.1 for enp1 in np.linspace(0, emax, n+1)[1:]: Tnp1 = Tn + dT tnp1 = tn + dt snp1, hnp1, Anp1, unp1, pnp1 = umodel.update(enp1, en, Tnp1, Tn, tnp1, tn, sn, hn, un, pn) es.append(enp1) ss.append(snp1) sn = snp1 hn = np.copy(hnp1) en = enp1 Tn = Tnp1 tn = tnp1 un = unp1 pn = pnp1 plt.plot(es, ss, 'k-') res = drivers.uniaxial_test(model, emax / n / dt, T = Tn, emax = emax) plt.plot(res['strain'], res['stress'], 'r-') plt.show()
elastic = elasticity.IsotropicLinearElasticModel(E, "youngs", nu, "poissons") surface = surfaces.IsoJ2() pmodel = models.SmallStrainPerfectPlasticity(elastic, surface, sY) model = models.SmallStrainCreepPlasticity(elastic, pmodel, cmodel) res = drivers.creep(model, 200.0, 1.0e2, 1000.0, verbose=True) plt.plot(res['time'], res['strain']) plt.show() res = drivers.strain_cyclic(model, 0.01, -1, 1.0e-4, 15, verbose=True, nsteps=25, hold_time=[10.0, 0]) plt.plot(res['strain'], res['stress']) plt.show() res = drivers.uniaxial_test(model, 1.0e-6, sdir=np.array([1, -1, 0.5, -0.5, 0.1, -0.25]), verbose=True) plt.plot(res['strain'], res['stress']) plt.show()
if __name__ == "__main__": E = 150000.0 nu = 0.3 sY = 150.0 h = 1.0e-2 l = 1.0 emodel = elasticity.IsotropicLinearElasticModel(E, "youngs", nu, "poissons") surface = surfaces.IsoJ2I1(h, l) model = models.SmallStrainPerfectPlasticity(emodel, surface, sY) res_tension = drivers.uniaxial_test(model, 1.0e-2) res_compres = drivers.uniaxial_test(model, 1.0e-2, sdir=np.array([-1, 0, 0, 0, 0, 0])) plt.plot(res_tension['strain'], res_tension['stress'], 'k-') plt.plot(res_compres['strain'], res_compres['stress'], 'r-') plt.show() E = 150000.0 nu = 0.3 sY = 150.0 h = 1.0e-2 l = 1.0 K = E / 50.0
slipmodel = sliprules.PowerLawSlipRule(strengthmodel, g0, n) imodel = inelasticity.AsaroInelasticity(slipmodel) emodel = elasticity.IsotropicLinearElasticModel(E, "youngs", nu, "poissons") kmodel = kinematics.StandardKinematicModel(emodel, imodel) lattice = crystallography.CubicLattice(1.0) lattice.add_slip_system([1,1,0],[1,1,1]) model = singlecrystal.SingleCrystalModel(kmodel, lattice, verbose = False) orientations = rotations.random_orientations(N) dt = emax / erate / steps pmodel = polycrystal.TaylorModel(model, orientations, nthreads = nthreads) res = drivers.uniaxial_test(pmodel, erate, emax = emax, nsteps = steps) strains.append(res['strain']) stresses.append(res['stress']) plt.figure() for e,s,r in zip(strains, stresses, rhos): plt.plot(e,s, label = r"$\rho=%3.1e\,\mathrm{m^{-2}}$" % r) plt.xlabel("Strain (mm/mm)") plt.ylabel("Stress (MPa)") plt.legend(loc='best') plt.tight_layout() plt.show()
def uniaxial(): # Data from "Numerical modeling of elasto-viscoplastic Chaboche constitutive..." # by A. Ambroziak E = 159000.0 nu = 0.3 k = 514.21 b = 60.0 R1 = -194.39 a = 170000.0 c = 500.0 n = 4.0 eta = 1023.5 # Translate Q = R1 b = b C1 = a g1 = c eta = eta sY = k mu = E / (2 * (1.0 + nu)) K = E / (3 * (1 - 2 * nu)) elastic = elasticity.IsotropicLinearElasticModel(mu, "shear", K, "bulk") surface = surfaces.IsoKinJ2() iso = hardening.VoceIsotropicHardeningRule(sY, Q, b) cs = [C1] gs = [hardening.ConstantGamma(g1)] hmodel = hardening.Chaboche(iso, cs, gs, [0.0], [1.0]) fluidity = visco_flow.ConstantFluidity(eta) vmodel = visco_flow.ChabocheFlowRule( surface, hmodel, fluidity, n) flow = general_flow.TVPFlowRule(elastic, vmodel) model = models.GeneralIntegrator(elastic, flow) erates = [1.0e-7, 1.0e-2, 1.0e-1] e_7 = np.array([1.03E-007, 0.000977076, 0.0019927018, 0.0029695719, 0.0038278073, 0.0048024128, 0.0058155682, 0.0068186871, 0.0078116926, 0.0088238185, 0.0098260368, 0.0108280492, 0.0118396862, 0.0128318167, 0.0138433765, 0.0148451316, 0.0158469381, 0.0168487447, 0.017840798, 0.0188523063, 0.019844411]) s_7 = np.array([1.9738128815, 164.2845378653, 316.6592895303, 475.0018013938, 559.9786920852, 631.0205153016, 688.1581520788, 733.3950096246, 763.7549280987, 781.2104336727, 791.7254264156, 794.3039929179, 792.9104861704, 789.5405931218, 785.170926534, 777.8289602355, 772.4711004972, 767.1132407589, 760.7671878699, 754.413414722, 750.0514683933]) e_2 = np.array([-1.94E-005, 0.000976973, 0.0019830515, 0.0029890784, 0.0037900553, 0.0048443338, 0.0058197114, 0.0068040701, 0.0078172512, 0.0088300977, 0.0098231803, 0.0108257074, 0.0118377047, 0.0128397943, 0.0138612103, 0.0148630941, 0.0158551988, 0.0168667329, 0.017878267, 0.0188703202, 0.0198623735]) s_2 = np.array([-0.0025734197, 160.316324745, 319.6393095, 476.9781876949, 604.6365302068, 747.075308553, 847.8787301718, 919.9087465388, 978.0384365961, 1023.2714340124, 1056.6075123267, 1079.0271444306, 1091.5223836042, 1097.0771099468, 1097.66384963, 1095.2821497319, 1090.9202034031, 1085.5584835353, 1080.1967636674, 1073.8507107785, 1067.5046578896]) e_1 = np.array([-1.93E-005, 0.0009672712, 0.0019928047, 0.0029793251, 0.0037900295, 0.0047863804, 0.0058017489, 0.0068163453, 0.0078302727, 0.0088243075, 0.0098374371, 0.0108404531, 0.0118432376, 0.0128554407, 0.0138577362, 0.014850124, 0.01587154, 0.0168734495, 0.0178753075, 0.0188770883, 0.0198789206]) s_1 = np.array([2.9735864206, 161.3122381546, 320.6275026506, 475.9899945444, 603.6444769267, 762.9713218113, 905.4255406755, 1018.1181611373, 1105.0173963169, 1175.0594459942, 1231.2050294914, 1272.4736739169, 1304.8138388216, 1325.2455042359, 1338.7366568191, 1345.2872965712, 1345.8740362543, 1344.4843896363, 1341.1106364582, 1334.7607234397, 1330.3949169815]) plt.plot(e_7, s_7, 'kx') plt.plot(e_2, s_2, 'rx') plt.plot(e_1, s_1, 'bx') res = drivers.uniaxial_test(model, erates[0], emax = 0.02) plt.plot(res['strain'], res['stress'], 'k-') res = drivers.uniaxial_test(model, erates[1], emax = 0.02) plt.plot(res['strain'], res['stress'], 'r-') res = drivers.uniaxial_test(model, erates[2], emax = 0.02) plt.plot(res['strain'], res['stress'], 'b-') plt.xlim([0,0.02]) plt.ylim([0,1500]) plt.show()
ns = [1.0] hmodel = hardening.Chaboche(iso, cs, gs, As, ns) fluidity = visco_flow.ConstantFluidity(eta) vmodel = visco_flow.ChabocheFlowRule( surface, hmodel, fluidity, n) flow = general_flow.TVPFlowRule(elastic, vmodel) model = models.GeneralIntegrator(elastic, flow, verbose = False) # Uniaxial stress/strain curves at decades of strain rates erates = np.logspace(-6,2,9) for rate in erates: res = drivers.uniaxial_test(model, rate, verbose = False) plt.plot(res['strain'], res['stress']) plt.xlabel("Strain (-/-)") plt.ylabel("Stress (MPa)") plt.show() # A strain-controlled cyclic test res = drivers.strain_cyclic(model, 0.001, -0.25, 1.0e-4, 50, verbose = False) plt.plot(res['strain'], res['stress'], 'k-') plt.xlabel("Strain (-/-)") plt.ylabel("Stress (MPa)") plt.show() plt.plot(res['cycles'], res['max'], 'k-')