コード例 #1
0
def ke_cbar(model: BDF, elem: CBAR, fdtype: str = 'float64'):
    """get the elemental stiffness matrix in the basic frame"""
    pid_ref = elem.pid_ref
    mat = pid_ref.mid_ref

    #is_passed, (wa, wb, ihat, jhat, khat) = elem.get_axes(model)
    #T = np.vstack([ihat, jhat, khat])
    #z = np.zeros((3, 3), dtype='float64')
    prop = elem.pid_ref
    mat = prop.mid_ref
    I1 = prop.I11()
    I2 = prop.I22()
    unused_I12 = prop.I12()
    pa = elem.pa
    pb = elem.pb
    #J = prop.J()
    #E = mat.E()
    #G = mat.G()
    z = np.zeros((3, 3), dtype='float64')
    T = z
    #unused_Teb = np.block([
    #[T, z],
    #[z, T],
    #])
    is_failed, (wa, wb, ihat, jhat, khat) = elem.get_axes(model)
    assert is_failed is False
    #print(wa, wb)
    xyz1 = elem.nodes_ref[0].get_position() + wa
    xyz2 = elem.nodes_ref[1].get_position() + wb
    dxyz = xyz2 - xyz1
    L = np.linalg.norm(dxyz)
    pid_ref = elem.pid_ref
    mat = pid_ref.mid_ref
    T = np.vstack([ihat, jhat, khat])
    z = np.zeros((3, 3), dtype=fdtype)
    Teb = np.block([
        [T, z, z, z],
        [z, T, z, z],
        [z, z, T, z],
        [z, z, z, T],
    ])
    k1 = pid_ref.k1
    k2 = pid_ref.k2
    Ke = _beami_stiffness(pid_ref, mat, L, I1, I2, k1=k1, k2=k2, pa=pa, pb=pb)
    K = Teb.T @ Ke @ Teb
    is_passed = not is_failed
    return is_passed, K
コード例 #2
0
    def test_pbarl_1(self):
        """tests the PBARL"""
        model = BDF(log=None, debug=False)
        pid = 4
        mid = 40
        group = 'group'
        Type = 'bad_type'
        dim = 42
        nsm = 0.5
        pbarl = PBARL(pid,
                      mid,
                      Type,
                      dim,
                      group=group,
                      nsm=nsm,
                      comment='comment')
        with self.assertRaises(ValueError):  # Type
            pbarl.validate()

        pbarl.Type = 'TUBE'
        with self.assertRaises(TypeError):  # dim
            pbarl.validate()

        pbarl.dim = [20.]
        with self.assertRaises(RuntimeError):
            pbarl.validate()

        pbarl.dim = [2., 1.]
        #with self.assertRaises(ValueError):
        #pbarl.validate()
        #pbarl.group = 'MSCBMLO'

        pbarl.validate()
        str(pbarl)
        pbarl.write_card(size=8, is_double=False)
        pbarl.write_card(size=16, is_double=False)
        pbarl.write_card(size=16, is_double=True)
        model.properties[pid] = pbarl

        nid1 = 52
        xyz1 = [0., 0., 0.]
        model.nodes[nid1] = GRID(nid1, cp=0, xyz=xyz1)

        nid2 = 53
        xyz2 = [1., 0., 0.]
        model.nodes[nid2] = GRID(nid2, cp=0, xyz=xyz2)

        E = 30.0e7
        G = None
        nu = 0.3
        mat = MAT1(mid, E, G, nu, rho=1.0)
        model.materials[mid] = mat

        eid = 42
        x = None
        g0 = None
        cbar = CBAR(eid,
                    pid, [nid1, nid2],
                    x,
                    g0,
                    offt='GGG',
                    pa=0,
                    pb=0,
                    wa=None,
                    wb=None,
                    comment='')
        cbar.validate()
        model.elements[eid] = cbar
        pbarl._verify(xref=False)

        model.validate()
        model.cross_reference()
        pbarl._verify(xref=True)
        assert allclose(cbar.Mass(), 9.9247779608), cbar.Mass()

        mat.rho = 0.
        assert allclose(cbar.Mass(), 0.5), cbar.Mass()
