def compute_forces_constraints(self, MB_beam, MB_tstep, Lambda):
        try:
            self.lc_list[0]
        except IndexError:
            return

        # TODO the output of this routine is wrong. check at some point.
        LM_C, LM_K, LM_Q = lagrangeconstraints.generate_lagrange_matrix(
            self.lc_list, MB_beam, MB_tstep, 0, self.num_LM_eq, self.sys_size,
            0., Lambda, np.zeros_like(Lambda), "static")
        F = -np.dot(LM_K[:, -self.num_LM_eq:], Lambda)

        first_dof = 0
        for ibody in range(len(MB_beam)):
            # Forces associated to nodes
            body_numdof = MB_beam[ibody].num_dof.value
            body_freenodes = np.sum(MB_beam[ibody].vdof > -1)
            last_dof = first_dof + body_numdof
            MB_tstep[ibody].forces_constraints_nodes[(
                MB_beam[ibody].vdof > -1), :] = F[first_dof:last_dof].reshape(
                    body_freenodes, 6, order='C')

            # Forces associated to the frame of reference
            if MB_beam[ibody].FoR_movement == 'free':
                # TODO: How are the forces in the quaternion equation interpreted?
                MB_tstep[ibody].forces_constraints_FoR[
                    ibody, :] = F[last_dof:last_dof + 10]
                last_dof += 10

            first_dof = last_dof
示例#2
0
    def compute_forces_constraints(self, MB_beam, MB_tstep, ts, dt, Lambda,
                                   Lambda_dot):
        """
        This function computes the forces generated at Lagrange Constraints

        Args:
            MB_beam (list(:class:`~sharpy.structure.models.beam.Beam`)): each entry represents a body
            MB_tstep (list(:class:`~sharpy.utils.datastructures.StructTimeStepInfo`)): each entry represents a body
            ts (int): Time step number
            dt(float): Time step increment
            Lambda (np.ndarray): Lagrange Multipliers array
            Lambda_dot (np.ndarray): Time derivarive of ``Lambda``

        Warning:
            This function is underdevelopment and not fully functional
        """
        try:
            self.lc_list[0]
        except IndexError:
            return

        # TODO the output of this routine is wrong. check at some point.
        LM_C, LM_K, LM_Q = lagrangeconstraints.generate_lagrange_matrix(
            self.lc_list, MB_beam, MB_tstep, ts, self.num_LM_eq, self.sys_size,
            dt, Lambda, Lambda_dot, "dynamic")
        F = -np.dot(LM_C[:, -self.num_LM_eq:], Lambda_dot) - np.dot(
            LM_K[:, -self.num_LM_eq:], Lambda)

        first_dof = 0
        for ibody in range(len(MB_beam)):
            # Forces associated to nodes
            body_numdof = MB_beam[ibody].num_dof.value
            body_freenodes = np.sum(MB_beam[ibody].vdof > -1)
            last_dof = first_dof + body_numdof
            MB_tstep[ibody].forces_constraints_nodes[(
                MB_beam[ibody].vdof > -1), :] = F[first_dof:last_dof].reshape(
                    body_freenodes, 6, order='C')

            # Forces associated to the frame of reference
            if MB_beam[ibody].FoR_movement == 'free':
                # TODO: How are the forces in the quaternion equation interpreted?
                MB_tstep[ibody].forces_constraints_FoR[
                    ibody, :] = F[last_dof:last_dof + 10]
                last_dof += 10

            first_dof = last_dof
    def assembly_MB_eq_system(self, MB_beam, MB_tstep, Lambda, MBdict,
                              iLoadStep):
        self.lc_list = lagrangeconstraints.initialize_constraints(MBdict)
        self.num_LM_eq = lagrangeconstraints.define_num_LM_eq(self.lc_list)

        # MB_M = np.zeros((self.sys_size+self.num_LM_eq, self.sys_size+self.num_LM_eq), dtype=ct.c_double, order='F')
        # MB_C = np.zeros((self.sys_size+self.num_LM_eq, self.sys_size+self.num_LM_eq), dtype=ct.c_double, order='F')
        MB_K = np.zeros(
            (self.sys_size + self.num_LM_eq, self.sys_size + self.num_LM_eq),
            dtype=ct.c_double,
            order='F')
        # MB_Asys = np.zeros((self.sys_size+self.num_LM_eq, self.sys_size+self.num_LM_eq), dtype=ct.c_double, order='F')
        MB_Q = np.zeros((self.sys_size + self.num_LM_eq, ),
                        dtype=ct.c_double,
                        order='F')
        #ipdb.set_trace()
        first_dof = 0
        last_dof = 0
        # Loop through the different bodies
        for ibody in range(len(MB_beam)):

            # Initialize matrices
            # M = None
            # C = None
            K = None
            Q = None

            # Generate the matrices for each body
            if MB_beam[ibody].FoR_movement == 'prescribed':
                last_dof = first_dof + MB_beam[ibody].num_dof.value
            elif MB_beam[ibody].FoR_movement == 'free':
                last_dof = first_dof + MB_beam[ibody].num_dof.value + 10

            K, Q = xbeamlib.cbeam3_asbly_static(MB_beam[ibody],
                                                MB_tstep[ibody], self.settings,
                                                iLoadStep)

            ############### Assembly into the global matrices
            # Flexible and RBM contribution to Asys
            # MB_M[first_dof:last_dof, first_dof:last_dof] = M.astype(dtype=ct.c_double, copy=True, order='F')
            # MB_C[first_dof:last_dof, first_dof:last_dof] = C.astype(dtype=ct.c_double, copy=True, order='F')
            MB_K[first_dof:last_dof,
                 first_dof:last_dof] = K.astype(dtype=ct.c_double,
                                                copy=True,
                                                order='F')

            #Q
            MB_Q[first_dof:last_dof] = Q

            first_dof = last_dof

        # Define the number of equations
        # Generate matrices associated to Lagrange multipliers
        LM_C, LM_K, LM_Q = lagrangeconstraints.generate_lagrange_matrix(
            self.lc_list, MB_beam, MB_tstep, 0, self.num_LM_eq, self.sys_size,
            0., Lambda, np.zeros_like(Lambda), "static")

        # Include the matrices associated to Lagrange Multipliers
        # MB_C += LM_C
        MB_K += LM_K
        MB_Q += LM_Q

        # MB_Asys = MB_K + MB_C*self.gamma/(self.beta*dt) + MB_M/(self.beta*dt*dt)

        return MB_K, MB_Q
