def main():
    np.set_printoptions(linewidth=300, precision=2)

    # Read ED file
    edFilename = os.path.join(MyDir,
                              './../../../data/NREL5MW/data/NREL5MW_ED.dat')
    ed = weio.FASTInputFile(edFilename)
    TowerHt = ed['TowerHt']
    TowerBsHt = ed['TowerBsHt']
    twrFilename = os.path.join(os.path.dirname(edFilename),
                               ed['TwrFile'].replace('"', ''))
    # Read twr file
    twr = weio.FASTInputFile(twrFilename).toDataFrame()
    z = twr['HtFract_[-]'] * (TowerHt - TowerBsHt)
    m = twr['TMassDen_[kg/m]']
    nSpan = len(z)
    PhiU = np.zeros((4, 3, nSpan))  # Shape functions
    PhiU[0][0, :] = twr['ShapeForeAft1_[-]']  # along x
    PhiU[1][0, :] = twr['ShapeForeAft2_[-]']  # along x
    PhiU[2][1, :] = twr['ShapeSideSide1_[-]']  # along y
    PhiU[3][1, :] = twr['ShapeSideSide2_[-]']  # along y
    s_G = np.zeros((3, nSpan))  # COG location
    s_G[2, :] = z
    jxxG = z * 0 + m  # NOTE: unknown
    MM, Gr, Ge, Oe, Oe6 = GMBeam(s_G,
                                 z,
                                 m,
                                 PhiU,
                                 jxxG=jxxG,
                                 bUseIW=True,
                                 main_axis='z',
                                 split_outputs=False,
                                 rot_terms=True)

    print(MM)
    print('Gr')
    print(Gr)
    print('Ge')
    print(Ge)
    print('Oe')
    print(Oe)
    print('Oe6')
    print(Oe6)
示例#2
0
    def test_inertia(self):
        np.set_printoptions(linewidth=300, precision=2)
        # read ElastoDyn file
        edFile=os.path.join(MyDir,'./../../../data/NREL5MW/data/NREL5MW_ED.dat')
        ED = weio.FASTInputFile(edFile)

        #def __init__(self, name, mass, J, s_OG, R_b2g=np.eye(3), s_OP=None, r_O=[0,0,0]):
        theta_tilt_y = -ED['ShftTilt']*np.pi/180  # NOTE: tilt has wrong orientation in FAST
        R_NS = R_y(theta_tilt_y)
        r_NS_inN    = np.array([0             , 0, ED['Twr2Shft']]) # Shaft start in N
        r_SR_inS    = np.array([ED['OverHang'], 0, 0             ]) # Rotor center in S
        r_SGhub_inS = np.array([ED['HubCM']   , 0, 0             ]) + r_SR_inS # Hub G in S
        r_NR_inN    = r_NS_inN + R_NS.dot(r_SR_inS)                 # Rotor center in N
        r_NGnac_inN = np.array([ED['NacCMxn'],0,ED['NacCMzn']    ]) # Nacelle G in N
        r_RGhub_inS = - r_SR_inS + r_SGhub_inS

        # --- Hub 
        M_hub  = ED['HubMass']
        JxxHub_atR = ED['HubIner'] #+ ED['GenIner']*ED['GBRatio']**2 
        hub = RigidBody('Hub', M_hub, (JxxHub_atR,0,0), s_OG=r_SGhub_inS, R_b2g=R_NS, s_OP=r_SR_inS, r_O=r_NS_inN) 
        #print(hub)

        # --- Generator 
        gen = RigidBody('Gen', 0, (ED['GenIner']*ED['GBRatio']**2,0,0), s_OG=[0,0,0], R_b2g=R_NS,  r_O=r_NS_inN) 
        #print(gen)

        # --- Nacelle 
