def test_Sim_ass_3(): #####From assignment 3#### laminate_q1 = Laminate('p10/90/0_2/p50s', materialID=1) laminate_q1.compute_all() load = numpy.array([450000, -110000, -130000], dtype=float) load = load * 10**-6 off_stress_norm = load * 10**-3 off_strain = laminate_q1.a.dot(off_stress_norm).reshape((3, 1)) on_strain = numpy.empty((14, 3)) on_stress = numpy.empty((14, 3)) for i in range(14): layer = laminate_q1.layers[i] on_strain[i, :] = transform_strain(off_strain, 'off', layer.theta) on_stress[i, :] = laminate_q1.layers[0].Q_on.dot(on_strain[i, :]) ###### ######From new Sim#### ##### my_sim = Sim(layup='p10/90/0_2/p50s', materialID=1) my_sim.apply_N(numpy.array([[0.4500], [-0.1100], [-0.1300]]) * ureg.MNperm) my_sim.solve() sim_off_strain = numpy.vstack(my_sim.off_strain) sim_on_strain = numpy.vstack(my_sim.on_strain) sim_on_stress = numpy.vstack(my_sim.on_stress) # sim_off_stress = numpy.vstack(my_sim.off_stress) for row in sim_off_strain: # print row array_assert_error(row, off_strain, tol=0.001) # for row in sim_on_strain: # array_assert_error(row,on_strain,tol=0.001) array_assert(sim_on_strain[0::2, :], on_strain, precision=10) array_assert(sim_on_strain[1::2, :], on_strain, precision=10) array_assert(sim_on_stress[0::2, :], on_stress, precision=10) array_assert(sim_on_stress[1::2, :], on_stress, precision=10)
def test_Sim_ass_3(): #####From assignment 3#### laminate_q1 = Laminate('p10/90/0_2/p50s', materialID = 1) laminate_q1.compute_all() load = numpy.array([450000,-110000,-130000],dtype=float) load = load*10**-6 off_stress_norm = load*10**-3 off_strain = laminate_q1.a.dot(off_stress_norm).reshape((3,1)) on_strain = numpy.empty((14,3)) on_stress = numpy.empty((14,3)) for i in range(14): layer = laminate_q1.layers[i] on_strain[i,:] = transform_strain(off_strain,'off',layer.theta) on_stress[i,:] = laminate_q1.layers[0].Q_on.dot(on_strain[i,:]) ###### ######From new Sim#### ##### my_sim = Sim(layup = 'p10/90/0_2/p50s', materialID = 1) my_sim.apply_N(numpy.array([[0.4500],[-0.1100],[-0.1300]])*ureg.MNperm) my_sim.solve() sim_off_strain = numpy.vstack(my_sim.off_strain) sim_on_strain = numpy.vstack(my_sim.on_strain) sim_on_stress = numpy.vstack(my_sim.on_stress) # sim_off_stress = numpy.vstack(my_sim.off_stress) for row in sim_off_strain: # print row array_assert_error(row,off_strain,tol = 0.001) # for row in sim_on_strain: # array_assert_error(row,on_strain,tol=0.001) array_assert(sim_on_strain[0::2,:],on_strain,precision = 10) array_assert(sim_on_strain[1::2,:],on_strain,precision = 10) array_assert(sim_on_stress[0::2,:],on_stress,precision = 10) array_assert(sim_on_stress[1::2,:],on_stress,precision = 10)
def test_by_hand(): import numpy from math import cos, sin, radians load = numpy.array([1,0,0]) angle = 30 tet = radians(float(angle)) my_layer = Layer(2,angle) my_layer.compute_all() off_strain_fast = my_layer.S_off.dot(load) #On-axis stress on_stress_auto = transform_stress(load, 'off',angle) m = cos(tet) n = sin(tet) sigma_x = m**2*load[0] + n**2*load[1] + 2*m*n*load[2] sigma_y = n**2*load[0] + m**2*load[1] -2*m*n*load[2] sigma_s = -m*n*load[0] + m*n*load[1]+(m**2 - n**2)*load[2] sigma_on = numpy.array([sigma_x, sigma_y, sigma_s]) array_assert(sigma_on,on_stress_auto) #On-axis strain on_strain_auto = my_layer.S_on.dot(on_stress_auto) ex = my_layer.PROPS['ex'] ey = my_layer.PROPS['ey'] es = my_layer.PROPS['es'] nuy = my_layer.PROPS['nuy'] nux = my_layer.PROPS['nux'] epsx = sigma_on[0]/ex + sigma_on[1]*(-nuy)/ey epsy = sigma_on[0]*(-nux)/ex + sigma_on[1]/ey epss = + sigma_on[2]/es eps_on = numpy.array([epsx,epsy,epss]) array_assert(eps_on,on_strain_auto) print eps_on print on_strain_auto #Off-axis strain off_strain_auto = transform_strain(on_strain_auto,'on',angle) m = cos(-tet) n = sin(-tet) eps1 = m**2*epsx+n**2*epsy+m*n*epss eps2 = n**2*epsx+m**2*epsy-m*n*epss eps6 = -2*m*n*epsx + 2*m*n*epsy + (m**2-n**2)*epss eps_off = numpy.array([eps1,eps2,eps6]) print eps_off print off_strain_auto array_assert(eps_off,off_strain_auto) #Long auto vs short auto print off_strain_auto print off_strain_fast array_assert(off_strain_auto,off_strain_fast)
def test_off_stress_to_off_strain(): off_stress = numpy.array([10,20,30]) #input angle = 40 my_layer = Layer(2,angle) my_layer.compute_all() off_strain_fast = my_layer.S_off.dot(off_stress) on_stress = transform_stress(off_stress,'off',angle) on_strain = my_layer.S_on.dot(on_stress) off_strain = transform_strain(on_strain,'on',angle) array_assert(off_strain,off_strain_fast)
def test_strain_ninety(): on_axis = numpy.array([200,200,100],dtype=float) off_axis = transform_strain(on_axis,'on',90) off_axis[2] *= -1 array_assert(on_axis, off_axis)
def test_strain_zero(): on_axis = numpy.array([420,-165,-135]) off_axis = transform_strain(on_axis,'on',0) array_assert(off_axis, on_axis)
def test_strain_on_to_off_to_on(): on_axis_og = [420,-165,-135] off_axis = transform_strain(on_axis_og,'on','45.3') on_axis = transform_strain(off_axis,'off','45.3') array_assert(on_axis_og,on_axis)
def test_strain_ninety(): on_axis = numpy.array([200, 200, 100], dtype=float) off_axis = transform_strain(on_axis, 'on', 90) off_axis[2] *= -1 array_assert(on_axis, off_axis)
def test_strain_zero(): on_axis = numpy.array([420, -165, -135]) off_axis = transform_strain(on_axis, 'on', 0) array_assert(off_axis, on_axis)
def test_strain_on_to_off_to_on(): on_axis_og = [420, -165, -135] off_axis = transform_strain(on_axis_og, 'on', '45.3') on_axis = transform_strain(off_axis, 'off', '45.3') array_assert(on_axis_og, on_axis)