예제 #1
0
파일: ricci.py 프로젝트: ycs0405/einsteinpy
    def from_riemann(cls, riemann, parent_metric=None):
        """
        Get Ricci Tensor calculated from Riemann Tensor

        Parameters
        ----------
        riemann : ~einsteinpy.symbolic.riemann.RiemannCurvatureTensor
           Riemann Tensor
        parent_metric : ~einsteinpy.symbolic.metric.MetricTensor or None
            Corresponding Metric for the Ricci Tensor.
            None if it should inherit the Parent Metric of Riemann Tensor.
            Defaults to None.

        """
        if not riemann.config == "ulll":
            riemann = riemann.change_config(newconfig="ulll",
                                            metric=parent_metric)
        if parent_metric is None:
            parent_metric = riemann.parent_metric
        return cls(
            simplify_sympy_array(
                sympy.tensorcontraction(riemann.tensor(), (0, 2))),
            riemann.syms,
            config="ll",
            parent_metric=parent_metric,
        )
예제 #2
0
파일: ricci.py 프로젝트: ycs0405/einsteinpy
    def from_riccitensor(cls, riccitensor, parent_metric=None):
        """
        Get Ricci Scalar calculated from Ricci Tensor

        Parameters
        ----------
        riccitensor: ~einsteinpy.symbolic.metric.RicciTensor
            Ricci Tensor
        parent_metric : ~einsteinpy.symbolic.metric.MetricTensor or None
            Corresponding Metric for the Ricci Scalar.
            Defaults to None.

        """

        if not riccitensor.config == "ul":
            riccitensor = riccitensor.change_config(newconfig="ul",
                                                    metric=parent_metric)
        if parent_metric is None:
            parent_metric = riccitensor.parent_metric
        ricci_scalar = tensorcontraction(riccitensor.tensor(), (0, 1))
        return cls(
            simplify_sympy_array(ricci_scalar),
            riccitensor.syms,
            parent_metric=parent_metric,
        )
예제 #3
0
    def simplify(self, set_self=True):
        """
        Returns a simplified Tensor

        Parameters
        ----------
        set_self : bool
            Replaces the tensor contained the class with its simplified version, if ``True``.
            Defaults to ``True``.

        Returns
        -------
        ~einsteinpy.symbolic.tensor.Tensor
            Simplified Tensor

        """
        if set_self:
            self.arr = simplify_sympy_array(self.tensor())
            return self.tensor()
        # return sympy.simplify(self.tensor())  # this used to work with older sympy versions
        return simplify_sympy_array(self.tensor())