#         M_nac = ED['NacMass']
#         JyyNac_atN = ED['NacYIner'] # Inertia of nacelle at N in N
#         nac = RigidBody('Nac', M_nac, (0,JyyNac_atN,0), r_NGnac_inN, s_OP=[0,0,0])
#         print(nac)

        # Blades 
        # TODO reconsider hubrad there
        psi=0
        bld1 = RigidBody('Bld1', 1.684475202e+04, (1.225603507e+07, 1.225603507e+07, 1.684475202e+04), s_OG=[0,0,22.00726], s_OP=[0,0,0], R_b2g=R_x(psi+ 0        ).dot(R_y(ED['PreCone(1)']*np.pi/180))  )
        bld2 = RigidBody('Bld2', 1.684475202e+04, (1.225603507e+07, 1.225603507e+07, 1.684475202e+04), s_OG=[0,0,22.00726], s_OP=[0,0,0], R_b2g=R_x(psi+ 2*np.pi/3).dot(R_y(ED['PreCone(2)']*np.pi/180))  )
        bld3 = RigidBody('Bld3', 1.684475202e+04, (1.225603507e+07, 1.225603507e+07, 1.684475202e+04), s_OG=[0,0,22.00726], s_OP=[0,0,0], R_b2g=R_x(psi+ 4*np.pi/3).dot(R_y(ED['PreCone(3)']*np.pi/180))  )
        #print(bld1)
        #print('Blade mass matrix\n',np.around(bld1.mass_matrix,5))
        blades = bld1.combine(bld2).combine(bld3, name='Blades')
        #print(blades)
        # 
        blades.pos_global = r_NR_inN # Setting origin w.r.t. N
        blades.R_b2g      = R_NS     # Setting frame w.r.t. N, as rotated
        #print(blades)

        # --- Rotor = Hub + Blades
        hubgen= hub.combine(gen, R_b2g=R_NS, r_O=hub.pos_global)
        rotor = blades.combine(hubgen, R_b2g=R_NS, r_O=hub.pos_global)
        #print(rotor)

        rotor = blades.combine(hub).combine(gen, r_O=r_NS_inN, R_b2g=R_NS)
        #print(rotor)
        rotor = blades.combine(hub, r_O=r_NS_inN, R_b2g=R_NS)
