コード例 #1
0
    def lorentz_transform(self, transformation_matrix):
        """
        Performs a Lorentz transform on the tensor.

        Parameters
        ----------
            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
                Sympy Array or multi-dimensional list containing Sympy Expressions

        Returns
        -------
            ~einsteinpy.symbolic.metric.MetricTensor
                lorentz transformed tensor

        """
        t = super(MetricTensor, self).lorentz_transform(transformation_matrix)
        return MetricTensor(
            t.tensor(),
            syms=self.syms,
            config=self._config,
            name=_change_name(self.name, context="__lt"),
        )
コード例 #2
0
    def change_config(self, newconfig="lll", metric=None):
        """
        Changes the index configuration(contravariant/covariant)

        Parameters
        ----------
        newconfig : str
            Specify the new configuration. Defaults to 'lll'
        metric : ~einsteinpy.symbolic.metric.MetricTensor or None
            Parent metric tensor for changing indices.
            Already assumes the value of the metric tensor from which it was initialized if passed with None. 
            Compulsory if not initialized with 'from_metric'. Defaults to None.

        Returns
        -------
        ~einsteinpy.symbolic.christoffel.ChristoffelSymbols
            New tensor with new configuration. Defaults to 'lll'

        Raises
        ------
        Exception
            Raised when a parent metric could not be found.

        """
        if metric is None:
            metric = self._parent_metric
        if metric is None:
            raise Exception(
                "Parent Metric not found, can't do configuration change")
        new_tensor = _change_config(self, metric, newconfig)
        new_obj = ChristoffelSymbols(
            new_tensor,
            self.syms,
            config=newconfig,
            parent_metric=metric,
            name=_change_name(self.name, context="__" + newconfig),
        )
        return new_obj
コード例 #3
0
ファイル: tensor.py プロジェクト: yf-hang/einsteinpy
    def lorentz_transform(self, transformation_matrix):
        """
        Performs a Lorentz transform on the tensor.

        Parameters
        ----------
            transformation_matrix : ~sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray or list
                Sympy Array or multi-dimensional list containing Sympy Expressions

        Returns
        -------
            ~einsteinpy.symbolic.tensor.BaseRelativityTensor
                lorentz transformed tensor(or vector)

        """
        tm = sympy.Array(transformation_matrix)
        t = self.tensor()
        for i in range(self.order):
            if self.config[i] == "u":
                t = simplify(
                    tensorcontraction(tensorproduct(tm, t), (1, 2 + i)))
            else:
                t = simplify(
                    tensorcontraction(tensorproduct(tm, t), (0, 2 + i)))
            dest = list(range(len(t.shape)))
            dest.remove(0)
            dest.insert(i, 0)
            t = sympy.permutedims(t, dest)

        return BaseRelativityTensor(
            t,
            syms=self.syms,
            config=self.config,
            parent_metric=None,
            variables=self.variables,
            functions=self.functions,
            name=_change_name(self.name, context="__lt"),
        )
コード例 #4
0
    def change_config(self, newconfig="uu"):
        """
        Changes the index configuration(contravariant/covariant)

        Parameters
        ----------
        newconfig : str
            Specify the new configuration. Defaults to 'uu'

        Returns
        -------
        ~einsteinpy.symbolic.metric.MetricTensor
            New Metric with new configuration. Defaults to 'uu'

        Raises
        ------
        ValueError
            Raised when new configuration is not 'll' or 'uu'.
            This constraint is in place because we are dealing with Metric Tensor.

        """
        if newconfig == self.config:
            return self
        if newconfig == "uu" or newconfig == "ll":
            inv_met = MetricTensor(
                sympy.simplify(sympy.Matrix(self.arr.tolist()).inv()).tolist(),
                self.syms,
                config=newconfig,
                name=_change_name(self.name, context="__" + newconfig),
            )
            inv_met._invmetric = self
            return inv_met

        raise ValueError(
            "Configuration can't have one upper and one lower index in Metric Tensor."
        )
コード例 #5
0
def test_change_name(curr_name, context, expected):
    altered_name = _change_name(curr_name, context)
    assert altered_name == expected