Ejemplo n.º 1
0
    def calc_k0(self, silent=False):
        self._rebuild()
        msg('Calculating k0... ', level=2, silent=silent)
        model = self.model
        a = self.a
        b = self.b
        r = self.r
        m = self.m
        n = self.n
        num = panmDB.db[self.model]['num']
        size = self.get_size()

        k0 = 0.

        # contributions from panels
        for p in self.panels:
            p.calc_k0(size=size, row0=0, col0=0, silent=True,
                          finalize=False)
            #TODO summing up coo_matrix objects may be slow!
            k0 += p.k0

        # contributions from bladestiff1ds
        for s in self.bladestiff1ds:
            s.calc_k0(size=size, row0=0, col0=0, silent=True,
                      finalize=False)
            #TODO summing up coo_matrix objects may be slow!
            k0 += s.k0

        # contributions from bladestiff2ds
        row0 = num*m*n
        col0 = num*m*n
        for i, s in enumerate(self.bladestiff2ds):
            num1 = stiffmDB.db[s.model]['num1']
            if i > 0:
                s_1 = bay.bladestiff2ds[i-1]
                row0 += num1*s_1.m1*s_1.n1
                col0 += num1*s_1.m1*s_1.n1
            s.calc_k0(size=size, row0=row0, col0=col0, silent=True,
                      finalize=False)
            #TODO summing up coo_matrix objects may be slow!
            k0 += s.k0

        # performing checks for the stiffness matrices
        assert np.any(np.isnan(k0.data)) == False
        assert np.any(np.isinf(k0.data)) == False
        k0 = csr_matrix(make_symmetric(k0))

        self.k0 = k0

        #NOTE forcing Python garbage collector to clean the memory
        #     it DOES make a difference! There is a memory leak not
        #     identified, probably in the csr_matrix process
        gc.collect()

        msg('finished!', level=2, silent=silent)
Ejemplo n.º 2
0
    def calc_cA(self, silent=False):
        self._rebuild()
        msg('Calculating cA... ', level=2, silent=silent)
        model = self.model
        a = self.a
        b = self.b
        r = self.r
        m = self.m
        n = self.n
        num = panmDB.db[self.model]['num']
        size = self.get_size()

        if self.beta is None:
            if self.Mach < 1:
                raise ValueError('Mach number must be >= 1')
            elif self.Mach == 1:
                self.Mach = 1.0001
            M = self.Mach
            beta = self.rho_air * self.V**2 / (M**2 - 1)**0.5
            gamma = beta*1./(2.*self.r*(M**2 - 1)**0.5)
            ainf = self.speed_sound
            aeromu = beta/(M*ainf)*(M**2 - 2)/(M**2 - 1)
        else:
            beta = self.beta
            gamma = self.gamma if self.gamma is not None else 0.
            aeromu = self.aeromu if self.aeromu is not None else 0.

        # contributions from panels
        p = self.panels[0]
        p.calc_cA(size=size, row0=0, col0=0, silent=silent)
        cA = p.cA

        assert np.any(np.isnan(cA.data)) == False
        assert np.any(np.isinf(cA.data)) == False

        cA = csr_matrix(make_symmetric(cA))

        self.cA = cA

        #NOTE forcing Python garbage collector to clean the memory
        #     it DOES make a difference! There is a memory leak not
        #     identified, probably in the csr_matrix process
        gc.collect()

        msg('finished!', level=2, silent=silent)
