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_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 #3
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_nonassri")

        mu = 40000.0
        K = 84000.0

        ys = 100.0
        r = 100.0
        d = 1000.0

        cs = [5.0, 10.0]
        gs = [1000.0, 1000.0]
        As = [0.0, 0.0]
        ns = [1.0, 1.0]

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

        surface = surfaces.IsoKinJ2()
        iso = hardening.VoceIsotropicHardeningRule(ys, r, d)

        gammas = [hardening.ConstantGamma(g) for g in gs]
        hmodel = hardening.Chaboche(iso, cs, gammas, As, ns)
        flow = ri_flow.RateIndependentNonAssociativeHardening(surface, hmodel)

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

        self.T = 300.0
        self.tmax = 10.0
        self.nsteps = 100
        self.emax = np.array([0.05, 0, 0, 0, 0, 0])
Example #4
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 #5
0
    def setUp(self):
        self.model1 = parse.parse_xml(localize("examples.xml"), "test_perfect")

        E = [-100, 100000]
        nu = 0.3

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

        surface = surfaces.IsoJ2()

        Ts = [100.0, 300.0, 500.0, 700.0]
        Sys = [1000.0, 120.0, 60.0, 30.0]

        yields = interpolate.PiecewiseLinearInterpolate(Ts, Sys)

        self.model2 = models.SmallStrainPerfectPlasticity(
            elastic, surface, yields)

        self.T = 550.0
        self.tmax = 10.0
        self.nsteps = 50
        self.emax = np.array([0.1, 0.05, 0, -0.025, 0, 0])
Example #6
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_perzyna")

        mu = 40000.0
        K = 84000.0

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

        sy = 100.0
        r = 100.0
        d = 1000.0
        KK = 1000.0

        n = 5.0
        eta = 500.0

        surface = surfaces.IsoKinJ2()
        iso = hardening.VoceIsotropicHardeningRule(sy, r, d)
        kin = hardening.LinearKinematicHardeningRule(KK)

        hmodel = hardening.CombinedHardeningRule(iso, kin)

        gmodel = visco_flow.GPowerLaw(n, eta)

        vmodel = visco_flow.PerzynaFlowRule(surface, hmodel, gmodel)
        flow = general_flow.TVPFlowRule(elastic, vmodel)

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

        self.T = 550.0 + 273.15
        self.tmax = 10.0
        self.nsteps = 100.0
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #7
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_pcreep")

        E = [-100, 100000]
        nu = 0.3

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

        surface = surfaces.IsoJ2()

        Ts = [100.0, 300.0, 500.0, 700.0]
        Sys = [1000.0, 120.0, 60.0, 30.0]

        yields = interpolate.PiecewiseLinearInterpolate(Ts, Sys)

        pmodel = models.SmallStrainPerfectPlasticity(elastic, surface, yields)

        self.T = 550.0
        self.tmax = 10.0
        self.nsteps = 50.0
        self.emax = np.array([0.1, 0.05, 0, -0.025, 0, 0])

        A = 1.85e-10
        n = 2.5

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

        self.model2 = models.SmallStrainCreepPlasticity(
            elastic, pmodel, cmodel)
Example #8
0
    def setUp(self):
        self.ro = 5
        self.ri = 4.5
        self.h = 2.5

        self.nr = 10
        self.nt = 20
        self.nz = 5

        self.E = 150000.0
        self.nu = 0.35

        self.tube = receiver.Tube(self.ro, self.ro - self.ri, self.h, self.nr,
                                  self.nt, self.nz)
        self.times = np.array([0, 1])
        self.tube.set_times(self.times)

        self.tube.set_pressure_bc(
            receiver.PressureBC(self.times, self.times / 50.0))

        self.mat = parse.parse_xml(
            os.path.join(os.path.dirname(__file__), "moose-verification",
                         "model.xml"),
            "creeping",
        )

        self.d = 0.25

        self.solver = structural.PythonTubeSolver(verbose=False)
