예제 #1
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)
예제 #2
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)
예제 #3
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)