示例#3
0
    def test_beam_linear_element(self):
        np.set_printoptions(linewidth=300, precision=9)
        # --- Read data from NREL5MW tower
        TowerHt = 87.6
        TowerBs = 0
        TwrFile = os.path.join(
            MyDir, './../../../data/NREL5MW/data/NREL5MW_ED_Tower_Onshore.dat')
        twr = weio.FASTInputFile(TwrFile).toDataFrame()
        z = twr['HtFract_[-]'] * (TowerHt - TowerBs)
        m = twr['TMassDen_[kg/m]']  # mu
        EIy = twr['TwFAStif_[Nm^2]']
        EIz = twr['TwSSStif_[Nm^2]']  # TODO actually EIx

        # --- Create Beam FEM model
        # Derived parameters
        A = m * 0 + 100  # Area
        Kv = m * 0 + 100  # Saint Venant torsion
        E = 214e9  # Young modulus  [N/m^2]
        Iy = EIy / E  # Area moment [m^4]
        Iz = EIz / E  # Area moment [m^4]
        nNodes = len(z)
        nElem = nNodes - 1
        nqe = 12  # Number of DOF per element
        nqk = int(nqe / 2)  # Number of DOF per nodes
        nDOF_tot = nNodes * nqk  # Total number of DOF without constraint (BC)
        nDOF = nDOF_tot - nqk  # Total number of DOF with constraint (BC) applied

        # Nodes positions
        xNodes = np.zeros((3, nNodes))
        xNodes[2, :] = z

        MM, KK, DCM, Elem2Nodes, Nodes2DOF, Elem2DOF = cbeam_frame3dlin(xNodes,
                                                                        m,
                                                                        Iy,
                                                                        Iz=Iz,
                                                                        A=A,
                                                                        Kv=Kv,
                                                                        E=E)

        np.testing.assert_almost_equal(MM[0, 0], 17921.9563543, 5)
        np.testing.assert_almost_equal(MM[-1, -1], 7590.2188, 5)
        np.testing.assert_almost_equal(MM[11, 11], 30565.98330, 5)
        np.testing.assert_almost_equal(MM[20, 20], 26585.67290, 5)
        np.testing.assert_almost_equal(KK[7, 7] / 1e10, 1.91655, 5)
        np.testing.assert_almost_equal(KK[10, 10] / 1e11, 4.893305, 5)
        np.testing.assert_almost_equal(KK[11, 11] / 1e12, 1.87917, 5)

        # --- Constraints/ BC
        MMr, KKr, Tr = applyBC(MM,
                               KK,
                               Elem2Nodes,
                               Nodes2DOF,
                               BC_root=[0, 0, 0, 0, 0, 0],
                               BC_tip=[1, 1, 1, 1, 1, 1])
        iStart = 0

        # --- Eigenvalues/vectors
        [Q, freq] = eig(KKr, MMr, freq_out=True)

        # --- Orthogonalization/ normalization of modes
        Imodes = [0, 1]
        Q[:, 0], Q[:, 1] = orthogonalizeModePair(Q[:, 0], Q[:, 1], iStart)
        Q = normalize_to_last(Q, Imodes, iStart)

        np.testing.assert_almost_equal(freq[0], 0.891449, 5)
        np.testing.assert_almost_equal(freq[1], 0.891449, 5)
        np.testing.assert_almost_equal(freq[-1], 5250.756553, 5)

        # --- Export Modes
        #U1 = np.concatenate(([0],Q[0::6,0] )) # along x
        #V1 = np.concatenate(([0],Q[4::6,0] )) # theta y
        #U2 = np.concatenate(([0],Q[1::6,1] )) # along y
        #V2 = np.concatenate(([0],Q[3::6,1] )) # theta x
        #M=np.column_stack([z,U1,V2,U2,V2])
        # np.savetxt('out.csv',M)

        # --- Generalized mass matrix
        # Selecting modes
        if len(Imodes) > 0:
            Se = Tr.dot(Q[:, Imodes])  # nDOF_tot x nShapes
        else:
            Se = Tr  # All

        Mtt, J0, Mrt, Mgt, Mgr, Mgg, St, Sr = generalizedMassMatrix(
            xNodes, MM, Se)

        Ct0_ = (Tr.T).dot(MM).dot(St)  # Mode mass matrix for all modes

        np.testing.assert_almost_equal(np.diag(Mtt), [347460.2316] * 3, 5)
        np.testing.assert_almost_equal(np.diag(Mgg), [61094.66490] * 2, 5)
        np.testing.assert_almost_equal(
            np.diag(J0) / 1e8,
            np.array([7.198598843e8] * 2 + [3.474602316e5]) / 1e8, 5)
        np.testing.assert_almost_equal(Mrt[0, 1], -13265404.838207997,
                                       5)  # -m*zCOG
        np.testing.assert_almost_equal(Mgt[0, 0], 104625.69072, 5)  # -m*zCOG
        np.testing.assert_almost_equal(Mgt[1, 1], 104625.69072, 5)  # -m*zCOG
        np.testing.assert_almost_equal(Mgr[0, 1], 6449889.716099, 5)  # -m*zCOG
        np.testing.assert_almost_equal(Mgr[1, 0], -6449889.716099,
                                       5)  # -m*zCOG

        # --- Shape integrals
        C3, Kr, C4, KFom_ab, Kom, Kom0, Kom0_ = shapeIntegrals(
            xNodes, Nodes2DOF, Elem2Nodes, Elem2DOF, DCM, m, Se, Sr, Tr)

        # --- C3 mass matrix             3  3 12 12 ie
        np.testing.assert_almost_equal(C3[0, 0, 0, 0, 0], 16063.6792,
                                       5)  # -m*zCOG
        np.testing.assert_almost_equal(C3[0, 0, 0, 6, 0], 7901.009,
                                       5)  # -m*zCOG
        np.testing.assert_almost_equal(C3[1, 1, 1, 1, 0], 17921.95635,
                                       5)  # -m*zCOG
        np.testing.assert_almost_equal(C3[1, 1, 5, 1, 0], 22014.56673,
                                       5)  # -m*zCOG
        np.testing.assert_almost_equal(C3[2, 2, 2, 2, 0], 17921.95635,
                                       5)  # -m*zCOG
        np.testing.assert_almost_equal(C3[2, 2, 10, 10, 0], 34359.12315,
                                       5)  # -m*zCOG
        # --- Term for second order Cr (Mgr) terms and Oe
        np.testing.assert_almost_equal(Kr[2, 0, 1], -61094.66491, 5)
        np.testing.assert_almost_equal(Kr[2, 1, 0], 61094.66491, 5)
        # --- Terms useful for 0th order of Gr, and 1st order of J
        np.testing.assert_almost_equal(C4[0, 2, 0], 6449889.7161, 4)
        np.testing.assert_almost_equal(C4[1, 2, 1], 6449889.7161, 4)
        # --- Omega terms
        np.testing.assert_almost_equal(KFom_ab[0, 0][1, 1], -17921.956354, 5)
        np.testing.assert_almost_equal(KFom_ab[0, 0][3, 1], 22014.566733, 5)
        np.testing.assert_almost_equal(KFom_ab[0, 0][7, 1], -6095.064086, 5)
        np.testing.assert_almost_equal(KFom_ab[0, 0][6, 6], 0.0, 5)
        np.testing.assert_almost_equal(KFom_ab[2, 2][0, 0], -17921.956354, 5)
        np.testing.assert_almost_equal(KFom_ab[2, 2][4, 0], -22014.566733, 5)
        np.testing.assert_almost_equal(KFom_ab[2, 2][6, 0], -6095.064086, 5)
        np.testing.assert_almost_equal(Kom[0][1, 1], -61094.664906, 5)
        np.testing.assert_almost_equal(Kom[1][0, 0], -61094.664906, 5)
        np.testing.assert_almost_equal(Kom[2][0, 0], -61094.664906, 5)
        np.testing.assert_almost_equal(Kom[3][0, 1], 61094.664906, 5)
        np.testing.assert_almost_equal(Kom[4][0, 0], 0, 5)
        np.testing.assert_almost_equal(Kom[5][0, 0], 0, 5)

        # --- Stiffening terms
        Kinv = Tr.dot(inv(KKr)).dot(Tr.T)
        GKg = geometricalStiffening(xNodes, Kinv, Tr, Se, Nodes2DOF,
                                    Elem2Nodes, Elem2DOF, DCM, E, A, Kom0_,
                                    Ct0_)

        np.testing.assert_almost_equal(GKg['omxx'][0, 0], 77201.43393, 5)
        np.testing.assert_almost_equal(GKg['omyy'][0, 0], 77201.43393, 5)
        np.testing.assert_almost_equal(GKg['omzz'][0, 0], 0, 5)
        np.testing.assert_almost_equal(GKg['omyz'][0, 0], 0, 5)

        # --- Convert to SID
        sid = FEMBeam2SID(Mtt, J0, Mrt, Mgt, Mgr, Mgg, KK, xNodes, DCM, Se, Kr,
                          Kom0, Kom, C4, GKg)

        #print(sid)
        with open('_OUT_SID_PY.txt', 'w') as f:
            f.write(str(sid).replace('-0.000000', ' 0.000000'))