Example #9
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 #10
0
def run_gr91_316_inelastic():
    mat_inner = parse.parse_xml('gr91.xml', 'gr91_simple')
    mat_outer = parse.parse_xml('316.xml', '316_simple')

    # Remember we take the 1/2 symmetry view
    l1 = 58.7375
    l2 = 46.0375
    l3 = 12.7

    A1 = np.pi * (19.05**2.0 - (19.05 - 6.35)**2.0)
    A2 = np.pi * 9.525**2.0
    A3 = np.pi * 3.175**2.0
    """
  T1 = 160.0 + 273.15
  T2 = 548.9 + 273.15
  ramp = 1*3600.0
  hold = 1000*3600.0
  model_1 = ThreeBarProblem(l1, l2, l3, A1, A2, A3, mat_outer, mat_inner,
      mat_inner, T1)
  model_1.run_standard_cycle(T1, T2, ramp, ramp, hold, 25, 25, 25, 2, 
      verbose = True)
  """

    T1 = 354.4 + 273.15
    T2 = 548.9 + 273.15
    ramp = 1 * 3600.0
    hold = 1000 * 3600.0
    model_2 = ThreeBarProblem(l1, l2, l3, A1, A2, A3, mat_outer, mat_inner,
                              mat_inner, T1)
    model_2.run_standard_cycle(T1,
                               T2,
                               ramp,
                               ramp,
                               hold,
                               25,
                               25,
                               25,
                               20,
                               verbose=False)

    print("Strain range: %f" %
          (np.max(model_2.em3[-75:]) - np.min(model_2.em3[-75:])))

    plt.plot(np.array(model_2.t) / 3600.0, model_2.em3)
    plt.xlabel("Time (hrs)")
    plt.ylabel("Mechanical strain in gauge bar (mm/mm)")
    plt.show()
Example #11
0
def compare_gr91_316_elastic():
    mat_inner = parse.parse_xml('gr91.xml', 'gr91_elastic')
    mat_outer = parse.parse_xml('316.xml', '316_elastic')

    # Remember we take the 1/2 symmetry view
    l1 = 58.7375
    l2 = 46.0375
    l3 = 12.7

    A1 = np.pi * (19.05**2.0 - (19.05 - 6.35)**2.0)
    A2 = np.pi * 9.525**2.0
    A3 = np.pi * 3.175**2.0

    T1 = 160.0 + 273.15
    T2 = 548.9 + 273.15
    model_1 = ThreeBarProblem(l1, l2, l3, A1, A2, A3, mat_outer, mat_inner,
                              mat_inner, T1)
    model_1.run_standard_cycle(T1,
                               T2,
                               1.0,
                               1.0,
                               0,
                               10,
                               10,
                               0,
                               1,
                               verbose=False)
    range_1 = np.max(model_1.em3) - np.min(model_1.em3)

    T1 = 354.4 + 273.15
    T2 = 548.9 + 273.15
    model_2 = ThreeBarProblem(l1, l2, l3, A1, A2, A3, mat_outer, mat_inner,
                              mat_inner, T1)
    model_2.run_standard_cycle(T1,
                               T2,
                               1.0,
                               1.0,
                               0,
                               10,
                               10,
                               0,
                               1,
                               verbose=False)
    range_2 = np.max(model_2.em3) - np.min(model_2.em3)

    print("320 F to 1020 F: %f" % range_1)
    print("670 F to 1020 F: %f" % range_2)
Example #12
0
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']))
Example #13
0
def rtt(tdir):
    """
    Load a model from tdir, load the time, temperature, and strain data
    from the csv file, run the test, and compare the stresses
  """
    model = parse.parse_xml(os.path.join(tdir, default_xml_file),
                            default_model_name)
    input_data = np.loadtxt(os.path.join(tdir, default_result_name),
                            delimiter=',',
                            skiprows=1)

    output_data = run_compare_test(model, input_data[:, 0], input_data[:, 1],
                                   input_data[:, 2:8])

    return input_data[:, 8:14], output_data[:, 8:14]
