Пример #1
0
    def build_matrices(self,
                       other_body,
                       force_full_computation=False,
                       **kwargs):
        """Return the influence matrices of self on other_body."""
        if isinstance(
                other_body, ReflectionSymmetry
        ) and other_body.plane == self.plane and not force_full_computation:
            # Use symmetry to speed up the evaluation of the matrix
            if other_body == self:
                LOG.debug(
                    f"Evaluating matrix of {self.name} on itself using mirror symmetry."
                )
            else:
                LOG.debug(
                    f"Evaluating matrix of {self.name} on {other_body.name} itself using mirror symmetry."
                )

            S_a, V_a = self.subbodies[0].build_matrices(
                other_body.subbodies[0], **kwargs)
            S_b, V_b = self.subbodies[0].build_matrices(
                other_body.subbodies[1], **kwargs)

            return BlockToeplitzMatrix([S_a,
                                        S_b]), BlockToeplitzMatrix([V_a, V_b])

        else:
            return CollectionOfFloatingBodies.build_matrices(
                self, other_body, **kwargs)
Пример #2
0
    def build_matrices(self,
                       other_body,
                       force_full_computation=False,
                       **kwargs):
        """Compute the influence matrix of `self` on `other_body`.

        Parameters
        ----------
        other_body: FloatingBody
            the body interacting with `self`
        force_full_computation: boolean
            if True, do not use the symmetry (for debugging).
        """

        if other_body == self and not force_full_computation:
            # Use symmetry to speed up the evaluation of the matrix
            LOG.debug(
                f"Evaluating matrix of {self.name} on itself using rotation symmetry."
            )

            S_list, V_list = [], []
            for body in self.subbodies[:self.nb_subbodies // 2 + 1]:
                S, V = self.subbodies[0].build_matrices(body, **kwargs)
                S_list.append(S)
                V_list.append(V)

            if self.nb_subbodies % 2 == 0:
                return BlockCirculantMatrix(
                    S_list, size=self.nb_subbodies), BlockCirculantMatrix(
                        V_list, size=self.nb_subbodies)
            else:
                return BlockCirculantMatrix(
                    S_list, size=self.nb_subbodies), BlockCirculantMatrix(
                        V_list, size=self.nb_subbodies)

        else:
            return CollectionOfFloatingBodies.build_matrices(
                self, other_body, **kwargs)
Пример #3
0
    def build_matrices(self,
                       other_body,
                       force_full_computation=False,
                       **kwargs):
        """Compute the influence matrix of `self` on `other_body`.

        Parameters
        ----------
        body: FloatingBody
            the body interacting with `self`
        force_full_computation: boolean
            if True, do not use the symmetry (for debugging).
        """

        if (isinstance(other_body, TranslationalSymmetry)
                and np.allclose(other_body.translation, self.translation)
                and other_body.nb_subbodies == self.nb_subbodies
                and not force_full_computation):
            # Use symmetry to speed up the evaluation of the matrix
            if other_body == self:
                LOG.debug(
                    f"Evaluating matrix of {self.name} on itself using translation symmetry."
                )
            else:
                LOG.debug(
                    f"Evaluating matrix of {self.name} on {other_body.name} itself using translation symmetry."
                )

            S_list, V_list = [], []
            for body in other_body.subbodies:
                S, V = self.subbodies[0].build_matrices(body, **kwargs)
                S_list.append(S)
                V_list.append(V)
            return BlockToeplitzMatrix(S_list), BlockToeplitzMatrix(V_list)

        else:
            return CollectionOfFloatingBodies.build_matrices(
                self, other_body, **kwargs)