Ask Your Question

# 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

/home/orca/SageMath/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__add__ (build/cythonized/sage/structure/element.c:10799)()
1229         cdef int cl = classify_elements(left, right)
1230         if HAVE_SAME_PARENT(cl):
-> 1231             return (<Element>left)._add_(right)
1232         # Left and right are Sage elements => use coercion model
1233         if BOTH_ARE_ELEMENT(cl):

/home/orca/SageMath/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.ModuleElement._add_ (build/cythonized/sage/structure/element.c:15170)()
2344     Generic element of a module.
2345     """
-> 2346     cpdef _add_(self, other):
2347         """
2348         Abstract addition method

/home/orca/SageMath/local/lib/python3.7/site-packages/sage/tensor/modules/free_module_tensor.py in _add_(self, other)
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

## 1 Answer

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  of this notebook for a concrete example of use.

more

## Comments

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?

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.

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

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...

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2020-04-26 23:59:37 +0200

Seen: 96 times

Last updated: Apr 27 '20