Example #14
0
File: run.py Project: dvp2015/neml
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
Example #15
0
    def setUp(self):
        self.model1 = parse.parse_xml("test/examples.xml", "test_yaguchi")

        mu_poly = [-0.11834615, 115.5, 48807.69]
        K_poly = [-0.256417, 250.25, 105750.0]

        shear = interpolate.PolynomialInterpolate(mu_poly)
        bulk = interpolate.PolynomialInterpolate(K_poly)
        elastic = elasticity.IsotropicLinearElasticModel(
            shear, "shear", bulk, "bulk")

        vmodel = visco_flow.YaguchiGr91FlowRule()

        flow = general_flow.TVPFlowRule(elastic, vmodel)

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

        self.T = 500.0
        self.tmax = 10.0
        self.nsteps = 100.0
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #16
0
    def setUp(self):
        self.model1 = parse.parse_xml(localize("examples.xml"),
                                      "test_rd_chaboche")

        mu = 60384.61
        K = 130833.3

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

        r = -80.0
        d = 3.0

        Cs = [135.0e3, 61.0e3, 11.0e3]
        gs = [5.0e4, 1100.0, 1.0]
        As = [0.0, 0.0, 0.0]
        ns = [1.0, 1.0, 1.0]
        gmodels = [hardening.ConstantGamma(g) for g in gs]

        eta = 701.0

        n = 10.5

        surface = surfaces.IsoKinJ2()
        iso = hardening.VoceIsotropicHardeningRule(0.0, r, d)

        hmodel = hardening.Chaboche(iso, Cs, gmodels, As, ns)

        fluidity = visco_flow.ConstantFluidity(eta)

        vmodel = visco_flow.ChabocheFlowRule(surface, hmodel, fluidity, n)
        flow = general_flow.TVPFlowRule(elastic, vmodel)

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

        self.T = 550.0 + 273.15
        self.tmax = 10.0
        self.nsteps = 100
        self.emax = np.array([0.1, 0, 0, 0, 0, 0])
Example #17
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 #18
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 #19
0
 def test_top(self):
     with self.assertRaises(parse.InvalidType):
         test = parse.parse_xml("test/examples.xml", "test_badtop")