示例#4
0
def OpenFASTIsolatedTower():
    # --- Read data from NREL5MW tower
    TowerHt = 87.6
    TowerBs = 0
    TwrFile = os.path.join(
        MyDir, './../../../data/NREL5MW/data/NREL5MW_ED_Tower_Onshore.dat')
    twr = weio.FASTInputFile(TwrFile).toDataFrame()
    z = twr['HtFract_[-]'] * (TowerHt - TowerBs)
    m = twr['TMassDen_[kg/m]']  # mu
    EIy = twr['TwFAStif_[Nm^2]']
    EIz = twr['TwSSStif_[Nm^2]']  # TODO actually EIx

    # --- Create Beam FEM model
    # Derived parameters
    A = m * 0 + 100  # Area
    Kv = m * 0 + 100  # Saint Venant torsion
    E = 214e9  # Young modulus  [N/m^2]
    Iy = EIy / E  # Area moment [m^4]
    Iz = EIz / E  # Area moment [m^4]
    nNodes = len(z)
    nElem = nNodes - 1

    # Nodes positions
    xNodes = np.zeros((3, nNodes))
    xNodes[2, :] = z

    # Assembly
    MM, KK, xNodes, DCM, Elem2Nodes, Nodes2DOF, Elem2DOF = cbeam_assembly_frame3dlin(
        xNodes, m, Iy, Iz=Iz, A=A, Kv=Kv, E=E)

    # --- Constraints/ BC
    MMr, KKr, Tr, _, _ = applyBC(MM,
                                 KK,
                                 Elem2Nodes,
                                 Nodes2DOF,
                                 BC_root=[0, 0, 0, 0, 0, 0],
                                 BC_tip=[1, 1, 1, 1, 1, 1])
    iStart = 0

    # --- Eigenvalues/vectors
    [Q, freq] = eig(KKr, MMr, freq_out=True)

    # --- Orthogonalization/ normalization of modes
    Imodes = [0, 1]
    #Q[:,0],Q[:,1] = orthogonalizeModePair(Q[:,0],Q[:,1], iStart)
    #Q= normalize_to_last(Q, Imodes, iStart);

    # --- Export Modes
    U1 = np.concatenate(([0], Q[0::6, 0]))  # Deflection mode 1, along x
    V1 = np.concatenate(([0], Q[4::6, 0]))  # Slope mode 1 , theta y
    U2 = np.concatenate(([0], Q[1::6, 1]))  # Deflection mode 2, along y
    V2 = np.concatenate(([0], Q[3::6, 1]))  # Slope mode 2, theta x
    #print(U1)
    #print(U2)
    #print(Q[:,0])
    #print(Q[:,1])
    #print(Q[:,2])
    #print(Q[:,3])
    #M=np.column_stack([z,U1,V2,U2,V2])
    # np.savetxt('out.csv',M)

    # --- Generalized mass matrix
    # Selecting modes
    Imodes = [0, 1]
    if len(Imodes) > 0:
        Se = Tr.dot(Q[:, Imodes])  # nDOF_tot x nShapes
    else:
        Se = Tr  # All
    Mtt, J0, Mrt, Mgt, Mgr, Mgg, St, Sr = generalizedMassMatrix(xNodes, MM, Se)

    #fig,ax = plt.subplots(1, 1, sharey=False, figsize=(6.4,4.8)) # (6.4,4.8)
    #fig.subplots_adjust(left=0.12, right=0.95, top=0.95, bottom=0.11, hspace=0.20, wspace=0.20)
    #   #  ax.plot(z, U1    , label='Mode 1')
    #ax.plot(z, U2    , label='Mode 2')
    #ax.set_xlabel('')
    #ax.set_ylabel('')
    #ax.legend()

    return MM, KK, Q, freq