Ejemplo n.º 3
0
def test_4panels_kt_kr():
    """Compare result of 4 assembled panels with single-domain results

    The panel assembly looks like::

         _________ _____
        |         |     |
        |         |     |
        |   p01   | p02 |
        |         |     |
        |_________|_____|
        |   p03   | p04 |
        |         |     |
        |         |     |
        |         |     |
        |         |     |
        |         |     |
        |_________|_____|

    """
    print('Testing validity of the default kt and kr values')

    plyt = 1.e-3 * 0.125
    laminaprop=(142.5e9, 8.7e9, 0.28, 5.1e9, 5.1e9, 5.1e9)
    stack=[0, 45, -45, 90, -45, 45, 0]
    lam = laminate.read_stack(stack=stack, plyt=plyt, laminaprop=laminaprop)

    mu=1.3e3

    r = 10.
    m = 8
    n = 8

    a1 = 1.5
    a2 = 1.5
    a3 = 2.5
    a4 = 2.5
    b1 = 1.5
    b2 = 0.5
    b3 = 1.5
    b4 = 0.5

    A11 = lam.ABD[0, 0]
    A22 = lam.ABD[1, 1]
    D11 = lam.ABD[3, 3]
    D22 = lam.ABD[4, 4]

    p01 = Panel(group='panels', x0=a3, y0=b2, a=a1, b=b1, r=r, m=m, n=n, plyt=plyt, stack=stack, laminaprop=laminaprop, mu=mu)
    p02 = Panel(group='panels', x0=a3, y0=0, a=a2, b=b2, r=r, m=m, n=n, plyt=plyt, stack=stack, laminaprop=laminaprop, mu=mu)
    p03 = Panel(group='panels', x0=0, y0=b2, a=a3, b=b3, r=r, m=m, n=n, plyt=plyt, stack=stack, laminaprop=laminaprop, mu=mu)
    p04 = Panel(group='panels', x0=0, y0=0, a=a4, b=b4, r=r, m=m, n=n, plyt=plyt, stack=stack, laminaprop=laminaprop, mu=mu)

    kt13, kr13 = connections.calc_kt_kr(p01, p03, 'xcte')
    kt24, kr24 = connections.calc_kt_kr(p02, p04, 'xcte')
    kt12, kr12 = connections.calc_kt_kr(p01, p02, 'ycte')
    kt34, kr34 = connections.calc_kt_kr(p03, p04, 'ycte')

    # boundary conditions
    p01.u1tx = 1 ; p01.u1rx = 1 ; p01.u2tx = 0 ; p01.u2rx = 1
    p01.v1tx = 1 ; p01.v1rx = 1 ; p01.v2tx = 0 ; p01.v2rx = 1
    p01.w1tx = 1 ; p01.w1rx = 1 ; p01.w2tx = 0 ; p01.w2rx = 1
    p01.u1ty = 1 ; p01.u1ry = 1 ; p01.u2ty = 0 ; p01.u2ry = 1
    p01.v1ty = 1 ; p01.v1ry = 1 ; p01.v2ty = 0 ; p01.v2ry = 1
    p01.w1ty = 1 ; p01.w1ry = 1 ; p01.w2ty = 0 ; p01.w2ry = 1

    p02.u1tx = 1 ; p02.u1rx = 1 ; p02.u2tx = 0 ; p02.u2rx = 1
    p02.v1tx = 1 ; p02.v1rx = 1 ; p02.v2tx = 0 ; p02.v2rx = 1
    p02.w1tx = 1 ; p02.w1rx = 1 ; p02.w2tx = 0 ; p02.w2rx = 1
    p02.u1ty = 0 ; p02.u1ry = 1 ; p02.u2ty = 1 ; p02.u2ry = 1
    p02.v1ty = 0 ; p02.v1ry = 1 ; p02.v2ty = 1 ; p02.v2ry = 1
    p02.w1ty = 0 ; p02.w1ry = 1 ; p02.w2ty = 1 ; p02.w2ry = 1

    p03.u1tx = 0 ; p03.u1rx = 1 ; p03.u2tx = 1 ; p03.u2rx = 1
    p03.v1tx = 0 ; p03.v1rx = 1 ; p03.v2tx = 1 ; p03.v2rx = 1
    p03.w1tx = 0 ; p03.w1rx = 1 ; p03.w2tx = 1 ; p03.w2rx = 1
    p03.u1ty = 1 ; p03.u1ry = 1 ; p03.u2ty = 0 ; p03.u2ry = 1
    p03.v1ty = 1 ; p03.v1ry = 1 ; p03.v2ty = 0 ; p03.v2ry = 1
    p03.w1ty = 1 ; p03.w1ry = 1 ; p03.w2ty = 0 ; p03.w2ry = 1

    p04.u1tx = 0 ; p04.u1rx = 1 ; p04.u2tx = 1 ; p04.u2rx = 1
    p04.v1tx = 0 ; p04.v1rx = 1 ; p04.v2tx = 1 ; p04.v2rx = 1
    p04.w1tx = 0 ; p04.w1rx = 1 ; p04.w2tx = 1 ; p04.w2rx = 1
    p04.u1ty = 0 ; p04.u1ry = 1 ; p04.u2ty = 1 ; p04.u2ry = 1
    p04.v1ty = 0 ; p04.v1ry = 1 ; p04.v2ty = 1 ; p04.v2ry = 1
    p04.w1ty = 0 ; p04.w1ry = 1 ; p04.w2ty = 1 ; p04.w2ry = 1

    conndict = [
        dict(p1=p01, p2=p02, func='SSycte', ycte1=0, ycte2=p02.b, kt=kt12, kr=kr12),
        dict(p1=p01, p2=p03, func='SSxcte', xcte1=0, xcte2=p03.a, kt=kt13, kr=kr13),
        dict(p1=p02, p2=p04, func='SSxcte', xcte1=0, xcte2=p04.a, kt=kt24, kr=kr24),
        dict(p1=p03, p2=p04, func='SSycte', ycte1=0, ycte2=p04.b, kt=kt34, kr=kr34),
        ]

    panels = [p01, p02, p03, p04]

    size = sum([3*p.m*p.n for p in panels])

    k0 = 0
    kM = 0

    row0 = 0
    col0 = 0
    for p in panels:
        k0 += p.calc_k0(row0=row0, col0=col0, size=size, silent=True, finalize=False)
        kM += p.calc_kM(row0=row0, col0=col0, size=size, silent=True, finalize=False)
        p.row_start = row0
        p.col_start = col0
        row0 += 3*p.m*p.n
        col0 += 3*p.m*p.n
        p.row_end = row0
        p.col_end = col0

    for conn in conndict:
        if conn.get('has_deffect'): # connecting if there is no deffect
            continue
        p1 = conn['p1']
        p2 = conn['p2']
        if conn['func'] == 'SSycte':
            k0 += connections.kCSSycte.fkCSSycte11(
                    conn['kt'], conn['kr'], p1, conn['ycte1'],
                    size, p1.row_start, col0=p1.col_start)
            k0 += connections.kCSSycte.fkCSSycte12(
                    conn['kt'], conn['kr'], p1, p2, conn['ycte1'], conn['ycte2'],
                    size, p1.row_start, col0=p2.col_start)
            k0 += connections.kCSSycte.fkCSSycte22(
                    conn['kt'], conn['kr'], p1, p2, conn['ycte2'],
                    size, p2.row_start, col0=p2.col_start)
        elif conn['func'] == 'SSxcte':
            k0 += connections.kCSSxcte.fkCSSxcte11(
                    conn['kt'], conn['kr'], p1, conn['xcte1'],
                    size, p1.row_start, col0=p1.col_start)
            k0 += connections.kCSSxcte.fkCSSxcte12(
                    conn['kt'], conn['kr'], p1, p2, conn['xcte1'], conn['xcte2'],
                    size, p1.row_start, col0=p2.col_start)
            k0 += connections.kCSSxcte.fkCSSxcte22(
                    conn['kt'], conn['kr'], p1, p2, conn['xcte2'],
                    size, p2.row_start, col0=p2.col_start)

    assert np.any(np.isnan(k0.data)) == False
    assert np.any(np.isinf(k0.data)) == False
    k0 = csr_matrix(make_symmetric(k0))
    assert np.any(np.isnan(kM.data)) == False
    assert np.any(np.isinf(kM.data)) == False
    kM = csr_matrix(make_symmetric(kM))

    eigvals, eigvecs = freq(k0, kM, tol=0, sparse_solver=True, silent=True,
             sort=True, reduced_dof=False,
             num_eigvalues=25, num_eigvalues_print=5)

    # Results for single panel
    m = 15
    n = 15
    singlepanel = Panel(a=(a1+a3), b=(b1+b2), r=r, m=m, n=n, plyt=plyt, stack=stack, laminaprop=laminaprop, mu=mu)
    singlepanel.freq(silent=True)

    assert np.isclose(eigvals[0], singlepanel.eigvals[0], atol=0.01, rtol=0.01)
