def test_shell_lb(): for model in [ 'plate_clpt_donnell_bardell', 'cylshell_clpt_donnell_bardell', ]: # ssss s = Shell() s.m = 12 s.n = 12 s.stack = [0, 90, -45, +45, +45, -45, 90, 0] s.plyt = 0.125e-3 s.laminaprop = (142.5e9, 8.7e9, 0.28, 5.1e9, 5.1e9, 5.1e9) s.model = model s.a = 2. s.b = 1. s.r = 1.e8 s.Nxx = -1 eigvals, eigvecs = lb(s.calc_kC(), s.calc_kG(), silent=True) assert np.isclose(eigvals[0], 157.5369886, atol=0.1, rtol=0) s.Nxx = 0 s.Nyy = -1 eigvals, eigvecs = lb(s.calc_kC(), s.calc_kG(), silent=True) assert np.isclose(eigvals[0], 58.1488566, atol=0.1, rtol=0) # ssfs s = Shell() s.y2u = 1 s.y2v = 1 s.y2w = 1 s.m = 12 s.n = 13 s.stack = [0, 90, -45, +45] s.plyt = 0.125e-3 s.laminaprop = (142.5e9, 8.7e9, 0.28, 5.1e9, 5.1e9, 5.1e9) s.model = model s.a = 1. s.b = 0.5 s.r = 1.e8 s.Nxx = -1 eigvals, eigvecs = lb(s.calc_kC(), s.calc_kG(), silent=True) assert np.isclose(eigvals[0], 15.8106238, atol=0.1, rtol=0) s.x2u = 1 s.x2v = 1 s.x2w = 1 s.y2u = 0 s.y2v = 0 s.y2w = 0 s.Nxx = 0 s.Nyy = -1 eigvals, eigvecs = lb(s.calc_kC(), s.calc_kG(), silent=True) assert np.isclose(eigvals[0], 14.046, atol=0.1, rtol=0) plot_shell(s, eigvecs[:, 0], vec='w')
def test_lb_isotropic(): #NOTE ssss boundary conditions by default s = Shell() s.m = 12 s.n = 12 s.stack = [0, 90, -45, +45, +45, -45, 90, 0] thickness = 1e-3 E = 70e9 nu = 0.33 s.a = 2. s.b = 1. s.r = 2. # compression # it is possible to apply any static load if necessary s.Nxx = -1 # shear s.Nxy = -1 s.plyt = thickness s.laminaprop = (E, E, nu) s.model = 'cylshell_clpt_donnell_bardell' # radius eigvals, eigvecs = lb(s.calc_kC(), s.calc_kG(), silent=True) plot_shell(s, eigvecs[:, 0], vec='w', filename='example_isotropic.png')
def test_calc_linear_buckling(): E11 = 71.e9 nu = 0.33 plyt = 0.007 lam = read_stack([0], plyt=plyt, laminaprop=(E11, E11, nu)) ans = { 'edge-based': 41.85273, 'cell-based': 6.98852939, 'cell-based-no-smoothing': 4.921956 } for prop_from_nodes in [True, False]: for k0s_method in [ 'edge-based', 'cell-based', 'cell-based-no-smoothing' ]: mesh = read_mesh( os.path.join(THISDIR, 'nastran_plate_16_nodes.dat')) for tria in mesh.elements.values(): tria.prop = lam for node in mesh.nodes.values(): node.prop = lam k0 = calc_k0(mesh, prop_from_nodes) add_k0s(k0, mesh, prop_from_nodes, k0s_method, alpha=0.2) # running static subcase first dof = 5 n = k0.shape[0] // 5 fext = np.zeros(n * dof, dtype=np.float64) fext[mesh.nodes[4].index * dof + 0] = -500. fext[mesh.nodes[7].index * dof + 0] = -500. fext[mesh.nodes[5].index * dof + 0] = -1000. fext[mesh.nodes[6].index * dof + 0] = -1000. # boundary conditions def bc(K): for i in [1, 10, 11, 12]: for j in [0, 1, 2]: K[mesh.nodes[i].index * dof + j, :] = 0 K[:, mesh.nodes[i].index * dof + j] = 0 for i in [2, 3, 4, 5, 6, 7, 8, 9]: for j in [1, 2]: K[mesh.nodes[i].index * dof + j, :] = 0 K[:, mesh.nodes[i].index * dof + j] = 0 bc(k0) k0 = coo_matrix(k0) d = solve(k0, fext, silent=True) kG = calc_kG(d, mesh, prop_from_nodes) bc(kG) kG = coo_matrix(kG) eigvals, eigvecs = lb(k0, kG, silent=True) print('k0s_method, eigvals[0]', k0s_method, eigvals[0]) assert np.isclose(eigvals[0], ans[k0s_method])
def test_lb_orthotropic(): #NOTE ssss boundary conditions by default s = Shell() s.m = 12 s.n = 12 s.stack = [0, 90, -45, +45, +45, -45, 90, 0] s.plyt = 0.125e-3 s.laminaprop = (142.5e9, 8.7e9, 0.28, 5.1e9, 5.1e9, 5.1e9) s.model = 'cylshell_clpt_donnell_bardell' s.a = 2. s.b = 1. # radius s.r = 2. # compression s.Nxx = -1 # shear s.Nxy = -1 eigvals, eigvecs = lb(s.calc_kC(), s.calc_kG(), silent=True) plot_shell(s, eigvecs[:, 0], vec='w')
val = fu/(N**0.5-1) for i in ids_corner: fext[mesh.nodes[i].index*dof + 0] = val/2 for i in ids_middle: fext[mesh.nodes[i].index*dof + 0] = val print('fext.sum()', fext.sum()) d = solve(k0, fext, silent=True) # running linear buckling case vec = d[0::dof] print('u.min()', vec.min()) kG = calc_kG(d, mesh, prop_from_nodes) bc(kG) kG = coo_matrix(kG) eigvals, eigvecs = lb(k0, kG, silent=True) print('eigvals[0]', eigvals[0]) xyz = np.array([n.xyz for n in nodes]) ind = np.lexsort((xyz[:, 1], xyz[:, 0])) xyz = xyz[ind] nodes = np.array(list(nodes))[ind] pick = [n.index for n in nodes] vec = eigvecs[2::dof, 0] levels = np.linspace(vec.min(), vec.max(), 16) import matplotlib.pyplot as plt import matplotlib.cm as cm plt.figure(dpi=100, figsize=(6, 3)) nx = int(N**0.5)
def test_plate_from_zero(): # Plate geometry and laminate data a = 0.406 b = 0.254 E1 = 1.295e11 E2 = 9.37e9 nu12 = 0.38 G12 = 5.24e9 G13 = 5.24e9 G23 = 5.24e9 plyt = 1.9e-4 laminaprop = (E1, E2, nu12, G12, G13, G23) angles = [0, 45, -45, 90, 90, -45, 45, 0] # Generating Mesh # --- import numpy as np from scipy.spatial import Delaunay xs = np.linspace(0, a, 8) ys = np.linspace(0, b, 8) points = np.array(np.meshgrid(xs, ys)).T.reshape(-1, 2) tri = Delaunay(points) # Using Meshless Package # --- from scipy.sparse import coo_matrix from composites.laminate import read_stack from structsolve import solve, lb from meshless.espim.read_mesh import read_delaunay from meshless.espim.plate2d_calc_k0 import calc_k0 from meshless.espim.plate2d_calc_kG import calc_kG from meshless.espim.plate2d_add_k0s import add_k0s mesh = read_delaunay(points, tri) nodes = np.array(list(mesh.nodes.values())) prop_from_nodes = True nodes_xyz = np.array([n.xyz for n in nodes]) # **Applying properties # applying heterogeneous properties for node in nodes: lam = read_stack(angles, plyt=plyt, laminaprop=laminaprop) node.prop = lam # **Defining Boundary Conditions** # DOF = 5 def bc(K, mesh): for node in nodes[nodes_xyz[:, 0] == xs.min()]: for dof in [1, 3]: j = dof - 1 K[node.index * DOF + j, :] = 0 K[:, node.index * DOF + j] = 0 for node in nodes[(nodes_xyz[:, 1] == ys.min()) | (nodes_xyz[:, 1] == ys.max())]: for dof in [2, 3]: j = dof - 1 K[node.index * DOF + j, :] = 0 K[:, node.index * DOF + j] = 0 for node in nodes[nodes_xyz[:, 0] == xs.max()]: for dof in [3]: j = dof - 1 K[node.index * DOF + j, :] = 0 K[:, node.index * DOF + j] = 0 # **Calculating Constitutive Stiffness Matrix** k0s_method = 'cell-based' k0 = calc_k0(mesh, prop_from_nodes) add_k0s(k0, mesh, prop_from_nodes, k0s_method, alpha=0.2) bc(k0, mesh) k0 = coo_matrix(k0) # **Defining Load and External Force Vector** def define_loads(mesh): loads = [] load_nodes = nodes[(nodes_xyz[:, 0] == xs.max()) & (nodes_xyz[:, 1] != ys.min()) & (nodes_xyz[:, 1] != ys.max())] fx = -1. / (nodes[nodes_xyz[:, 0] == xs.max()].shape[0] - 1) for node in load_nodes: loads.append([node, (fx, 0, 0)]) load_nodes = nodes[(nodes_xyz[:, 0] == xs.max()) & ( (nodes_xyz[:, 1] == ys.min()) | (nodes_xyz[:, 1] == ys.max()))] fx = -1. / (nodes[nodes_xyz[:, 0] == xs.max()].shape[0] - 1) / 2 for node in load_nodes: loads.append([node, (fx, 0, 0)]) return loads n = k0.shape[0] // DOF fext = np.zeros(n * DOF, dtype=np.float64) loads = define_loads(mesh) for node, force_xyz in loads: fext[node.index * DOF + 0] = force_xyz[0] print('Checking sum of forces: %s' % str(fext.reshape(-1, DOF).sum(axis=0))) # **Running Static Analysis** d = solve(k0, fext, silent=True) total_trans = (d[0::DOF]**2 + d[1::DOF]**2)**0.5 print('Max total translation', total_trans.max()) # **Calculating Geometric Stiffness Matrix** kG = calc_kG(d, mesh, prop_from_nodes) bc(kG, mesh) kG = coo_matrix(kG) # **Running Linear Buckling Analysis** eigvals, eigvecs = lb(k0, kG, silent=True) print('First 5 eigenvalues') print('\n'.join(map(str, eigvals[:5]))) assert np.allclose(eigvals[:5], [ 1004.29332981, 1822.11577078, 2898.3728806, 2947.17499169, 3297.54959342, ])