示例#5
0
    def test_BladeBeam_SID(self):
        """ 
        In this test we use:
        - Beam properties from the Blade of the NREL5MW
        - Shape functions determined using a FEM beam representation (see welib/yams/tests/test_sid.py)
        - We test for the gyroscopic and centrifugal matrix Gr, Ge, Oe
        - Beam along z axis
        
        """
        np.set_printoptions(linewidth=300, precision=9)

        # --- Read data from NREL5MW Blade
        edFile = os.path.join(MyDir,
                              './../../../data/NREL5MW/data/NREL5MW_ED.dat')
        parentDir = os.path.dirname(edFile)
        ed = weio.FASTInputFile(edFile)
        TipRad = ed['TipRad']
        HubRad = ed['HubRad']
        BldLen = TipRad - HubRad
        BldFile = ed['BldFile(1)'].replace('"', '')
        BldFile = os.path.join(parentDir, BldFile)
        bld = weio.FASTInputFile(BldFile).toDataFrame()
        z = bld['BlFract_[-]'] * BldLen + HubRad
        m = bld['BMassDen_[kg/m]']
        nSpan = len(z)

        # --- Shape function taken from FEM
        shapeFile = os.path.join(
            MyDir, '../../../data/NREL5MW/NREL5MW_Blade_FEM_Modes.csv')
        shapes = weio.read(shapeFile).toDataFrame()
        nShapes = 2
        PhiU = np.zeros((nShapes, 3, nSpan))  # Shape
        s_G = np.zeros((3, nSpan))
        main_axis = 'z'
        if main_axis == 'z':
            # Mode 1
            PhiU[0, 0, :] = shapes['U1x']
            PhiU[0, 1, :] = shapes['U1y']
            # Mode 2
            PhiU[1, 0, :] = shapes['U2x']
            PhiU[1, 1, :] = shapes['U2y']
            s_G[2, :] = z

        # --- Testing for straight COG
        s_span = z
        jxxG = z * 0 + m  # NOTE: unknown
        MM, Gr, Ge, Oe, Oe6 = GMBeam(s_G,
                                     s_span,
                                     m,
                                     PhiU,
                                     jxxG=jxxG,
                                     bUseIW=True,
                                     main_axis=main_axis,
                                     split_outputs=False,
                                     rot_terms=True)

        MM_ref = np.array(
            [[
                1.684475202e+04, 0.000000000e+00, 0.000000000e+00,
                0.000000000e+00, 3.707069074e+05, -0.000000000e+00,
                1.976263092e+03, -6.366476591e+00
            ],
             [
                 0.000000000e+00, 1.684475202e+04, 0.000000000e+00,
                 -3.707069074e+05, 0.000000000e+00, 0.000000000e+00,
                 4.082717323e+00, 2.915664880e+03
             ],
             [
                 0.000000000e+00, 0.000000000e+00, 1.684475202e+04,
                 0.000000000e+00, -0.000000000e+00, 0.000000000e+00,
                 0.000000000e+00, 0.000000000e+00
             ],
             [
                 0.000000000e+00, -3.707069074e+05, 0.000000000e+00,
                 1.225603507e+07, -0.000000000e+00, -0.000000000e+00,
                 -1.817970390e+02, -1.200295386e+05
             ],
             [
                 3.707069074e+05, 0.000000000e+00, -0.000000000e+00,
                 -0.000000000e+00, 1.225603507e+07, -0.000000000e+00,
                 8.737268222e+04, -2.574073558e+02
             ],
             [
                 -0.000000000e+00, 0.000000000e+00, 0.000000000e+00,
                 -0.000000000e+00, -0.000000000e+00, 1.684475202e+04,
                 0.000000000e+00, 0.000000000e+00
             ],
             [
                 1.976263092e+03, 4.082717323e+00, 0.000000000e+00,
                 -1.817970390e+02, 8.737268222e+04, 0.000000000e+00,
                 8.364646779e+02, -9.586291225e-04
             ],
             [
                 -6.366476591e+00, 2.915664880e+03, 0.000000000e+00,
                 -1.200295386e+05, -2.574073558e+02, 0.000000000e+00,
                 -9.586291225e-04, 1.351321852e+03
             ]])

        np.testing.assert_allclose(MM[0:3, 0:3], MM_ref[0:3, 0:3], rtol=1e-4)
        np.testing.assert_allclose(MM[0:3, 3:6], MM_ref[0:3, 3:6], rtol=1e-4)
        np.testing.assert_allclose(MM[0:3, 6:], MM_ref[0:3, 6::], rtol=1e-4)
        np.testing.assert_allclose(MM[3:6, 3:6], MM_ref[3:6, 3:6], rtol=1e-4)
        np.testing.assert_allclose(MM[3:6, 6:], MM_ref[3:6, 6:], rtol=1e-4)
        np.testing.assert_allclose(MM[6::, 6::], MM_ref[6:, 6:], rtol=1e-4)
        np.testing.assert_allclose(MM, MM.T, rtol=1e-4)

        np.testing.assert_allclose(Gr[0][0, :], [0, 0, -174817], rtol=1e-5)
        np.testing.assert_allclose(Gr[0][1, :], [0, 0, -363.7477], rtol=1e-5)
        np.testing.assert_allclose(Gr[1][0, :], [0, 0, 514.944], rtol=1e-5)
        np.testing.assert_allclose(Gr[1][1, :], [0, 0, -240127], rtol=1e-5)

        np.testing.assert_allclose(Ge[0][1, :], [0, 0, 2087.767], rtol=1e-5)
        np.testing.assert_allclose(Ge[1][0, :], [0, 0, -2087.767], rtol=1e-5)
        np.testing.assert_allclose(Oe6[0][:], [0, 0, 0, 0, 181.8739, 87408.6],
                                   rtol=1e-5)
        np.testing.assert_allclose(Oe6[1][:], [0, 0, 0, 0, 120063, -257.472],
                                   rtol=1e-5)