Ejemplo n.º 4
0
    def calc_linear_matrices(self, combined_load_case=None, silent=False,
            calc_kG0=True, calc_kA=True, calc_kM=True):
        self._rebuild()
        msg('Calculating linear matrices... ', level=2, silent=silent)

        fk0, fkG0, fkA, fkM, k0edges = modelDB.get_linear_matrices(self)
        model = self.model
        a = self.a
        b = self.b
        m1 = self.m1
        n1 = self.n1
        laminaprops = self.laminaprops
        plyts = self.plyts
        h = sum(plyts)
        stack = self.stack
        mu = self.mu
        if calc_kA and self.beta is None:
            if self.M < 1:
                raise ValueError('Mach number must be >= 1')
            elif self.M == 1:
                self.M = 1.0001
            self.beta = self.rho * self.V**2 / (self.M**2 - 1)**0.5
        beta = self.beta

        if stack != []:
            lam = laminate.read_stack(stack, plyts=plyts,
                                             laminaprops=laminaprops)

        if 'clpt' in model:
            if lam is not None:
                F = lam.ABD

        elif 'fsdt' in model:
            if lam is not None:
                F = lam.ABDE
                F[6:, 6:] *= self.K

        if self.force_orthotropic_laminate:
            msg('')
            msg('Forcing orthotropic laminate...', level=2)
            F[0, 2] = 0. # A16
            F[1, 2] = 0. # A26
            F[2, 0] = 0. # A61
            F[2, 1] = 0. # A62

            F[0, 5] = 0. # B16
            F[5, 0] = 0. # B61
            F[1, 5] = 0. # B26
            F[5, 1] = 0. # B62

            F[3, 2] = 0. # B16
            F[2, 3] = 0. # B61
            F[4, 2] = 0. # B26
            F[2, 4] = 0. # B62

            F[3, 5] = 0. # D16
            F[4, 5] = 0. # D26
            F[5, 3] = 0. # D61
            F[5, 4] = 0. # D62

            if F.shape[0] == 8:
                F[6, 7] = 0. # A45
                F[7, 6] = 0. # A54

        self.lam = lam
        self.F = F

        k0 = fk0(a, b, F, m1, n1)
        if calc_kA:
            kA = fkA(beta, a, b, m1, n1)
        if calc_kM:
            kM = fkM(mu, h, a, b, m1, n1)

        if calc_kG0:
            Fx = self.Fx if self.Fx is not None else 0.
            Fy = self.Fy if self.Fy is not None else 0.
            Fxy = self.Fxy if self.Fxy is not None else 0.
            Fyx = self.Fyx if self.Fyx is not None else 0.

            if not combined_load_case:
                kG0 = fkG0(Fx, Fy, Fxy, Fyx, a, b, m1, n1)
            else:
                kG0_Fx = fkG0(Fx, 0, 0, 0, a, b, m1, n1)
                kG0_Fy = fkG0(0, Fy, 0, 0, a, b, m1, n1)
                kG0_Fxy = fkG0(0, 0, Fxy, 0, a, b, m1, n1)
                kG0_Fyx = fkG0(0, 0, 0, Fyx, a, b, m1, n1)

        # performing checks for the linear stiffness matrices

        assert np.any(np.isnan(k0.data)) == False
        assert np.any(np.isnan(k0.data)) == False

        if calc_kA:
            assert np.any(np.isinf(kA.data)) == False
            assert np.any(np.isinf(kA.data)) == False

        if calc_kM:
            assert np.any(np.isinf(kM.data)) == False
            assert np.any(np.isinf(kM.data)) == False

        k0 = csr_matrix(make_symmetric(k0))
        if calc_kA:
            kA = csr_matrix(make_skew_symmetric(kA))
        if calc_kM:
            kM = csr_matrix(make_symmetric(kM))

        if k0edges is not None:
            assert np.any((np.isnan(k0edges.data)
                           | np.isinf(k0edges.data))) == False
            k0edges = csr_matrix(make_symmetric(k0edges))

        if k0edges is not None:
            k0 = k0 + k0edges

        self.k0 = k0
        if calc_kA:
            self.kA = kA
        if calc_kM:
            self.kM = kM

        if calc_kG0:
            if not combined_load_case:
                assert np.any((np.isnan(kG0.data) | np.isinf(kG0.data))) == False
                kG0 = csr_matrix(make_symmetric(kG0))
                self.kG0 = kG0

            else:
                assert np.any((np.isnan(kG0_Fx.data)
                               | np.isinf(kG0_Fx.data))) == False
                assert np.any((np.isnan(kG0_Fy.data)
                               | np.isinf(kG0_Fy.data))) == False
                assert np.any((np.isnan(kG0_Fxy.data)
                               | np.isinf(kG0_Fxy.data))) == False
                assert np.any((np.isnan(kG0_Fyx.data)
                               | np.isinf(kG0_Fyx.data))) == False

                kG0_Fx = csr_matrix(make_symmetric(kG0_Fx))
                kG0_Fy = csr_matrix(make_symmetric(kG0_Fy))
                kG0_Fxy = csr_matrix(make_symmetric(kG0_Fxy))
                kG0_Fyx = csr_matrix(make_symmetric(kG0_Fyx))

                self.kG0_Fx = kG0_Fx
                self.kG0_Fy = kG0_Fy
                self.kG0_Fxy = kG0_Fxy
                self.kG0_Fyx = kG0_Fyx

        #NOTE forcing Python garbage collector to clean the memory
        #     it DOES make a difference! There is a memory leak not
        #     identified, probably in the csr_matrix process

        gc.collect()

        msg('finished!', level=2, silent=silent)
