def setUp(self): self.strength = 35.0 self.H = history.History() self.H.add_scalar("strength") self.H.set_scalar("strength", self.strength) self.H.add_scalar("whatever") self.H.set_scalar("whatever", 0.5) self.tau0 = 10.0 self.tau_sat = 50.0 self.b = 2.5 self.strengthmodel = slipharden.VoceSlipHardening( self.tau_sat, self.b, self.tau0) self.g0 = 1.0 self.n = 3.0 self.slipmodel = sliprules.PowerLawSlipRule(self.strengthmodel, self.g0, self.n) self.imodel = inelasticity.AsaroInelasticity(self.slipmodel) self.L = crystallography.CubicLattice(1.0) self.L.add_slip_system([1, 1, 0], [1, 1, 1]) self.Q = rotations.Orientation(35.0, 17.0, 14.0, angle_type="degrees") self.S = tensors.Symmetric( np.array([[100.0, -25.0, 10.0], [-25.0, -17.0, 15.0], [10.0, 15.0, 35.0]])) self.T = 300.0 self.mu = 29000.0 self.E = 120000.0 self.nu = 0.3 self.emodel = elasticity.CubicLinearElasticModel( self.E, self.nu, self.mu, "moduli") self.dn = np.array([[4.1, 2.8, -1.2], [3.1, 7.1, 0.2], [4, 2, 3]]) self.dn = 0.5 * (self.dn + self.dn.T) self.d = tensors.Symmetric(self.dn) self.wn = np.array([[-9.36416517, 2.95527444, 8.70983194], [-1.54693052, 8.7905658, -5.10895168], [-8.52740468, -0.7741642, 2.89544992]]) self.wn = 0.5 * (self.wn - self.wn.T) self.w = tensors.Skew(self.wn) self.dmodel = crystaldamage.NilDamageModel() self.model = kinematics.DamagedStandardKinematicModel( self.emodel, self.imodel, self.dmodel) self.fspin = self.model.spin(self.S, self.d, self.w, self.Q, self.H, self.L, self.T, history.History()) self.fixed = self.model.decouple(self.S, self.d, self.w, self.Q, self.H, self.L, self.T, history.History())
def test_normal_usecase(self): """ Actually check that the stiffness in the appropriate direction resolves to zero """ strain = tensors.Symmetric(np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])) emodel = elasticity.CubicLinearElasticModel(100000.0, 0.3, 60000.0, "moduli") C = emodel.C_tensor(0) n = tensors.Vector([1.0, -1, 1]).normalize() P = projections.normal_projection_ss(n) PP = tensors.SymSymR4.id() - P PC = PP.dot(C) stress = PC.dot(strain).to_full() val = stress.dot(n).dot(n) self.assertAlmostEqual(val, 0) # Some random orthogonal direction s = n.cross(tensors.Vector([1, 0.0, 0])).normalize() val = stress.dot(s).dot(s) val2 = C.dot(strain).dot(s).dot(s) self.assertAlmostEqual(val, val2)
def setUp(self): self.mu = 29000.0 self.E = 120000.0 self.nu = 0.3 self.T = 325.0 self.Q = rotations.Orientation(31.0, 59.0, 80.0, angle_type = "degrees", convention = "bunge") self.Q_cube = rotations.Orientation(90.0, 0.0, 0.0, angle_type = "degrees", convention = "bunge") self.model = elasticity.CubicLinearElasticModel(self.E, self.nu, self.mu, "moduli") self.v1 = tensors.Vector(np.array([1.0,0.0,0])) self.v2 = tensors.Vector(np.array([0.0,1.0,0]))
def setUp(self): self.N = 10 self.tau0 = 10.0 self.tau_sat = 50.0 self.b = 2.5 self.strengthmodel = slipharden.VoceSlipHardening(self.tau_sat, self.b, self.tau0) self.g0 = 1.0 self.n = 3.0 self.slipmodel = sliprules.PowerLawSlipRule(self.strengthmodel, self.g0, self.n) self.imodel = inelasticity.AsaroInelasticity(self.slipmodel) self.L = crystallography.CubicLattice(1.0) self.L.add_slip_system([1,1,0],[1,1,1]) self.Q = rotations.Orientation(35.0,17.0,14.0, angle_type = "degrees") self.mu = 29000.0 self.E = 120000.0 self.nu = 0.3 self.emodel = elasticity.CubicLinearElasticModel(self.E, self.nu, self.mu, "moduli") self.kmodel = kinematics.StandardKinematicModel(self.emodel, self.imodel) self.model = singlecrystal.SingleCrystalModel(self.kmodel, self.L, miter = 120) self.orientations = rotations.random_orientations(self.N) self.D = np.array([0.01,-0.002,-0.003,0.012,-0.04,0.01]) self.W = np.array([0.02,-0.02,0.03]) self.T = 300.0 self.dt = 2.0
def test_shear_usecase(self): """ Actually check that the stiffness in the shear directions resolves to zero """ strain = tensors.Symmetric(np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])) emodel = elasticity.CubicLinearElasticModel(100000.0, 0.3, 60000.0, "moduli") C = emodel.C_tensor(0) n = tensors.Vector([1.0, -1, 1]).normalize() s = n.cross(tensors.Vector([1, 0, 0])).normalize() t = n.cross(s) P = projections.shear_projection_ss(n) PP = tensors.SymSymR4.id() - P PC = PP.dot(C) stress = PC.dot(strain).to_full() v1 = stress.dot(n).dot(s) self.assertAlmostEqual(v1, 0) v2 = stress.dot(n).dot(t) self.assertAlmostEqual(v2, 0) extra = (s + t).normalize() v3 = stress.dot(n).dot(extra) self.assertAlmostEqual(v3, 0) # IDK, i guess check normal on a different plane vn1 = stress.dot(n).dot(n) vn2 = C.dot(strain).dot(n).dot(n) self.assertAlmostEqual(vn1, vn2) # IDK, i guess check shear on a different plane vn1 = stress.dot(s).dot(t) vn2 = C.dot(strain).dot(s).dot(t) self.assertAlmostEqual(vn1, vn2)
def setUp(self): self.tau0 = 10.0 self.tau_sat = 50.0 self.b = 2.5 self.strengthmodel = slipharden.VoceSlipHardening( self.tau_sat, self.b, self.tau0) self.g0 = 1.0 self.n = 3.0 self.slipmodel = sliprules.PowerLawSlipRule(self.strengthmodel, self.g0, self.n) self.imodel = inelasticity.AsaroInelasticity(self.slipmodel) self.L = crystallography.CubicLattice(1.0) self.L.add_slip_system([1, 1, 0], [1, 1, 1]) self.Q = rotations.Orientation(35.0, 17.0, 14.0, angle_type="degrees") self.mu = 29000.0 self.E = 120000.0 self.nu = 0.3 self.emodel = elasticity.CubicLinearElasticModel( self.E, self.nu, self.mu, "moduli") self.kmodel = kinematics.StandardKinematicModel( self.emodel, self.imodel) self.model = singlecrystal.SingleCrystalModel(self.kmodel, self.L, initial_rotation=self.Q) self.model_no_rot = singlecrystal.SingleCrystalModel( self.kmodel, self.L, initial_rotation=self.Q, update_rotation=False, verbose=False) self.T = 300.0 self.stress_n = np.array([120.0, -60.0, 170.0, 35.0, 80.0, -90.0]) self.stress_np1 = np.array([15.0, -40.0, 120.0, 70.0, -10.0, -50.0]) self.d = np.array([0.1, -0.2, 0.25, 0.11, -0.05, 0.075]) self.w = np.array([0.1, 0.2, -0.2]) self.strength_n = 25.0 self.strength_np1 = 30.0 self.S_np1 = tensors.Symmetric(common.usym(self.stress_np1)) self.S_n = tensors.Symmetric(common.usym(self.stress_n)) self.D = tensors.Symmetric(common.usym(self.d)) self.W = tensors.Skew(common.uskew(self.w)) self.strength_n = 25.0 self.strength_np1 = 30.0 self.H_n = history.History() self.H_n.add_scalar("strength") self.H_n.set_scalar("strength", self.strength_n) self.H_np1 = history.History() self.H_np1.add_scalar("strength") self.H_np1.set_scalar("strength", self.strength_np1) self.dt = 2.0 self.fixed = self.kmodel.decouple(self.S_n, self.D, self.W, self.Q, self.H_n, self.L, self.T, history.History()) self.ts = singlecrystal.SCTrialState(self.D, self.W, self.S_n, self.H_n, self.Q, self.L, self.T, self.dt, self.fixed) self.x = np.zeros((self.model.nparams, )) self.x[:6] = self.stress_np1 self.x[6] = self.strength_np1 self.Ddir = np.array([0.01, -0.005, -0.003, 0.01, 0.02, -0.003]) * 2 self.Wdir = np.array([0.02, -0.03, 0.01]) * 2 self.nsteps = 10
t0 = 100.0 b = 10.0 sat = 50 g0 = 1.0e-4 n = 6.0 mu = 29000.0 E = 120000.0 nu = 0.3 c = 40 beta = 3.0 emodel = elasticity.CubicLinearElasticModel(E, nu, mu, "moduli") strengthmodel = slipharden.VoceSlipHardening(sat, b, t0) slipmodel = sliprules.PowerLawSlipRule(strengthmodel, g0, n) imodel = inelasticity.AsaroInelasticity(slipmodel) base_kin = kinematics.StandardKinematicModel(emodel, imodel) base_cp_model = singlecrystal.SingleCrystalModel(base_kin, lattice) base_model = polycrystal.TaylorModel(base_cp_model, orientations, nthreads=nthreads) base_kin = kinematics.StandardKinematicModel(emodel, imodel) base_cp_model = singlecrystal.SingleCrystalModel(base_kin, lattice)
def setUp(self): self.L = crystallography.CubicLattice(1.0) self.L.add_slip_system([1, 1, 0], [1, 1, 1]) self.nslip = self.L.ntotal self.strength = 35.0 self.c = 10.0 self.beta = 2.0 self.H = history.History() for i in range(12): self.H.add_scalar("strength" + str(i)) self.H.set_scalar("strength" + str(i), self.strength) for j in range(4): self.H.add_scalar("slip_damage_" + str(j)) self.H.set_scalar("slip_damage_" + str(j), self.c * 0.4) self.static = 20.0 self.s0 = [self.static] * self.nslip self.k = 1000.0 self.sat = 40.0 self.m = 1.5 self.strengthmodel = slipharden.VocePerSystemHardening( self.s0, [self.k] * self.nslip, [self.sat] * self.nslip, [self.m] * self.nslip) self.g0 = 1.0 self.n = 3.0 self.slipmodel = sliprules.PowerLawSlipRule(self.strengthmodel, self.g0, self.n) self.imodel = inelasticity.AsaroInelasticity(self.slipmodel) self.Q = rotations.Orientation(35.0, 17.0, 14.0, angle_type="degrees") self.S = tensors.Symmetric( np.array([[100.0, -25.0, 10.0], [-25.0, -17.0, 15.0], [10.0, 15.0, 35.0]])) self.T = 300.0 self.mu = 29000.0 self.E = 120000.0 self.nu = 0.3 self.emodel = elasticity.CubicLinearElasticModel( self.E, self.nu, self.mu, "moduli") self.dn = np.array([[4.1, 2.8, -1.2], [3.1, 7.1, 0.2], [4, 2, 3]]) self.dn = 0.5 * (self.dn + self.dn.T) self.d = tensors.Symmetric(self.dn) self.wn = np.array([[-9.36416517, 2.95527444, 8.70983194], [-1.54693052, 8.7905658, -5.10895168], [-8.52740468, -0.7741642, 2.89544992]]) self.wn = 0.5 * (self.wn - self.wn.T) self.w = tensors.Skew(self.wn) self.dmodel = crystaldamage.WorkPlaneDamage() self.nfunc = crystaldamage.SigmoidTransformation(self.c, self.beta) self.sfunc = crystaldamage.SigmoidTransformation(self.c, self.beta) self.dmodel = crystaldamage.PlanarDamageModel(self.dmodel, self.nfunc, self.sfunc, self.L) self.model = kinematics.DamagedStandardKinematicModel( self.emodel, self.imodel, self.dmodel) self.fspin = self.model.spin(self.S, self.d, self.w, self.Q, self.H, self.L, self.T, history.History()) self.fixed = self.model.decouple(self.S, self.d, self.w, self.Q, self.H, self.L, self.T, history.History())