Example #1
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml",
                                      "test_creep_plasticity")

        A = 1.85e-10
        n = 2.5

        smodel = creep.PowerLawCreep(A, n)
        cmodel = creep.J2CreepModel(smodel)

        E = 150000.0
        nu = 0.3
        sY = 200.0
        H = E / 50.0

        elastic = elasticity.IsotropicLinearElasticModel(
            E, "youngs", nu, "poissons")
        surface = surfaces.IsoJ2()
        iso = hardening.LinearIsotropicHardeningRule(sY, H)
        flow = ri_flow.RateIndependentAssociativeFlow(surface, iso)

        pmodel = models.SmallStrainRateIndependentPlasticity(elastic, flow)

        self.model2 = models.SmallStrainCreepPlasticity(
            elastic, pmodel, cmodel)

        self.T = 300.0
        self.tmax = 10.0
        self.nsteps = 100.0
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #2
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_powerdamage")

        E = 92000.0
        nu = 0.3

        s0 = 180.0
        Kp = 1000.0

        elastic = elasticity.IsotropicLinearElasticModel(
            E, "youngs", nu, "poissons")

        surface = surfaces.IsoJ2()
        hrule = hardening.LinearIsotropicHardeningRule(s0, Kp)

        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        bmodel = models.SmallStrainRateIndependentPlasticity(elastic, flow)

        a = 2.2
        A = 2e-5
        self.model2 = damage.NEMLPowerLawDamagedModel_sd(elastic, A, a, bmodel)

        self.T = 300.0
        self.tmax = 10.0
        self.nsteps = 100.0
        self.emax = np.array([0.05, 0, 0, 0, 0, 0])
Example #3
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_j2isocomb")

        E = 150000.0
        nu = 0.3

        ys = 100.0
        H = 100.0
        r = 100.0
        d = 1000.0

        elastic = elasticity.IsotropicLinearElasticModel(
            E, "youngs", nu, "poissons")

        surface = surfaces.IsoJ2()
        hrule1 = hardening.LinearIsotropicHardeningRule(ys, H)
        hrule2 = hardening.VoceIsotropicHardeningRule(0.0, r, d)
        hrule = hardening.CombinedIsotropicHardeningRule([hrule1, hrule2])
        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        self.model2 = models.SmallStrainRateIndependentPlasticity(
            elastic, flow)

        self.T = 300.0
        self.tmax = 10.0
        self.nsteps = 100.0
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #4
0
  def complete(self):
    self.E = 92000.0
    self.nu = 0.3

    self.s0 = 180.0
    self.Kp = 1000.0
    self.H = 1000.0

    self.elastic = elasticity.IsotropicLinearElasticModel(self.E, "youngs",
        self.nu, "poissons")

    surface = surfaces.IsoKinJ2()
    iso = hardening.LinearIsotropicHardeningRule(self.s0, self.Kp)
    kin = hardening.LinearKinematicHardeningRule(self.H)
    hrule = hardening.CombinedHardeningRule(iso, kin)

    flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

    self.bmodel = models.SmallStrainRateIndependentPlasticity(self.elastic, 
        flow)

    self.xi = 0.478
    self.phi = 1.914
    self.A = 10000000.0

    self.model = damage.ModularCreepDamageModel_sd(
        self.elastic, 
        self.A, self.xi, self.phi,
        self.effective_model(),
        self.bmodel)

    self.stress = np.array([100,-50.0,300.0,-99,50.0,125.0])
    self.T = 100.0

    self.s_np1 = self.stress
    self.s_n = np.array([-25,150,250,-25,-100,25])

    self.d_np1 = 0.5
    self.d_n = 0.4

    self.e_np1 = np.array([0.1,-0.01,0.15,-0.05,-0.1,0.15])
    self.e_n = np.array([-0.05,0.025,-0.1,0.2,0.11,0.13])

    self.T_np1 = self.T
    self.T_n = 90.0

    self.t_np1 = 1.0
    self.t_n = 0.0

    self.u_n = 0.0
    self.p_n = 0.0
  
    # This is a rather boring baseline history state to probe, but I can't
    # think of a better way to get a "generic" history from a generic model
    self.hist_n = np.array([self.d_n] + list(self.bmodel.init_store()))
    self.x_trial = np.array([50,-25,150,-150,190,100.0] + [0.41])

    self.nsteps = 10
    self.etarget = np.array([0.1,-0.025,0.02,0.015,-0.02,-0.05])
    self.ttarget = 10.0