示例#4
0
    def assembly_MB_eq_system(self, MB_beam, MB_tstep, ts, dt, Lambda,
                              Lambda_dot, MBdict):
        """
        This function generates the matrix and vector associated to the linear system to solve a structural iteration
        It usses a Newmark-beta scheme for time integration. Being M, C and K the mass, damping
        and stiffness matrices of the system:

        .. math::
            MB_Asys = MB_K + MB_C \frac{\gamma}{\beta dt} + \frac{1}{\beta dt^2} MB_M

        Args:
            MB_beam (list(:class:`~sharpy.structure.models.beam.Beam`)): each entry represents a body
            MB_tstep (list(:class:`~sharpy.utils.datastructures.StructTimeStepInfo`)): each entry represents a body
            ts (int): Time step number
            dt(int): time step
            Lambda (np.ndarray): Lagrange Multipliers array
            Lambda_dot (np.ndarray): Time derivarive of ``Lambda``
            MBdict (dict): Dictionary including the multibody information

        Returns:
            MB_Asys (np.ndarray): Matrix of the systems of equations
            MB_Q (np.ndarray): Vector of the systems of equations
        """
        self.num_LM_eq = lagrangeconstraints.define_num_LM_eq(self.lc_list)

        MB_M = np.zeros(
            (self.sys_size + self.num_LM_eq, self.sys_size + self.num_LM_eq),
            dtype=ct.c_double,
            order='F')
        MB_C = np.zeros(
            (self.sys_size + self.num_LM_eq, self.sys_size + self.num_LM_eq),
            dtype=ct.c_double,
            order='F')
        MB_K = np.zeros(
            (self.sys_size + self.num_LM_eq, self.sys_size + self.num_LM_eq),
            dtype=ct.c_double,
            order='F')
        MB_Asys = np.zeros(
            (self.sys_size + self.num_LM_eq, self.sys_size + self.num_LM_eq),
            dtype=ct.c_double,
            order='F')
        MB_Q = np.zeros((self.sys_size + self.num_LM_eq, ),
                        dtype=ct.c_double,
                        order='F')
        first_dof = 0
        last_dof = 0

        # Loop through the different bodies
        for ibody in range(len(MB_beam)):

            # Initialize matrices
            M = None
            C = None
            K = None
            Q = None

            # Generate the matrices for each body
            if MB_beam[ibody].FoR_movement == 'prescribed':
                last_dof = first_dof + MB_beam[ibody].num_dof.value
                M, C, K, Q = xbeamlib.cbeam3_asbly_dynamic(
                    MB_beam[ibody], MB_tstep[ibody], self.settings)

            elif MB_beam[ibody].FoR_movement == 'free':
                last_dof = first_dof + MB_beam[ibody].num_dof.value + 10
                M, C, K, Q = xbeamlib.xbeam3_asbly_dynamic(
                    MB_beam[ibody], MB_tstep[ibody], self.settings)

            ############### Assembly into the global matrices
            # Flexible and RBM contribution to Asys
            MB_M[first_dof:last_dof,
                 first_dof:last_dof] = M.astype(dtype=ct.c_double,
                                                copy=True,
                                                order='F')
            MB_C[first_dof:last_dof,
                 first_dof:last_dof] = C.astype(dtype=ct.c_double,
                                                copy=True,
                                                order='F')
            MB_K[first_dof:last_dof,
                 first_dof:last_dof] = K.astype(dtype=ct.c_double,
                                                copy=True,
                                                order='F')

            #Q
            MB_Q[first_dof:last_dof] = Q

            first_dof = last_dof

        # Define the number of equations
        # Generate matrices associated to Lagrange multipliers
        LM_C, LM_K, LM_Q = lagrangeconstraints.generate_lagrange_matrix(
            self.lc_list, MB_beam, MB_tstep, ts, self.num_LM_eq, self.sys_size,
            dt, Lambda, Lambda_dot, "dynamic")

        # Include the matrices associated to Lagrange Multipliers
        MB_C += LM_C
        MB_K += LM_K
        MB_Q += LM_Q

        MB_Asys = MB_K + MB_C * self.gamma / (self.beta * dt) + MB_M / (
            self.beta * dt * dt)

        return MB_Asys, MB_Q
