# metric perturbations on Sagemanifolds

I would like to carry out some metric perturbations within SageManifolds.

To that end, I have defined a 4-dimensional Lorentzian manifold N:

N = Manifold(4, 'N', latex_name=r'\mathcal{N}', structure='Lorentzian')


a global chart:

GC.<x0,x,y,z> = N.chart(r'x0:(-oo,+oo):x^0 x y z')


the corresponding frame eN:

eN = GC.frame()


the unperturbed metric g0:

g0 = N.metric('g0', latex_name=r'g_{(0)}')


the control parameter for the perturbation:

var('eps', latex_name=r'\epsilon', domain='real')


and the perturbation tensor field itself:

g1 = N.tensor_field(0, 2, name='g1', latex_name='g_{1}', sym=(0,1))


Up until here, everything seems to work fine and there are no errors or warnings. However, when I try to define the total perturbed metric, via:

g = g0 + eps*g1


the following error shows up:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-e785f6693878> in <module>()
----> 1 g = g0 + epsplus*g1plus
2 g

1229         cdef int cl = classify_elements(left, right)
1230         if HAVE_SAME_PARENT(cl):
1232         # Left and right are Sage elements => use coercion model
1233         if BOTH_ARE_ELEMENT(cl):

2344     Generic element of a module.
2345     """
2347         """

2090         basis = self.common_basis(other)
2091         if basis is None:
-> 2092             raise ValueError("no common basis for the addition")
2093         comp_result = self._components[basis] + other._components[basis]
2094         result = self._fmodule.tensor_from_comp(self._tensor_type, comp_result)

ValueError: no common basis for the addition


How is the correct way to define g as the sum of those 2 former tensor fields??? I have also tried

g[eN] = g0[eN] + epsplus*g1plus[eN]


but there is then:

Type Error: unhashable type: 'VectorFieldFreeModule_with_category.element_class'


and also:

g[eN,:] = g0[eN,:] + epsplus*g1plus[eN,:]


but then the error is:

ValueError: no basis could be found for computing the components in the Coordinate frame (N, (d/dx0,d/dx,d/dy,d/dz)).

edit retag close merge delete

Sort by » oldest newest most voted

The error is due to the fact that neither g0 nor g1 are initialized. They have simply been declared as a metric and a type (0,2) tensor field, but you should initialize their components in some vector frame, in order to fully define them.

Regarding perturbation of tensor fields, note that tensor series expansion have been introduced in Sage 8.8, see the changelog for details, in particular cell [25] of this notebook for a concrete example of use.

more

Dear Eric,

I get the difference between a plain declaration and an initialization; thanks. However, I would like to use, until a certain time, completely general expressions for the components (in the default frame, for instance), that is, arbitrary functions of all the coordinates. Is this feasible? If so, how?

( 2020-04-27 10:06:32 -0600 )edit

You can use function('A')(x0,x,y,z) to initialize some tensor components with an arbitrary function of the coordinates. NB: if you do this for all components, some computations, like the Riemann tensor, will become huge.

( 2020-04-27 11:00:54 -0600 )edit

I was thinking something along the lines of the package xPert (xAct) from Mathematica

( 2020-04-27 13:28:02 -0600 )edit

The currrent implementation of tensor calculus in SageMath does not deal with "abstract" tensors, as xAct does, i.e. tensor fields have to be defined by their components in a given frame (usually a coordinate frame). Adding abstract tensor calculus in SageMath could be a nice project, if there are volunteers...

( 2020-05-01 03:10:28 -0600 )edit