Example #5
0
    def setUp(self):
        self.hist0 = np.zeros((7, ))

        self.E = 92000.0
        self.nu = 0.3

        self.mu = self.E / (2 * (1 + self.nu))
        self.K = self.E / (3 * (1 - 2 * self.nu))

        self.s0 = 180.0
        self.R = 150.0
        self.d = 10.0

        self.elastic = elasticity.IsotropicLinearElasticModel(
            self.mu, "shear", self.K, "bulk")

        surface = surfaces.IsoJ2()
        hrule = hardening.VoceIsotropicHardeningRule(self.s0, self.R, self.d)
        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        self.model = models.SmallStrainRateIndependentPlasticity(
            self.elastic, flow, check_kt=False)

        self.efinal = np.array([0.1, -0.05, 0.02, -0.03, 0.1, -0.15])
        self.tfinal = 10.0
        self.T = 300.0
        self.nsteps = 10
Example #6
0
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()
Example #7
0
def example4():
  # T is in hours, strain in percent, stress in MPa
  A = 1.85e-10
  n = 2.5
  m = 0.3

  smodel = creep.PowerLawCreep(A, n)
  cmodel = creep.J2CreepModel(smodel)

  E = 150000.0
  nu = 0.3
  sY = 200.0
  H = E / 25.0

  elastic = elasticity.IsotropicLinearElasticModel(E, "youngs", nu,
      "poissons")
  surface = surfaces.IsoJ2()
  iso = hardening.LinearIsotropicHardeningRule(sY, H)
  flow = ri_flow.RateIndependentAssociativeFlow(surface, iso)

  pmodel = models.SmallStrainRateIndependentPlasticity(elastic, flow)
  model = models.SmallStrainCreepPlasticity(elastic, pmodel, cmodel)

  res = drivers.creep(model, 205.0, 3600.0, 100.0, verbose = False, 
      nsteps_up = 500)
  plt.plot(res['strain'], res['stress'])
  plt.show()
Example #8
0
  def setUp(self):
    self.E = 92000.0
    self.nu = 0.3

    self.s0 = 180.0
    self.Kp = 1000.0
    self.H = 1000.0

    self.elastic = elasticity.IsotropicLinearElasticModel(self.E, "youngs",
        self.nu, "poissons")

    surface = surfaces.IsoKinJ2()
    iso = hardening.LinearIsotropicHardeningRule(self.s0, self.Kp)
    kin = hardening.LinearKinematicHardeningRule(self.H)
    hrule = hardening.CombinedHardeningRule(iso, kin)

    flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

    self.bmodel = models.SmallStrainRateIndependentPlasticity(self.elastic, 
        flow)

    self.fn = interpolate.PolynomialInterpolate([-6.653e-9,2.952e-4,-6.197e-1])
    self.C = 32.06

    self.lmr = larsonmiller.LarsonMillerRelation(self.fn, self.C)
    self.effective = damage.VonMisesEffectiveStress()

    self.model = damage.LarsonMillerCreepDamageModel_sd(
        self.elastic, self.lmr, self.effective, self.bmodel)

    self.stress = np.array([100,-50.0,300.0,-99,50.0,125.0])
    self.T = 100.0

    self.s_np1 = self.stress
    self.s_n = np.array([-25,150,250,-25,-100,25])

    self.d_np1 = 0.5
    self.d_n = 0.4

    self.e_np1 = np.array([0.1,-0.01,0.15,-0.05,-0.1,0.15])
    self.e_n = np.array([-0.05,0.025,-0.1,0.2,0.11,0.13])

    self.T_np1 = self.T
    self.T_n = 90.0

    self.t_np1 = 1.0
    self.t_n = 0.0
    self.dt = self.t_np1 - self.t_n

    self.u_n = 0.0
    self.p_n = 0.0
  
    # This is a rather boring baseline history state to probe, but I can't
    # think of a better way to get a "generic" history from a generic model
    self.hist_n = np.array([self.d_n] + list(self.bmodel.init_store()))
    self.x_trial = np.array([50,-25,150,-150,190,100.0] + [0.41])

    self.nsteps = 10
    self.etarget = np.array([0.1,-0.025,0.02,0.015,-0.02,-0.05])
    self.ttarget = 10.0