示例#5
0
    def assembly_MB_eq_system(self, MB_beam, MB_tstep, Lambda, MBdict, iLoadStep):
        """
        This function generates the matrix and vector associated to the linear system to solve a structural iteration
        It usses a Newmark-beta scheme for time integration.

        Args:
            MB_beam (list(:class:`~sharpy.structure.models.beam.Beam`)): each entry represents a body
            MB_tstep (list(:class:`~sharpy.utils.datastructures.StructTimeStepInfo`)): each entry represents a body
            Lambda (np.ndarray): Lagrange Multipliers array
            MBdict (dict): Dictionary including the multibody information
            iLoadStep (int): load step

        Returns:
            MB_K (np.ndarray): Matrix of the multibody system
            MB_Q (np.ndarray): Vector of the systems of equations
        """
        self.lc_list = lagrangeconstraints.initialize_constraints(MBdict)
        self.num_LM_eq = lagrangeconstraints.define_num_LM_eq(self.lc_list)

        # MB_M = np.zeros((self.sys_size+self.num_LM_eq, self.sys_size+self.num_LM_eq), dtype=ct.c_double, order='F')
        # MB_C = np.zeros((self.sys_size+self.num_LM_eq, self.sys_size+self.num_LM_eq), dtype=ct.c_double, order='F')
        MB_K = np.zeros((self.sys_size+self.num_LM_eq, self.sys_size+self.num_LM_eq), dtype=ct.c_double, order='F')
        # MB_Asys = np.zeros((self.sys_size+self.num_LM_eq, self.sys_size+self.num_LM_eq), dtype=ct.c_double, order='F')
        MB_Q = np.zeros((self.sys_size+self.num_LM_eq,), dtype=ct.c_double, order='F')
        #ipdb.set_trace()
        first_dof = 0
        last_dof = 0
        # Loop through the different bodies
        for ibody in range(len(MB_beam)):

            # Initialize matrices
            # M = None
            # C = None
            K = None
            Q = None

            # Generate the matrices for each body
            if MB_beam[ibody].FoR_movement == 'prescribed':
                last_dof = first_dof + MB_beam[ibody].num_dof.value
            elif MB_beam[ibody].FoR_movement == 'free':
                last_dof = first_dof + MB_beam[ibody].num_dof.value + 10

            K, Q = xbeamlib.cbeam3_asbly_static(MB_beam[ibody], MB_tstep[ibody], self.settings, iLoadStep)

            ############### Assembly into the global matrices
            # Flexible and RBM contribution to Asys
            # MB_M[first_dof:last_dof, first_dof:last_dof] = M.astype(dtype=ct.c_double, copy=True, order='F')
            # MB_C[first_dof:last_dof, first_dof:last_dof] = C.astype(dtype=ct.c_double, copy=True, order='F')
            MB_K[first_dof:last_dof, first_dof:last_dof] = K.astype(dtype=ct.c_double, copy=True, order='F')

            #Q
            MB_Q[first_dof:last_dof] = Q

            first_dof = last_dof

        # Define the number of equations
        # Generate matrices associated to Lagrange multipliers
        LM_C, LM_K, LM_Q = lagrangeconstraints.generate_lagrange_matrix(
            self.lc_list,
            MB_beam,
            MB_tstep,
            0,
            self.num_LM_eq,
            self.sys_size,
            0.,
            Lambda,
            np.zeros_like(Lambda),
            "static")

        # Include the matrices associated to Lagrange Multipliers
        # MB_C += LM_C
        MB_K += LM_K
        MB_Q += LM_Q

        # MB_Asys = MB_K + MB_C*self.gamma/(self.beta*dt) + MB_M/(self.beta*dt*dt)

        return MB_K, MB_Q