示例#6
0
    def test_TowerBeam_SID(self):
        """ 
        In this test we use:
        - Beam properties from the Tower of the NREL5MW
        - Shape functions determined using a FEM beam representation (see welib/FEM/tests/test_beam_linear_element.py)
        - We test for the gyroscopic and centrifugal matrix Gr, Ge, Oe
        - Beam along z axis
        
        """
        np.set_printoptions(linewidth=300, precision=9)
        # --- Read data from NREL5MW tower
        TowerHt = 87.6
        TowerBs = 0
        TwrFile = os.path.join(
            MyDir, './../../../data/NREL5MW/data/NREL5MW_ED_Tower_Onshore.dat')
        twr = weio.FASTInputFile(TwrFile).toDataFrame()
        z = twr['HtFract_[-]'] * (TowerHt - TowerBs)
        m = twr['TMassDen_[kg/m]']
        nSpan = len(z)

        # --- Shape function taken from FEM
        shapeFile = os.path.join(
            MyDir, '../../../data/NREL5MW/NREL5MW_Tower_Onshore_FEM_Modes.csv')
        shapes = weio.read(shapeFile).toDataFrame()
        nShapes = 2
        PhiU = np.zeros((nShapes, 3, nSpan))  # Shape
        PhiV = np.zeros((nShapes, 3, nSpan))  # Slope
        s_G = np.zeros((3, nSpan))
        main_axis = 'z'
        if main_axis == 'x':
            PhiU[0, 1, :] = shapes['U1']  # along y
            PhiU[1, 2, :] = shapes['U2']  # along z
            PhiV[0, 1, :] = shapes['V1']  # along y
            PhiV[1, 2, :] = shapes['V2']  # along z
            s_G[0, :] = z
        elif main_axis == 'z':
            PhiU[0, 0, :] = shapes['U1']  # along x
            PhiU[1, 1, :] = shapes['U2']  # along y
            PhiV[0, 0, :] = shapes[
                'V1']  # along x (around theta y) # TODO double check convention
            PhiV[1, 1, :] = shapes[
                'V2']  # along y (around theta x  # TODO double check convention
            s_G[2, :] = z

        # --- Testing for straight COG
        s_span = z
        jxxG = z * 0 + m  # NOTE: unknown
        #MM = GMBeam(s_G, s_span, m, PhiU, jxxG=jxxG, bUseIW=True, main_axis='x') # Ref uses IW_xm
        Mxx, Mtt, Mxt, Mtg, Mxg, Mgg, Gr, Ge, Oe, Oe6 = GMBeam(
            s_G,
            s_span,
            m,
            PhiU,
            jxxG=jxxG,
            bUseIW=True,
            main_axis=main_axis,
            split_outputs=True,
            rot_terms=True)
        MM, Gr, Ge, Oe, Oe6 = GMBeam(s_G,
                                     s_span,
                                     m,
                                     PhiU,
                                     jxxG=jxxG,
                                     bUseIW=True,
                                     main_axis=main_axis,
                                     split_outputs=False,
                                     rot_terms=True)
        MM_ref = np.array(  # NOTE: this is onshore tower
            [[
                3.474602316e+05, 0.000000000e+00, 0.000000000e+00,
                0.000000000e+00, 1.322633773e+07, -0.000000000e+00,
                1.046938838e+05, 0.000000000e+00
            ],
             [
                 0.000000000e+00, 3.474602316e+05, 0.000000000e+00,
                 -1.322633773e+07, 0.000000000e+00, 0.000000000e+00,
                 0.000000000e+00, 1.046938838e+05
             ],
             [
                 0.000000000e+00, 0.000000000e+00, 3.474602316e+05,
                 0.000000000e+00, -0.000000000e+00, 0.000000000e+00,
                 0.000000000e+00, 0.000000000e+00
             ],
             [
                 0.000000000e+00, -1.322633773e+07, 0.000000000e+00,
                 7.182575651e+08, -0.000000000e+00, -0.000000000e+00,
                 0.000000000e+00, -6.440479129e+06
             ],
             [
                 1.322633773e+07, 0.000000000e+00, -0.000000000e+00,
                 -0.000000000e+00, 7.182575651e+08, -0.000000000e+00,
                 6.440479129e+06, 0.000000000e+00
             ],
             [
                 -0.000000000e+00, 0.000000000e+00, 0.000000000e+00,
                 -0.000000000e+00, -0.000000000e+00, 3.474602316e+05,
                 0.000000000e+00, 0.000000000e+00
             ],
             [
                 1.046938838e+05, 0.000000000e+00, 0.000000000e+00,
                 0.000000000e+00, 6.440479129e+06, 0.000000000e+00,
                 6.145588498e+04, 0.000000000e+00
             ],
             [
                 0.000000000e+00, 1.046938838e+05, 0.000000000e+00,
                 -6.440479129e+06, 0.000000000e+00, 0.000000000e+00,
                 0.000000000e+00, 6.145588498e+04
             ]])

        np.testing.assert_allclose(Mxx, MM_ref[0:3, 0:3], rtol=1e-4)
        np.testing.assert_allclose(Mxt, MM_ref[0:3, 3:6], rtol=1e-4)
        np.testing.assert_allclose(Mxg, MM_ref[0:3, 6::], rtol=1e-4)
        np.testing.assert_allclose(Mtt, MM_ref[3:6, 3:6], rtol=1e-4)
        np.testing.assert_allclose(Mtg, MM_ref[3:6, 6:], rtol=1e-4)
        np.testing.assert_allclose(Mgg, MM_ref[6:, 6:], rtol=1e-4)

        np.testing.assert_allclose(Gr[0][0, :], [0, 0, -12945834], rtol=1e-5)
        np.testing.assert_allclose(Gr[1][1, :], [0, 0, -12945834], rtol=1e-5)
        np.testing.assert_allclose(Ge[0][1, :], [0, 0, 122911], rtol=1e-5)
        np.testing.assert_allclose(Ge[1][0, :], [0, 0, -122911], rtol=1e-5)
        np.testing.assert_allclose(Oe6[0][:], [0, 0, 0, 0, 0, 6472917],
                                   rtol=1e-5)
        np.testing.assert_allclose(Oe6[1][:], [0, 0, 0, 0, 6472917, 0],
                                   rtol=1e-5)