Example #9
0
    def setUp(self):
        string_rep = '<test_j2iso type="SmallStrainRateIndependentPlasticity"><elastic type="IsotropicLinearElasticModel"><m1>103561.64383561644</m1><m1_type>youngs</m1_type><m2>0.2945205479452055</m2><m2_type>poissons</m2_type></elastic><flow type="RateIndependentAssociativeFlow"><surface type="IsoJ2"/><hardening type="LinearIsotropicHardeningRule"><s0>100.0</s0><K>1000.0</K></hardening></flow></test_j2iso>'

        self.model1 = parse.parse_string(string_rep)

        mu = 40000.0
        K = 84000.0

        ys = 100.0
        H = 1000.0

        elastic = elasticity.IsotropicLinearElasticModel(
            mu, "shear", K, "bulk")

        surface = surfaces.IsoJ2()
        hrule = hardening.LinearIsotropicHardeningRule(ys, H)
        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        self.model2 = models.SmallStrainRateIndependentPlasticity(
            elastic, flow)

        self.T = 300.0
        self.tmax = 10.0
        self.nsteps = 100
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #10
0
    def setUp(self):
        self.hist0 = np.zeros((13, ))

        self.E = 92000.0
        self.nu = 0.3

        self.mu = self.E / (2 * (1 + self.nu))
        self.K = self.E / (3 * (1 - 2 * self.nu))

        self.s0 = 180.0
        self.Kp = 1000.0

        self.H = 1000.0

        self.elastic = elasticity.IsotropicLinearElasticModel(
            self.mu, "shear", self.K, "bulk")

        surface = surfaces.IsoKinJ2()
        iso = hardening.LinearIsotropicHardeningRule(self.s0, self.Kp)
        kin = hardening.LinearKinematicHardeningRule(self.H)
        hrule = hardening.CombinedHardeningRule(iso, kin)

        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        self.model = models.SmallStrainRateIndependentPlasticity(
            self.elastic, flow)

        self.efinal = np.array([0.1, -0.05, 0.02, -0.03, 0.1, -0.15])
        self.tfinal = 10.0
        self.T = 300.0
        self.nsteps = 10
Example #11
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_j2comb")

        mu = 40000.0
        K = 84000.0

        ys = 100.0
        r = 100.0
        d = 1000.0

        KH = 1000.0

        elastic = elasticity.IsotropicLinearElasticModel(
            mu, "shear", K, "bulk")

        surface = surfaces.IsoKinJ2()
        iso = hardening.VoceIsotropicHardeningRule(ys, r, d)
        kin = hardening.LinearKinematicHardeningRule(KH)
        hrule = hardening.CombinedHardeningRule(iso, kin)
        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        self.model2 = models.SmallStrainRateIndependentPlasticity(
            elastic, flow)

        self.T = 300.0
        self.tmax = 10.0
        self.nsteps = 100.0
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #12
0
    def setUp(self):
        self.hist0 = np.zeros((13, ))

        self.A = 1.85e-10
        self.n = 2.5

        self.smodel = creep.PowerLawCreep(self.A, self.n)
        self.cmodel = creep.J2CreepModel(self.smodel)

        self.E = 150000.0
        self.nu = 0.3
        self.sY = 200.0
        self.H = self.E / 50.0

        self.elastic = elasticity.IsotropicLinearElasticModel(
            self.E, "youngs", self.nu, "poissons")

        self.surface = surfaces.IsoJ2()
        self.iso = hardening.LinearIsotropicHardeningRule(self.sY, self.H)
        self.flow = ri_flow.RateIndependentAssociativeFlow(
            self.surface, self.iso)

        self.pmodel = models.SmallStrainRateIndependentPlasticity(
            self.elastic, self.flow)

        self.model = models.SmallStrainCreepPlasticity(self.elastic,
                                                       self.pmodel,
                                                       self.cmodel)

        self.efinal = np.array([0.1, -0.05, 0.02, -0.03, 0.1, -0.15])
        self.tfinal = 10.0
        self.T = 300.0
        self.nsteps = 10