Ejemplo n.º 5
0
    def calc_linear_matrices(self, combined_load_case=None):
        self._rebuild()
        msg('Calculating linear matrices... ', level=2)

        fk0, fkG0, k0edges = modelDB.get_linear_matrices(self)
        model = self.model
        a = self.a
        b = self.b
        m1 = self.m1
        n1 = self.n1
        laminaprops = self.laminaprops
        plyts = self.plyts
        stack = self.stack

        if stack != []:
            lam = laminate.read_stack(stack, plyts=plyts,
                                             laminaprops=laminaprops)

        if 'clpt' in model:
            if lam is not None:
                F = lam.ABD

        elif 'fsdt' in model:
            if lam is not None:
                F = lam.ABDE
                F[6:, 6:] *= self.K

        if self.force_orthotropic_laminate:
            msg('')
            msg('Forcing orthotropic laminate...', level=2)
            F[0, 2] = 0. # A16
            F[1, 2] = 0. # A26
            F[2, 0] = 0. # A61
            F[2, 1] = 0. # A62

            F[0, 5] = 0. # B16
            F[5, 0] = 0. # B61
            F[1, 5] = 0. # B26
            F[5, 1] = 0. # B62

            F[3, 2] = 0. # B16
            F[2, 3] = 0. # B61
            F[4, 2] = 0. # B26
            F[2, 4] = 0. # B62

            F[3, 5] = 0. # D16
            F[4, 5] = 0. # D26
            F[5, 3] = 0. # D61
            F[5, 4] = 0. # D62

            if F.shape[0] == 8:
                F[6, 7] = 0. # A45
                F[7, 6] = 0. # A54

        self.lam = lam
        self.F = F

        k0 = fk0(a, b, F, m1, n1)

        Fx = self.Fx if self.Fx is not None else 0.
        Fy = self.Fy if self.Fy is not None else 0.
        Fxy = self.Fxy if self.Fxy is not None else 0.
        Fyx = self.Fyx if self.Fyx is not None else 0.

        if not combined_load_case:
            kG0 = fkG0(Fx, Fy, Fxy, Fyx, a, b, m1, n1)
        else:
            kG0_Fx = fkG0(Fx, 0, 0, 0, a, b, m1, n1)
            kG0_Fy = fkG0(0, Fy, 0, 0, a, b, m1, n1)
            kG0_Fxy = fkG0(0, 0, Fxy, 0, a, b, m1, n1)
            kG0_Fyx = fkG0(0, 0, 0, Fyx, a, b, m1, n1)

        # performing checks for the linear stiffness matrices

        assert np.any(np.isnan(k0.data)) == False
        assert np.any(np.isinf(k0.data)) == False

        k0 = csr_matrix(make_symmetric(k0))

        if k0edges is not None:
            assert np.any((np.isnan(k0edges.data)
                           | np.isinf(k0edges.data))) == False
            k0edges = csr_matrix(make_symmetric(k0edges))

        if k0edges is not None:
            msg('Applying elastic constraints!', level=3)
            #FIXME improve the way to consider the elastic constraints for the
            #      case of infinity stiffnesses
            k0max = np.abs(k0).max()
            k0 = k0 + k0edges/np.abs(k0edges).max()*100*k0max

        self.k0 = k0

        if not combined_load_case:
            assert np.any((np.isnan(kG0.data) | np.isinf(kG0.data))) == False
            kG0 = csr_matrix(make_symmetric(kG0))
            self.kG0 = kG0

        else:
            assert np.any((np.isnan(kG0_Fx.data)
                           | np.isinf(kG0_Fx.data))) == False
            assert np.any((np.isnan(kG0_Fy.data)
                           | np.isinf(kG0_Fy.data))) == False
            assert np.any((np.isnan(kG0_Fxy.data)
                           | np.isinf(kG0_Fxy.data))) == False
            assert np.any((np.isnan(kG0_Fyx.data)
                           | np.isinf(kG0_Fyx.data))) == False

            kG0_Fx = csr_matrix(make_symmetric(kG0_Fx))
            kG0_Fy = csr_matrix(make_symmetric(kG0_Fy))
            kG0_Fxy = csr_matrix(make_symmetric(kG0_Fxy))
            kG0_Fyx = csr_matrix(make_symmetric(kG0_Fyx))

            self.kG0_Fx = kG0_Fx
            self.kG0_Fy = kG0_Fy
            self.kG0_Fxy = kG0_Fxy
            self.kG0_Fyx = kG0_Fyx

        #NOTE forcing Python garbage collector to clean the memory
        #     it DOES make a difference! There is a memory leak not
        #     identified, probably in the csr_matrix process

        gc.collect()

        msg('finished!', level=2)