示例#7
0
文件: sid.py 项目: eboateng/welib
def FAST2SID(ed_file, Imodes_twr=None, Imodes_bld=None):
    import welib.weio as weio
    import os
    # --- Read data from ElastoDyn file
    parentDir = os.path.dirname(ed_file)
    ed = weio.read(ed_file)
    #     edfile =
    #     if twr:

    twr_sid = None
    if Imodes_twr is not None:
        TowerHt = ed['TowerHt']
        TowerBs = ed['TowerBsHt']
        TwrFile = ed['TwrFile'].replace('"', '')
        TwrFile = os.path.join(parentDir, TwrFile)
        twr = weio.FASTInputFile(TwrFile).toDataFrame()
        z = twr['HtFract_[-]'] * (TowerHt - TowerBs)
        m = twr['TMassDen_[kg/m]']  # mu
        EIy = twr['TwFAStif_[Nm^2]']
        EIz = twr[
            'TwSSStif_[Nm^2]']  # TODO actually EIx, but FEM beams along x
        # --- Create Beam FEM model
        # Derived parameters
        A = m * 0 + 100  # Area
        Kv = m * 0 + 100  # Saint Venant torsion
        E = 214e9  # Young modulus
        Iy = EIy / E
        Iz = EIz / E
        xNodes = np.zeros((3, len(m)))
        xNodes[2, :] = z

        twr_sid = Beam2SID(xNodes, Imodes_twr, m, Iy, Iz, Kv=Kv, A=A, E=E)

    bld_sid = None
    if Imodes_bld is not None:
        TipRad = ed['TipRad']
        HubRad = ed['HubRad']
        BldLen = TipRad - HubRad
        BldFile = ed['BldFile(1)'].replace('"', '')
        BldFile = os.path.join(parentDir, BldFile)
        bld = weio.FASTInputFile(BldFile).toDataFrame()
        z = bld['BlFract_[-]'] * BldLen + HubRad
        m = bld['BMassDen_[kg/m]']  # mu
        EIy = bld['FlpStff_[Nm^2]']
        EIz = bld['EdgStff_[Nm^2]']  # TODO actually EIx, but FEM beams along x
        phi = bld['PitchAxis_[-]'] / (180) * np.pi
        # --- Derived parameters
        phi = np.concatenate(
            ([0], np.diff(phi)))  #% add phi_abs(1) to pitch angle
        A = m * 0 + 100  # Area
        Kv = m * 0 + 100  # Saint Venant torsion
        E = 214e9  # Young modulus
        Iy = EIy / E
        Iz = EIz / E
        xNodes = np.zeros((3, len(m)))
        xNodes[2, :] = z
        bld_sid = Beam2SID(xNodes,
                           Imodes_bld,
                           m,
                           Iy,
                           Iz,
                           Kv=Kv,
                           A=A,
                           E=E,
                           phi=phi)

    return twr_sid, bld_sid
示例#8
0
        Graph.addMode(displ=dispCB[:, :, iMode],
                      name='CB{:d}'.format(iMode + 1),
                      freq=data['CB_frequencies'][iMode])

    #print(Graph.toJSON())

    return Graph


if __name__ == '__main__':
    import welib.weio as weio

    filename = '../../_data/Monopile/MT100_SD.dat'
    # filename='../../_data/Monopile/TetraSpar_SubDyn_v3.dat'

    sd = weio.FASTInputFile(filename)
    #     sd.write('OutMT.dat')
    Graph = sd.toGraph()
    Graph.divideElements(2)
    print(Graph)
    print(Graph.sortNodesBy('z'))
    # print(Graph.nodalDataFrame(sortBy='z'))
    print(Graph.points)
    print(Graph.connectivity)
    print(Graph)

# import numpy as np
# import matplotlib.pyplot as plt
# from matplotlib import collections  as mc
# from mpl_toolkits.mplot3d import Axes3D
# fig = plt.figure()