def test_block_diagonal(self): self.assertTrue(np.allclose(matrix.SquareMatrix(4, type = "diagonal_blocks", data = [1,2], blocks = [3,1]), np.array([ [1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,2]])))
def test_blocks(self): self.assertTrue(np.allclose(matrix.SquareMatrix(4, type = "block", data = [1,2,3,4], blocks=[3,1]), np.array([ [1,1,1,2], [1,1,1,2], [1,1,1,2], [3,3,3,4]])))
def setUp(self): self.a_data = [1.0,1.1,2.3] self.a = matrix.FlatVector(self.a_data) self.b_data = [-8.0,1.1,2.2,3.3] self.b = matrix.FlatVector(self.b_data) self.M_data = np.array([[2.0,3.0,1.0],[7.1,3.1,-1.0],[2.0,-1.2,8.1]]) self.M = matrix.SquareMatrix(3, type = "dense", data = list(self.M_data.flatten()))
def setUp(self): 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]])) * 3 self.H = history.History() self.T = 300.0 E = 160000.0 nu = 0.31 self.g0 = 1.0e-4 self.n = 10.0 K = E / 50.0 s0 = 75.0 M = matrix.SquareMatrix(self.L.ntotal, type="dense", data=[K] * (self.L.ntotal * self.L.ntotal)) self.isostrength = slipharden.GeneralLinearHardening(M, [s0 / 2] * self.L.ntotal, absval=False) self.flowresistance = slipharden.GeneralLinearHardening(M, [s0 / 2] * self.L.ntotal, absval=False) self.backstrength = slipharden.GeneralLinearHardening(M, [0] * self.L.ntotal, absval=False) self.strengths = [ self.backstrength, self.isostrength, self.flowresistance ] self.model = sliprules.KinematicPowerLawSlipRule( self.backstrength, self.isostrength, self.flowresistance, self.g0, self.n) self.model.populate_history(self.H) self.model.init_history(self.H) self.strength_values = np.linspace(0, 10, 36) + 5.0 self.H.copy_data(self.strength_values) self.fixed = history.History()
def setUp(self): 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.nslip = self.L.ntotal self.static = 20.0 self.current = 25.0 self.H = history.History() for i in range(self.nslip): self.H.add_scalar("strength" + str(i)) self.H.set_scalar("strength" + str(i), self.current) self.T = 300.0 self.M = matrix.SquareMatrix(self.nslip, type="block", data=[0.1, 0.2, 0.3, 0.4], blocks=[6, 6]) self.s0 = [self.static] * self.nslip self.model = slipharden.GeneralLinearHardening(self.M, self.s0, absval=False) self.g0 = 1.0 self.n = 3.0 self.sliprule = sliprules.PowerLawSlipRule(self.model, self.g0, self.n) self.fixed = history.History()
def test_diagonal(self): self.assertTrue(np.allclose(matrix.SquareMatrix(4, type = "diagonal", data = [1,2,3,4]), np.diag([1,2,3,4])))
def test_identity(self): self.assertTrue(np.allclose(matrix.SquareMatrix(4, type = "identity"), np.eye(4)))
def test_zero(self): self.assertTrue(np.allclose(matrix.SquareMatrix(4), np.zeros((4,4))))
def setUp(self): self.np_mat = np.array([[2.0,3.0,1.0],[7.1,3.1,-1.0],[2.0,-1.2,8.1]]) self.M = matrix.SquareMatrix(3, type = "dense", data = list(self.np_mat.flatten()))
K = E / 50.0 s0 = 75.0 emax = 0.01 erate = 1.0e-4 R = -0.5 ncycles = 3 lattice = crystallography.CubicLattice(1.0) lattice.add_slip_system([1,1,0],[1,1,1]) orientations = rotations.random_orientations(N) # Matrix used in the hardening options M = matrix.SquareMatrix(lattice.ntotal, type = "diagonal", data = [K] * lattice.ntotal) # Option 1: diagonal hardening with: # 1) Initial strength of 75 # 2) K = E / 50 # 3) abs on the slip rates h1 = slipharden.GeneralLinearHardening(M, [s0] * lattice.ntotal, absval = True) # Option 2: diagonal hardening with: # 1) Initial strength of 37.5 # 2) K = E / 50 # 3) abs on the slip rates h2 = slipharden.GeneralLinearHardening(M, [s0/2] * lattice.ntotal, absval = True) h2b = slipharden.GeneralLinearHardening(M, [s0/2] * lattice.ntotal,