示例#1
0
文件: damage.py 项目: dschwen/neml
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()
示例#2
0
def run_compare_test(model, target_times, target_temps, target_strains):
    """
    Run through a single test
  """
    driver = drivers.Driver_sd(model)
    for t, e, T in zip(target_times[1:], target_strains[1:], target_temps[1:]):
        driver.strain_step(e, t, T)

    data = np.concatenate(
        (np.array(driver.t_int)[:, None], np.array(driver.T_int)[:, None],
         np.array(driver.mechanical_strain_int), np.array(driver.stress_int)),
        axis=1)

    return data
示例#3
0
def temp_jump_test(model,
                   erate,
                   strains,
                   Ts,
                   nsteps=50,
                   sdir=np.array([1, 0, 0, 0, 0, 0])):
    """
    Run a temperature jump test.
  """
    driver = drivers.Driver_sd(model)
    strain = []
    stress = []

    for T, de in zip(Ts, strains):
        e_inc = de / nsteps
        for i in range(nsteps):
            einc, ainc = driver.erate_einc_step(sdir, erate, e_inc, T)
            strain.append(np.dot(driver.strain_int[-1], sdir))
            stress.append(np.dot(driver.stress_int[-1], sdir))

    return np.array(strain), np.array(stress)
def load_unload(model,
                emax,
                erate,
                nsteps,
                E,
                ff=1.0,
                verbose=False,
                miter=50,
                T=0):

    sdir = np.array([1.0, 0, 0, 0, 0, 0])

    driver = drivers.Driver_sd(model, verbose=verbose, miter=miter)

    for e in np.linspace(0, emax, nsteps)[1:]:
        driver.erate_step(sdir, erate, e / erate, T)

    t = driver.t[-1]
    my_stress = driver.stress[-1][0]
    dt = my_stress / E / nsteps / erate * ff

    einc_guess = np.array([-1, 0.5, 0.5, 0, 0, 0]) * 1.0e-4
    ainc_guess = -0.01

    for i in range(nsteps):
        t += dt
        if i == 0:
            driver.erate_step(-sdir,
                              erate,
                              t,
                              T,
                              einc_guess=einc_guess,
                              ainc_guess=ainc_guess)
        else:
            driver.erate_step(-sdir, erate, t, T)

    return driver.strain[:, 0], driver.stress[:, 0]