Esempio n. 1
0
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])
Esempio n. 2
0
def test_calc_linear_static():
    mesh = read_mesh(os.path.join(THISDIR, 'nastran_plate_16_nodes.dat'))
    E11 = 71.e9
    nu = 0.33
    plyt = 0.007
    lam = read_stack([0], plyt=plyt, laminaprop=(E11, E11, nu))
    for tria in mesh.elements.values():
        tria.prop = lam
    for node in mesh.nodes.values():
        node.prop = lam
    for prop_from_nodes in [False, True]:
        for k0s_method in ['cell-based', 'cell-based-no-smoothing']: #, 'edge-based'
            k0 = calc_k0(mesh, prop_from_nodes)
            add_k0s(k0, mesh, prop_from_nodes, k0s_method, alpha=0.2)

            k0run = k0.copy()

            dof = 5
            n = k0.shape[0] // dof
            fext = np.zeros(n*dof, dtype=np.float64)
            fext[mesh.nodes[4].index*dof + 2] = 500.
            fext[mesh.nodes[7].index*dof + 2] = 500.
            fext[mesh.nodes[5].index*dof + 2] = 1000.
            fext[mesh.nodes[6].index*dof + 2] = 1000.
            i, j = np.indices(k0run.shape)

            # boundary conditions
            for nid in [1, 10, 11, 12]:
                for j in [0, 1, 2, 3]:
                    k0run[mesh.nodes[nid].index*dof+j, :] = 0
                    k0run[:, mesh.nodes[nid].index*dof+j] = 0

            k0run = coo_matrix(k0run)
            u = solve(k0run, fext, silent=True)
            ans = np.loadtxt(os.path.join(THISDIR, 'nastran_plate_16_nodes.result.txt'),
                    dtype=float)
            xyz = np.array([n.xyz for n in mesh.nodes.values()])
            ind = np.lexsort((xyz[:, 1], xyz[:, 0]))
            xyz = xyz[ind]
            nodes = np.array(list(mesh.nodes.values()))[ind]
            pick = [n.index for n in nodes]
            assert np.allclose(u[2::5][pick].reshape(4, 4).T, ans, rtol=0.05)
from meshless.espim.read_mesh import read_mesh
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

THISDIR = os.path.dirname(inspect.getfile(inspect.currentframe()))

E11 = 71.e9
nu = 0.33
plyt = 0.007
laminaprop = (E11, E11, nu)
lam = read_stack([0], plyt=plyt, laminaprop=laminaprop, calc_scf=True)
prop_from_nodes = False
k0s_method = 'cell-based'
mesh = read_mesh(os.path.join(THISDIR, 'nastran_test.dat'))

nodes = mesh.nodes.values()
for tria in mesh.elements.values():
    tria.prop = lam
for node in nodes:
    node.prop = lam
k0 = calc_k0(mesh, prop_from_nodes)
add_k0s(k0, mesh, prop_from_nodes, k0s_method)

dof = 5
N = k0.shape[0] // 5

# boundary conditions
def bc(K):
    ids = [n.nid for n in nodes if np.isclose(n.xyz[0], 0.)]
Esempio n. 4
0
def test_read_mesh():
    mesh = read_mesh(os.path.join(THISDIR, 'nastran_plate_16_nodes.dat'))
    assert len(mesh.nodes) == 16
    assert len(mesh.elements) == 18
    assert len(mesh.edges) == 33