Ejemplo n.º 6
0
def test_4panels_kt_kr():
    """Compare result of 4 assembled panels with single-domain results

    The panel assembly looks like::

         _________ _____
        |         |     |
        |         |     |
        |   p01   | p02 |
        |         |     |
        |_________|_____|
        |   p03   | p04 |
        |         |     |
        |         |     |
        |         |     |
        |         |     |
        |         |     |
        |_________|_____|

    """
    print('Testing validity of the default kt and kr values')

    plyt = 1.e-3 * 0.125
    laminaprop = (142.5e9, 8.7e9, 0.28, 5.1e9, 5.1e9, 5.1e9)
    stack = [0, 45, -45, 90, -45, 45, 0]
    lam = laminate.read_stack(stack=stack, plyt=plyt, laminaprop=laminaprop)

    mu = 1.3e3

    r = 10.
    m = 8
    n = 8

    a1 = 1.5
    a2 = 1.5
    a3 = 2.5
    a4 = 2.5
    b1 = 1.5
    b2 = 0.5
    b3 = 1.5
    b4 = 0.5

    A11 = lam.ABD[0, 0]
    A22 = lam.ABD[1, 1]
    D11 = lam.ABD[3, 3]
    D22 = lam.ABD[4, 4]

    p01 = Panel(group='panels',
                x0=a3,
                y0=b2,
                a=a1,
                b=b1,
                r=r,
                m=m,
                n=n,
                plyt=plyt,
                stack=stack,
                laminaprop=laminaprop,
                mu=mu)
    p02 = Panel(group='panels',
                x0=a3,
                y0=0,
                a=a2,
                b=b2,
                r=r,
                m=m,
                n=n,
                plyt=plyt,
                stack=stack,
                laminaprop=laminaprop,
                mu=mu)
    p03 = Panel(group='panels',
                x0=0,
                y0=b2,
                a=a3,
                b=b3,
                r=r,
                m=m,
                n=n,
                plyt=plyt,
                stack=stack,
                laminaprop=laminaprop,
                mu=mu)
    p04 = Panel(group='panels',
                x0=0,
                y0=0,
                a=a4,
                b=b4,
                r=r,
                m=m,
                n=n,
                plyt=plyt,
                stack=stack,
                laminaprop=laminaprop,
                mu=mu)

    kt13, kr13 = connections.calc_kt_kr(p01, p03, 'xcte')
    kt24, kr24 = connections.calc_kt_kr(p02, p04, 'xcte')
    kt12, kr12 = connections.calc_kt_kr(p01, p02, 'ycte')
    kt34, kr34 = connections.calc_kt_kr(p03, p04, 'ycte')

    # boundary conditions
    p01.u1tx = 1
    p01.u1rx = 1
    p01.u2tx = 0
    p01.u2rx = 1
    p01.v1tx = 1
    p01.v1rx = 1
    p01.v2tx = 0
    p01.v2rx = 1
    p01.w1tx = 1
    p01.w1rx = 1
    p01.w2tx = 0
    p01.w2rx = 1
    p01.u1ty = 1
    p01.u1ry = 1
    p01.u2ty = 0
    p01.u2ry = 1
    p01.v1ty = 1
    p01.v1ry = 1
    p01.v2ty = 0
    p01.v2ry = 1
    p01.w1ty = 1
    p01.w1ry = 1
    p01.w2ty = 0
    p01.w2ry = 1

    p02.u1tx = 1
    p02.u1rx = 1
    p02.u2tx = 0
    p02.u2rx = 1
    p02.v1tx = 1
    p02.v1rx = 1
    p02.v2tx = 0
    p02.v2rx = 1
    p02.w1tx = 1
    p02.w1rx = 1
    p02.w2tx = 0
    p02.w2rx = 1
    p02.u1ty = 0
    p02.u1ry = 1
    p02.u2ty = 1
    p02.u2ry = 1
    p02.v1ty = 0
    p02.v1ry = 1
    p02.v2ty = 1
    p02.v2ry = 1
    p02.w1ty = 0
    p02.w1ry = 1
    p02.w2ty = 1
    p02.w2ry = 1

    p03.u1tx = 0
    p03.u1rx = 1
    p03.u2tx = 1
    p03.u2rx = 1
    p03.v1tx = 0
    p03.v1rx = 1
    p03.v2tx = 1
    p03.v2rx = 1
    p03.w1tx = 0
    p03.w1rx = 1
    p03.w2tx = 1
    p03.w2rx = 1
    p03.u1ty = 1
    p03.u1ry = 1
    p03.u2ty = 0
    p03.u2ry = 1
    p03.v1ty = 1
    p03.v1ry = 1
    p03.v2ty = 0
    p03.v2ry = 1
    p03.w1ty = 1
    p03.w1ry = 1
    p03.w2ty = 0
    p03.w2ry = 1

    p04.u1tx = 0
    p04.u1rx = 1
    p04.u2tx = 1
    p04.u2rx = 1
    p04.v1tx = 0
    p04.v1rx = 1
    p04.v2tx = 1
    p04.v2rx = 1
    p04.w1tx = 0
    p04.w1rx = 1
    p04.w2tx = 1
    p04.w2rx = 1
    p04.u1ty = 0
    p04.u1ry = 1
    p04.u2ty = 1
    p04.u2ry = 1
    p04.v1ty = 0
    p04.v1ry = 1
    p04.v2ty = 1
    p04.v2ry = 1
    p04.w1ty = 0
    p04.w1ry = 1
    p04.w2ty = 1
    p04.w2ry = 1

    conndict = [
        dict(p1=p01,
             p2=p02,
             func='SSycte',
             ycte1=0,
             ycte2=p02.b,
             kt=kt12,
             kr=kr12),
        dict(p1=p01,
             p2=p03,
             func='SSxcte',
             xcte1=0,
             xcte2=p03.a,
             kt=kt13,
             kr=kr13),
        dict(p1=p02,
             p2=p04,
             func='SSxcte',
             xcte1=0,
             xcte2=p04.a,
             kt=kt24,
             kr=kr24),
        dict(p1=p03,
             p2=p04,
             func='SSycte',
             ycte1=0,
             ycte2=p04.b,
             kt=kt34,
             kr=kr34),
    ]

    panels = [p01, p02, p03, p04]

    size = sum([3 * p.m * p.n for p in panels])

    k0 = 0
    kM = 0

    row0 = 0
    col0 = 0
    for p in panels:
        k0 += p.calc_k0(row0=row0,
                        col0=col0,
                        size=size,
                        silent=True,
                        finalize=False)
        kM += p.calc_kM(row0=row0,
                        col0=col0,
                        size=size,
                        silent=True,
                        finalize=False)
        p.row_start = row0
        p.col_start = col0
        row0 += 3 * p.m * p.n
        col0 += 3 * p.m * p.n
        p.row_end = row0
        p.col_end = col0

    for conn in conndict:
        if conn.get('has_deffect'):  # connecting if there is no deffect
            continue
        p1 = conn['p1']
        p2 = conn['p2']
        if conn['func'] == 'SSycte':
            k0 += connections.kCSSycte.fkCSSycte11(conn['kt'],
                                                   conn['kr'],
                                                   p1,
                                                   conn['ycte1'],
                                                   size,
                                                   p1.row_start,
                                                   col0=p1.col_start)
            k0 += connections.kCSSycte.fkCSSycte12(conn['kt'],
                                                   conn['kr'],
                                                   p1,
                                                   p2,
                                                   conn['ycte1'],
                                                   conn['ycte2'],
                                                   size,
                                                   p1.row_start,
                                                   col0=p2.col_start)
            k0 += connections.kCSSycte.fkCSSycte22(conn['kt'],
                                                   conn['kr'],
                                                   p1,
                                                   p2,
                                                   conn['ycte2'],
                                                   size,
                                                   p2.row_start,
                                                   col0=p2.col_start)
        elif conn['func'] == 'SSxcte':
            k0 += connections.kCSSxcte.fkCSSxcte11(conn['kt'],
                                                   conn['kr'],
                                                   p1,
                                                   conn['xcte1'],
                                                   size,
                                                   p1.row_start,
                                                   col0=p1.col_start)
            k0 += connections.kCSSxcte.fkCSSxcte12(conn['kt'],
                                                   conn['kr'],
                                                   p1,
                                                   p2,
                                                   conn['xcte1'],
                                                   conn['xcte2'],
                                                   size,
                                                   p1.row_start,
                                                   col0=p2.col_start)
            k0 += connections.kCSSxcte.fkCSSxcte22(conn['kt'],
                                                   conn['kr'],
                                                   p1,
                                                   p2,
                                                   conn['xcte2'],
                                                   size,
                                                   p2.row_start,
                                                   col0=p2.col_start)

    assert np.any(np.isnan(k0.data)) == False
    assert np.any(np.isinf(k0.data)) == False
    k0 = csr_matrix(make_symmetric(k0))
    assert np.any(np.isnan(kM.data)) == False
    assert np.any(np.isinf(kM.data)) == False
    kM = csr_matrix(make_symmetric(kM))

    eigvals, eigvecs = freq(k0,
                            kM,
                            tol=0,
                            sparse_solver=True,
                            silent=True,
                            sort=True,
                            reduced_dof=False,
                            num_eigvalues=25,
                            num_eigvalues_print=5)

    # Results for single panel
    m = 15
    n = 15
    singlepanel = Panel(a=(a1 + a3),
                        b=(b1 + b2),
                        r=r,
                        m=m,
                        n=n,
                        plyt=plyt,
                        stack=stack,
                        laminaprop=laminaprop,
                        mu=mu)
    singlepanel.freq(silent=True)

    assert np.isclose(eigvals[0], singlepanel.eigvals[0], atol=0.01, rtol=0.01)