Example #13
0
    def setUp(self):
        self.E = 100000.0
        self.nu = 0.29
        self.sY = 100.0
        self.H = 1200.0

        elastic = elasticity.IsotropicLinearElasticModel(
            self.E, "youngs", self.nu, "poissons")
        surf = surfaces.IsoJ2()
        hard = hardening.LinearIsotropicHardeningRule(self.sY, self.H)
        flow = ri_flow.RateIndependentAssociativeFlow(surf, hard)
        self.model = models.SmallStrainRateIndependentPlasticity(elastic, flow)

        self.conditions = [{
            'hist_n':
            self.model.init_store(),
            'stress_n':
            np.zeros((6, )),
            'd_n':
            np.zeros((6, )),
            'd_np1':
            np.array([0.1, 0.05, -0.025, 0.15, 0.2, -0.05]),
            'w_n':
            np.zeros((3, )),
            'w_np1':
            np.array([-0.15, 0.1, 0.05]),
            'dt':
            1.0,
            'T':
            300.0
        }, {
            'hist_n':
            self.model.init_store(),
            'stress_n':
            np.array([10.0, -5.0, 30.0, -5.0, 10.0, 15.0]),
            'd_n':
            np.zeros((6, )),
            'd_np1':
            np.array([0.05, 0.5, 0.25, 0.20, -0.2, 0.25]),
            'w_n':
            np.zeros((3, )),
            'w_np1':
            np.array([-0.15, 0.25, 0.05]),
            'dt':
            1.0,
            'T':
            300.0
        }]

        self.directions = [{
            'd': np.array([0.1, -0.15, 0.2, -0.05, 0.15, 0.25]),
            'w': np.array([0.25, -0.15, 0.1])
        }]

        self.nsteps = 10
        self.dt = 1.0
        self.T = 300.0
Example #14
0
def unload_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 = 2e-5
    a = 2.2
    model = damage.NEMLPowerLawDamagedModel_sd(elastic, A, a, bmodel)

    driver = drivers.Driver_sd(model)
    nsteps = 25
    sdir = np.array([1, 0, 0, 0, 0, 0])
    erate = 1.0e-5
    e_inc = 0.1 / nsteps
    for i in range(nsteps):
        einc, ainc = driver.erate_einc_step(sdir, erate, e_inc, 0.0)

    estrain = model.elastic_strains(driver.stress_int[-1], driver.T_int[-1],
                                    driver.stored[-1])

    print("Calculated elastic strain: %f" % estrain[0])

    nsteps = 20
    dt = 0.1
    rstress = driver.stress_int[-1]
    rstrain = driver.strain_int[-1][0]
    for m in np.linspace(0, 1.0, nsteps, endpoint=False)[::-1]:
        driver.stress_step(rstress * m, driver.t_int[-1] + dt,
                           driver.T_int[-1])

    fstrain = driver.strain_int[-1][0]

    print("Actual elastic strain: %f" % (rstrain - fstrain))

    print("Calculated final elastic strain: %f" % model.elastic_strains(
        driver.stress_int[-1], driver.T_int[-1], driver.stored[-1])[0])

    plt.plot(driver.strain[:, 0], driver.stress[:, 0])
    plt.show()
Example #15
0
  def setUp(self):
    self.s0 = 200.0
    self.K = 15000.0

    self.surface = surfaces.IsoJ2()
    self.hardening = hardening.LinearIsotropicHardeningRule(self.s0, self.K)
    self.model = ri_flow.RateIndependentAssociativeFlow(self.surface, self.hardening)

    self.hist0 = np.zeros((1,))
    
    self.T = 300.0