コード例 #3
0
def _recover_forcei_cbar(model: BDF,
                         xb,
                         dof_map,
                         elem: CBAR,
                         prop: Union[PBAR, PBARL],
                         fdtype: str = 'float64'):
    """get the static CBAR force"""
    #words = ['                                 F O R C E S   I N   B A R   E L E M E N T S         ( C B A R )\n',
    #'0    ELEMENT         BEND-MOMENT END-A            BEND-MOMENT END-B                - SHEAR -               AXIAL\n',
    #'       ID.         PLANE 1       PLANE 2        PLANE 1       PLANE 2        PLANE 1       PLANE 2         FORCE         TORQUE\n']
    nid1, nid2 = elem.nodes
    prop = elem.pid_ref
    mat = prop.mid_ref

    i1 = dof_map[(nid1, 1)]
    i2 = dof_map[(nid2, 1)]

    q_all = np.hstack([
        xb[i1:i1 + 6],
        xb[i2:i2 + 6],
    ])
    #q_axial = np.array([
    #xb[i1], xb[i1+1], xb[i1+2],
    #xb[i2], xb[i2+1], xb[i2+2]
    #])
    #q_torsion = np.array([
    #xb[i1+3], xb[i1+4], xb[i1+5],
    #xb[i2+3], xb[i2+4], xb[i2+5]
    #])

    #u_axial = Lambda @ q_axial
    #u_torsion = Lambda @ q_torsion

    nid1, nid2 = elem.nodes
    is_passed, Ke = ke_cbar(model, elem, fdtype=fdtype)
    assert is_passed

    #pid_ref = elem.pid_ref
    #mat = pid_ref.mid_ref

    # ------------------
    is_failed, (wa, wb, ihat, jhat, khat) = elem.get_axes(model)
    assert is_failed is False
    #print(wa, wb)
    #xyz1 = elem.nodes_ref[0].get_position() + wa
    #xyz2 = elem.nodes_ref[1].get_position() + wb
    #dxyz = xyz2 - xyz1
    #L = np.linalg.norm(dxyz)
    #pid_ref = elem.pid_ref
    #mat = pid_ref.mid_ref
    T = np.vstack([ihat, jhat, khat])
    z = np.zeros((3, 3), dtype=fdtype)
    Teb = np.block([
        [T, z, z, z],
        [z, T, z, z],
        [z, z, T, z],
        [z, z, z, T],
    ])  # 12x12
    q_element = Teb @ q_all
    u_e = q_element.reshape(12, 1)
    Fe = Ke @ q_element

    # ---------------------------------
    f_e = Fe
    #c, d, e, f = prop.get_cdef()
    #C1, C2 = c
    #D1, D2 = d
    #E1, E2 = e
    #F1, F2 = f
    C1, C2, D1, D2, E1, E2, F1, F2 = prop.get_cdef().ravel()
    A = prop.A
    E = mat.E()
    I1 = prop.I11()
    I2 = prop.I22()

    #f_e = obj.k_e * u_e
    force2stress = np.array([
        [1 / A, 0, 0, 0, C2 / I2, -C1 / I1],
        [1 / A, 0, 0, 0, D2 / I2, -D1 / I1],
        [1 / A, 0, 0, 0, E2 / I2, -E1 / I1],
        [1 / A, 0, 0, 0, F2 / I2, -F1 / I1],
    ])

    #print(force2stress.shape)
    #print(f_e.shape)
    stress = np.hstack([
        -force2stress @ f_e[:6],
        force2stress @ f_e[6:],
    ])
    #print(E, stress)

    # [End A Long. Stress or Strain at Point C;
    #  End A Long. Stress or Strain at Point D;
    #  End A Long. Stress or Strain at Point E;
    #  End A Long. Stress or Strain at Point F;
    #  End B Long. Stress or Strain at Point C;
    #  End B Long. Stress or Strain at Point D;
    #  End B Long. Stress or Strain at Point E;
    #  End B Long. Stress or Strain at Point F]
    strain = 1 / E * stress

    strain_energy = 0.5 * np.diag(u_e.T @ f_e).T
    #print('strain_energy =', strain_energy)
    # ---------------------------------
    #k1 = pid_ref.k1
    #k2 = pid_ref.k2
    #Ke = _beami_stiffness(pid_ref, mat, L, I1, I2, k1=k1, k2=k2, pa=pa, pb=pb)
    #K = Teb.T @ Ke @ Teb

    #is_passed, (wa, wb, ihat, jhat, khat) = elem.get_axes(model)
    #T = np.vstack([ihat, jhat, khat])
    #z = np.zeros((3, 3), dtype='float64')
    #I1 = prop.I11()
    #I2 = prop.I22()
    #A = prop.Area()
    #J = prop.J()
    #unused_I12 = prop.I12()

    (Fx1, Fy1, Fz1, Mx1, My1, Mz1, Fx2, Fy2, Fz2, Mx2, My2, Mz2) = Fe

    axial = Fx1
    torque = Mx1
    shear1 = Fy1
    shear2 = Fz1
    bending_moment_a1 = My1
    bending_moment_a2 = Mz1

    bending_moment_b1 = My2
    bending_moment_b2 = Mz2

    out = (bending_moment_a1, bending_moment_a2, bending_moment_b1,
           bending_moment_b2, shear1, shear2, axial, torque)
    return out