Ejemplo n.º 7
0
    def calc_linear_matrices(self, combined_load_case=None, silent=False,
            calc_kG0=True, calc_kA=True, calc_kM=True):
        self._rebuild()
        msg('Calculating linear matrices... ', level=2, silent=silent)

        fk0, fkG0, fkAx, fkAy, fcA, fkM, fk0edges, fk0sb, fk0sf, fk0sf2, fkMsb, fkMsf = \
                modelDB.get_linear_matrices(self)
        model = self.model
        a = self.a
        b = self.b
        r = self.r
        m1 = self.m1
        n1 = self.n1
        laminaprops = self.laminaprops
        plyts = self.plyts
        h = sum(plyts)
        stack = self.stack
        mu = self.mu
        if calc_kA and self.beta is None:
            if self.Mach < 1:
                raise ValueError('Mach number must be >= 1')
            elif self.Mach == 1:
                self.Mach = 1.0001
            M = self.Mach
            beta = self.rho_air * self.V**2 / (M**2 - 1)**0.5
            gamma = beta*1./(2.*r*(M**2 - 1)**0.5)
            ainf = self.speed_sound
            aeromu = beta/(M*ainf)*(M**2 - 2)/(M**2 - 1)
        elif calc_kA and self.beta is not None:
            beta = self.beta
            gamma = self.gamma if self.gamma is not None else 0.
            aeromu = self.aeromu if self.aeromu is not None else 0.
        elif not calc_kA:
            pass
        else:
            raise NotImplementedError('check here')

        if stack != []:
            lam = laminate.read_stack(stack, plyts=plyts,
                                             laminaprops=laminaprops)

        if 'clpt' in model:
            if lam is not None:
                F = lam.ABD

        elif 'fsdt' in model:
            if lam is not None:
                F = lam.ABDE
                F[6:, 6:] *= self.K

        self.lam = lam
        self.F = F

        k0 = fk0(a, b, r, F, m1, n1)

        if (self.model == 'clpt_donnell_bc1'
        or  self.model == 'clpt_sanders_bc1'):
            k0edges = fk0edges(m1, n1, a, b,
                               self.kphixBot, self.kphixTop,
                               self.kphiyLeft, self.kphiyRight)
        elif self.model == 'fsdt_donnell_bc1':
            k0edges = fk0edges(m1, n1, a, b,
                               self.kphixBot, self.kphixTop,
                               self.kphiyBot, self.kphiyTop,
                               self.kphixLeft, self.kphixRight,
                               self.kphiyLeft, self.kphiyRight)
        else:
            raise

        if calc_kA:
            if self.flow == 'x':
                kA = fkAx(beta, gamma, a, b, m1, n1)
            elif self.flow == 'y':
                kA = fkAy(beta, a, b, m1, n1)
            if fcA is None:
                cA = None
            else:
                cA = fcA(aeromu, a, b, m1, n1)
                cA = cA*(0+1j)
        if calc_kM:
            if self.model == 'fsdt_donnell_bc1':
                raise NotImplementedError('There is a bug with kM for model %s'
                        % self.model)
            kM = fkM(mu, h, a, b, m1, n1)

        if calc_kG0:
            Fx = self.Fx if self.Fx is not None else 0.
            Fy = self.Fy if self.Fy is not None else 0.
            Fxy = self.Fxy if self.Fxy is not None else 0.
            Fyx = self.Fyx if self.Fyx is not None else 0.

            if not combined_load_case:
                kG0 = fkG0(Fx, Fy, Fxy, Fyx, a, b, r, m1, n1)
            else:
                kG0_Fx = fkG0(Fx, 0, 0, 0, a, b, r, m1, n1)
                kG0_Fy = fkG0(0, Fy, 0, 0, a, b, r, m1, n1)
                kG0_Fxy = fkG0(0, 0, Fxy, 0, a, b, r, m1, n1)
                kG0_Fyx = fkG0(0, 0, 0, Fyx, a, b, r, m1, n1)

        # contributions from stiffeners
        #TODO summing up coo_matrix objects may be very slow!
        for s in self.stiffeners:
            if s.blam is not None:
                Fsb = s.blam.ABD
                k0 += fk0sb(s.ys, s.bb, a, b, r, m1, n1, Fsb)
            if s.flange_formulation == 1:
                k0 += fk0sf(s.ys, a, b, r, m1, n1, s.Exx, s.Gxy, s.Jxx, s.Iyy)
            elif s.flange_formulation == 2:
                k0 += fk0sf2(s.bf, s.df, s.ys, a, b, r, m1, n1, s.E1, s.F1,
                             s.S1, s.Jxx)

            if s.blam is not None:
                kM += fkMsb(s.mu, s.ys, s.db, s.hb, a, b, m1, n1)
            kM += fkMsf(s.mu, s.ys, s.df, s.Asf, a, b, s.Iyy, s.Jxx, m1, n1)

        # performing checks for the linear stiffness matrices

        assert np.any(np.isnan(k0.data)) == False
        assert np.any(np.isinf(k0.data)) == False

        if calc_kA:
            assert np.any(np.isnan(kA.data)) == False
            assert np.any(np.isinf(kA.data)) == False
            if cA is not None:
                assert np.any(np.isnan(cA.data)) == False
                assert np.any(np.isinf(cA.data)) == False

        if calc_kM:
            assert np.any(np.isnan(kM.data)) == False
            assert np.any(np.isinf(kM.data)) == False

        k0 = csr_matrix(make_symmetric(k0))
        if calc_kA:
            kA = csr_matrix(make_skew_symmetric(kA))
            if cA is not None:
                cA = csr_matrix(make_symmetric(cA))
        if calc_kM:
            kM = csr_matrix(make_symmetric(kM))

        assert np.any(np.isnan(k0edges.data)) == False
        assert np.any(np.isinf(k0edges.data)) == False
        k0edges = csr_matrix(make_symmetric(k0edges))

        k0 = k0 + k0edges

        self.k0 = k0
        if calc_kA:
            self.kA = kA
            self.cA = cA
        if calc_kM:
            self.kM = kM

        if calc_kG0:
            if not combined_load_case:
                assert np.any((np.isnan(kG0.data) | np.isinf(kG0.data))) == False
                kG0 = csr_matrix(make_symmetric(kG0))
                self.kG0 = kG0

            else:
                assert np.any((np.isnan(kG0_Fx.data)
                               | np.isinf(kG0_Fx.data))) == False
                assert np.any((np.isnan(kG0_Fy.data)
                               | np.isinf(kG0_Fy.data))) == False
                assert np.any((np.isnan(kG0_Fxy.data)
                               | np.isinf(kG0_Fxy.data))) == False
                assert np.any((np.isnan(kG0_Fyx.data)
                               | np.isinf(kG0_Fyx.data))) == False

                kG0_Fx = csr_matrix(make_symmetric(kG0_Fx))
                kG0_Fy = csr_matrix(make_symmetric(kG0_Fy))
                kG0_Fxy = csr_matrix(make_symmetric(kG0_Fxy))
                kG0_Fyx = csr_matrix(make_symmetric(kG0_Fyx))

                self.kG0_Fx = kG0_Fx
                self.kG0_Fy = kG0_Fy
                self.kG0_Fxy = kG0_Fxy
                self.kG0_Fyx = kG0_Fyx

        #NOTE forcing Python garbage collector to clean the memory
        #     it DOES make a difference! There is a memory leak not
        #     identified, probably in the csr_matrix process

        gc.collect()

        msg('finished!', level=2, silent=silent)