Example #16
0
 def test_ri_plasticity(self):
     surface = surfaces.IsoJ2()
     sy = 100.0
     K = 1000.0
     H = 500.0
     hrule = hardening.CombinedHardeningRule(
         hardening.LinearIsotropicHardeningRule(sy, K),
         hardening.LinearKinematicHardeningRule(H))
     flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)
     model = models.SmallStrainRateIndependentPlasticity(
         self.elastic1, flow)
     self.are_equal(self.elastic1, model.elastic)
     model.set_elastic_model(self.elastic2)
     self.are_equal(self.elastic2, model.elastic)
Example #17
0
def creep_ex():
    E = 92000.0
    nu = 0.3

    s0 = 120.0

    A = 1.0e-10
    n = 3.0

    Kp = E / 500
    H = E / 500

    smodel = creep.PowerLawCreep(A, n)
    cmodel = creep.J2CreepModel(smodel)

    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)

    pmodel = models.SmallStrainRateIndependentPlasticity(elastic, flow)

    bmodel = models.SmallStrainCreepPlasticity(elastic, pmodel, cmodel)

    A_damg = 1.0e-2
    a_damg = 1.0

    model = damage.NEMLPowerLawDamagedModel_sd(elastic,
                                               A_damg,
                                               a_damg,
                                               bmodel,
                                               verbose=False)

    #res = drivers.uniaxial_test(model, 1.0e-2, emax = 0.25)
    #plt.plot(res['strain'], res['stress'])
    #plt.show()

    res = drivers.creep(model, 120.0, 1.0, 393.0, verbose=False)

    plt.plot(res['rtime'], res['rstrain'])
    plt.show()
    plt.loglog(res['rtime'], res['rrate'])
    plt.show()
Example #18
0
    def setUp(self):
        E = 150000.0
        nu = 0.3

        ys = 100.0
        H = 1000.0

        elastic = elasticity.IsotropicLinearElasticModel(
            E, "youngs", nu, "poissons")

        surface = surfaces.IsoJ2()
        hrule = hardening.LinearIsotropicHardeningRule(ys, H)
        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        self.model = models.SmallStrainRateIndependentPlasticity(elastic, flow)

        self.nblock = 100
Example #19
0
def example3():
  # T is in hours, strain in percent, stress in MPa
  A = 1.85e-10
  n = 2.5

  smodel = creep.PowerLawCreep(A, n)
  cmodel = creep.J2CreepModel(smodel)

  E = 150000.0
  nu = 0.3
  sY = 200.0
  H = E / 50.0

  elastic = elasticity.IsotropicLinearElasticModel(E, "youngs", nu,
      "poissons")
  surface = surfaces.IsoJ2()
  iso = hardening.LinearIsotropicHardeningRule(sY, H)
  flow = ri_flow.RateIndependentAssociativeFlow(surface, iso)

  pmodel = models.SmallStrainRateIndependentPlasticity(elastic, flow)
  
  smax = 250.0
  R = -0.5
  srate = 1.0 * 3600.0
  ncycles = 25
  hold = 25

  res1 = drivers.stress_cyclic(pmodel, smax, R, srate, ncycles, 
      hold_time = [0,hold])

  model = models.SmallStrainCreepPlasticity(elastic, pmodel, cmodel, verbose = False)

  res2 = drivers.stress_cyclic(model, smax, R, srate, ncycles, 
      hold_time = [0,hold], verbose = False)

  plt.plot(res1['strain'], res1['stress'], 'k-')
  plt.plot(res2['strain'], res2['stress'], 'r-')
  plt.show()
Example #20
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_j2iso")

        mu = 40000.0
        K = 84000.0

        ys = 100.0
        H = 1000.0

        elastic = elasticity.IsotropicLinearElasticModel(
            mu, "shear", K, "bulk")

        surface = surfaces.IsoJ2()
        hrule = hardening.LinearIsotropicHardeningRule(ys, H)
        flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

        self.model2 = models.SmallStrainRateIndependentPlasticity(
            elastic, flow)

        self.T = 300.0
        self.tmax = 10.0
        self.nsteps = 100.0
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #21
0
    def test_damage(self):
        s0 = 180.0
        Kp = 1000.0
        H = 1000.0

        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(
            self.elastic1, flow)

        W0 = 10.0
        k0 = 0.0001
        a0 = 2.0

        model1 = damage.NEMLExponentialWorkDamagedModel_sd(
            self.elastic1, W0, k0, a0, bmodel)

        W02 = 10.0
        k02 = 0.001
        a02 = 1.5

        model2 = damage.NEMLExponentialWorkDamagedModel_sd(
            self.elastic1, W02, k02, a02, bmodel)

        model = damage.CombinedDamageModel_sd(self.elastic1, [model1, model2],
                                              bmodel)

        self.very_close(model, self.emodel1)

        model.set_elastic_model(self.elastic2)

        self.very_close(model, self.emodel2)