Example #20
0
        ], [
            214750.0, 213658.571429, 212587.755102, 211548.29932,
            210508.843537, 209469.387755, 208429.931973, 207451.428571,
            206515.918367, 205580.408163, 204526.530612, 203279.183673,
            202031.836735, 200838.367347, 199902.857143, 198967.346939,
            198031.836735, 197096.326531, 196160.816327, 195225.306122,
            194053.061224, 192805.714286, 191558.367347, 190311.020408,
            189063.673469, 187816.326531, 186568.979592, 185321.632653,
            184074.285714, 182826.938776, 181579.591837, 180332.244898,
            179084.897959, 177546.938776, 175987.755102, 174428.571429,
            172643.265306, 170772.244898, 168901.22449, 166868.571429,
            164685.714286, 162502.857143, 160222.857143, 157728.163265,
            155233.469388, 152738.77551, 150244.081633, 147749.387755,
            145254.693878, 142760.0
        ]), "youngs", 0.3, "poissons")
    bmodel = parse.parse_xml("example.xml", "gr91_simple")

    fn = interpolate.PolynomialInterpolate(
        [-6.65303514e-09, 2.95224385e-04, -6.19561357e-01])
    C = 28.0
    lmr = larsonmiller.LarsonMillerRelation(fn, C)
    estress = damage.VonMisesEffectiveStress()
    model = damage.LarsonMillerCreepDamageModel_sd(emodel, lmr, estress,
                                                   bmodel)

    T = 550 + 273.15

    lmps = []

    for s in srange:
        res = drivers.creep(model,
Example #21
0
 def test_badobject(self):
     with self.assertRaises(RuntimeError):
         test = parse.parse_xml(localize("examples.xml"), "test_badobject")
Example #22
0
    t0 = 50.0
    ts = 50.0
    b = 100.0

    g0 = 1.0
    n = 12.0

    # Setup
    L *= erate
    dt = emax / steps / erate

    d = nemlmath.sym(0.5 * (L + L.T))
    w = nemlmath.skew(0.5 * (L - L.T))

    model = parse.parse_xml("cpmodel.xml", "example")

    T = 300.0

    h_n = model.init_store()

    s_n = np.zeros((6, ))

    d_n = np.zeros((6, ))
    w_n = np.zeros((3, ))

    u_n = 0.0
    p_n = 0.0
    t_n = 0.0
    T_n = T
Example #23
0
H = 2500.0
iso = hardening.LinearIsotropicHardeningRule(sY, H)

eta = 100.0
n = 5.0
gpower = visco_flow.GPowerLaw(n, eta)
vflow = visco_flow.PerzynaFlowRule(surface, iso, gpower)

integrator = general_flow.TVPFlowRule(elastic, vflow)

model = models.GeneralIntegrator(elastic, integrator)

erate = 1.0e-4
res = drivers.uniaxial_test(model, erate)

plt.figure()
plt.plot(res['strain'], res['stress'], 'k-')
plt.xlabel("Strain (mm/mm)")
plt.ylabel("Stress (MPa)")
plt.show()

model2 = parse.parse_xml("tutorial.xml", "tutorial_model")

res2 = drivers.uniaxial_test(model2, erate)

plt.figure()
plt.plot(res2['strain'], res2['stress'], 'k-')
plt.xlabel("Strain (mm/mm)")
plt.ylabel("Stress (MPa)")
plt.show()
Example #24
0
 def get_neml_model(self):
     """
   Return the actual model for use in a solve
 """
     return parse.parse_xml(self.xmlfile, self.modelname)
Example #25
0
from srlife import receiver, structural

# Moose comparison stuff
# MOOSE test stuff
ramp = lambda x: np.piecewise(x, [x < 1, x >= 1],
                              [lambda xx: xx, lambda xx: 1.0 + xx * 0.0])
unit_temperature = lambda x, y, z: (np.sqrt(x**2.0 + y**2.0) - 9) / (
    10 - 9) * np.cos(np.arctan2(y, x)) * (z / 10.0 + 1)
temperature = lambda t, x, y, z: np.array(
    [100 * ramp(ti) * unit_temperature(x, y, z) for ti in t])
pressure = lambda t: 1.0 * ramp(t)

times = np.array(
    [0, 0.5, 1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001])
mat = parse.parse_xml(
    os.path.join(os.path.dirname(__file__), 'moose-verification', 'model.xml'),
    'creeping')

ri = 9.0
ro = 10.0
h = 10.0
nr = 11
nt = 20
nz = 6

moose_base = os.path.join(os.path.dirname(__file__), 'moose-verification')
moose_ver = [
    os.path.join(moose_base, f) for f in ['1d_out.e', '2d_out.e', '3d_out.e']
]

Example #26
0
 def test_badobject(self):
     with self.assertRaises(RuntimeError):
         test = parse.parse_xml("test/examples.xml", "test_badobject")
Example #27
0
    parser.add_argument("--nsteps",
                        default=100,
                        type=int,
                        help="Number of load steps to use")

    args = parser.parse_args()

    if not os.path.exists(args.directory):
        raise ValueError("Directory %s does not exist!" % args.directory)

    model_file = os.path.join(args.directory, default_xml_file)
    if not os.path.exists(model_file):
        raise ValueError("Model file %s does not exist!" % model_file)

    try:
        model = parse.parse_xml(model_file, default_model_name)
    except Exception:
        raise ValueError("Cannot load model name %s from file %s!" %
                         (model_file, default_model_name))

    result = generate_tensile_test(model,
                                   T=args.temperature,
                                   erate=args.strain_rate,
                                   emax=args.maximum_strain,
                                   nsteps=args.nsteps)

    outfile = os.path.join(args.directory, default_result_name)
    np.savetxt(
        outfile,
        result,
        delimiter=',',
]

# Moose comparison stuff
# MOOSE test stuff
ramp = lambda x: np.piecewise(x, [x < 1, x >= 1],
                              [lambda xx: xx, lambda xx: 1.0 + xx * 0.0])
unit_temperature = (lambda x, y, z: (np.sqrt(x**2.0 + y**2.0) - 9) /
                    (10 - 9) * np.cos(np.arctan2(y, x)) * (z / 10.0 + 1))
temperature = lambda t, x, y, z: np.array(
    [100 * ramp(ti) * unit_temperature(x, y, z) for ti in t])
pressure = lambda t: 1.0 * ramp(t)

times = np.array(
    [0, 0.5, 1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001])
mat = parse.parse_xml(
    os.path.join(os.path.dirname(__file__), "moose-verification", "model.xml"),
    "creeping",
)

ri = 9.0
ro = 10.0
h = 10.0
nr = 11
nt = 20
nz = 6

moose_base = os.path.join(os.path.dirname(__file__), "moose-verification")
moose_ver = [
    os.path.join(moose_base, f) for f in ["1d_out.e", "2d_out.e", "3d_out.e"]
]