Example #22
0
from neml import solvers, models, elasticity, drivers, surfaces, hardening, ri_flow, parse

import matplotlib.pyplot as plt
import numpy as np

if __name__ == "__main__":
    E = 100000.0
    nu = 0.3
    s0 = 100.0
    A = 200.0
    n = 0.2

    elastic = elasticity.IsotropicLinearElasticModel(E, "youngs", nu,
                                                     "poissons")

    surface = surfaces.IsoJ2()
    iso = hardening.PowerLawIsotropicHardeningRule(s0, A, n)

    flow = ri_flow.RateIndependentAssociativeFlow(surface, iso)
    model = models.SmallStrainRateIndependentPlasticity(elastic, flow)

    model2 = parse.parse_xml("example.xml", "powerlaw")

    erate = 1.0

    res = drivers.uniaxial_test(model, erate, emax=0.1)
    res2 = drivers.uniaxial_test(model2, erate, emax=0.1)
    plt.plot(res['strain'], res['stress'])
    plt.plot(res2['strain'], res2['stress'], ls='--')
    plt.show()
Example #23
0
  def setUp(self):
    self.E = 92000.0
    self.nu = 0.3

    self.s0 = 180.0
    self.Kp = 1000.0
    self.H = 1000.0

    self.elastic = elasticity.IsotropicLinearElasticModel(self.E, "youngs",
        self.nu, "poissons")

    surface = surfaces.IsoKinJ2()
    iso = hardening.LinearIsotropicHardeningRule(self.s0, self.Kp)
    kin = hardening.LinearKinematicHardeningRule(self.H)
    hrule = hardening.CombinedHardeningRule(iso, kin)

    flow = ri_flow.RateIndependentAssociativeFlow(surface, hrule)

    self.bmodel = models.SmallStrainRateIndependentPlasticity(self.elastic, 
        flow)
    
    self.fn = interpolate.PolynomialInterpolate([0.1,5.0, 1e-8])
    self.n = 2.1

    self.model = damage.NEMLWorkDamagedModel_sd(
        self.elastic, self.fn, self.n, self.bmodel, verbose = False)

    self.stress = np.array([100,-50.0,300.0,-99,50.0,125.0]) * 0.75
    self.T = 100.0

    self.s_np1 = self.stress
    self.s_n = np.array([-25,150,250,-25,-100,25]) * 0.0

    self.d_np1 = 0.2
    self.d_n = 0.1

    self.e_np1 = np.array([0.1,-0.01,0.15,-0.05,-0.1,0.15]) * 0.75
    self.e_n = np.array([-0.05,0.025,-0.1,0.2,0.11,0.13]) * 0.0

    self.T_np1 = self.T
    self.T_n = 90.0

    self.t_np1 = 5000.0
    self.t_n = 0.9

    self.u_n = 0.0
    self.p_n = 0.0
  
    # This is a rather boring baseline history state to probe, but I can't
    # think of a better way to get a "generic" history from a generic model
    self.hist_n = np.array([self.d_n] + list(self.bmodel.init_store()))
    self.x_trial = np.array([50,-25,150,-150,190,100.0] + [0.41])

    self.nsteps = 10
    self.etarget = np.array([0.1,-0.025,0.02,0.015,-0.02,-0.05])
    self.ttarget = 2.0

    self.ee = np.dot(self.elastic.S(self.T_np1), self.s_np1*(1.0-self.d_np1) - self.s_n*(1.0-self.d_n))
    self.de = self.e_np1 - self.e_n
    self.dp = self.de - self.ee
    self.dt = self.t_np1 - self.t_n
    self.Wdot = np.dot(self.s_np1*(1.0-self.d_np1), self.dp) / self.dt