creating an action in sage manifold

174 views
Skip to first unread message

Zach Elgood

unread,
May 30, 2016, 11:31:14 AM5/30/16
to sage-support
Hello again,
Thank you very much for the previous help. Some of the research I do involves using actions to calculate things like the Euler Lagrange equations. I was wondering if this is possible to do in Sage. For example, if I had the Lagrangian

Nabla_mu(phi) Nabla^mu (phi)-m^2*phi^2

how would I go about constructing one? I tried simply defining it, but I keep getting the attribute 'sage.symbolic.expression.Expression' object has no attribute '_domain' when I try and take the covariant derivative of it.

Eric Gourgoulhon

unread,
May 30, 2016, 4:38:48 PM5/30/16
to sage-support
Hi,


Le lundi 30 mai 2016 17:31:14 UTC+2, Zach Elgood a écrit :
Hello again,
Thank you very much for the previous help. Some of the research I do involves using actions to calculate things like the Euler Lagrange equations. I was wondering if this is possible to do in Sage.

To my knowledge, no variational calculus is implemented in Sage yet. But this would be a nice project!
 
For example, if I had the Lagrangian

Nabla_mu(phi) Nabla^mu (phi)-m^2*phi^2

how would I go about constructing one? I tried simply defining it, but I keep getting the attribute 'sage.symbolic.expression.Expression' object has no attribute '_domain' when I try and take the covariant derivative of it.

A reason could be that phi has not been defined as a scalar field (i.e. as phi = M.scalar_field(...)), but merely as a symbolic expression. Is it the case?

Best wishes,

Eric.

Zach Elgood

unread,
May 30, 2016, 5:12:01 PM5/30/16
to sage-support
Thank you for your response. I haven't actually tried the example, as my expression is much more complex. However, let's say I want to take the covariant derivative of the following vector with respect to the Schwarzschild metric: (1-M/r)dt^2. How would one construct that to take a covariant derivative? 

Eric Gourgoulhon

unread,
May 31, 2016, 6:20:20 PM5/31/16
to sage-support
Hi,


Le lundi 30 mai 2016 23:12:01 UTC+2, Zach Elgood a écrit :
Thank you for your response. I haven't actually tried the example, as my expression is much more complex. However, let's say I want to take the covariant derivative of the following vector with respect to the Schwarzschild metric: (1-M/r)dt^2.

I am not sure to understand:  (1-M/r)dt^2 is not a vector...

How would one construct that to take a covariant derivative? 


Here is an example with the vector  d/dt + (-2*m/r + 1) d/dr :

sage: M = Manifold(4, 'M')
sage
: X.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
sage
: m = var('m'); assume(m>=0)
sage
: g = M.lorentzian_metric('g')
sage
: g[0,0], g[1,1] = -(1-2*m/r), 1/(1-2*m/r)
sage
: g[2,2], g[3,3] = r^2, (r*sin(th))^2
sage
: v = M.vector_field(name='v')
sage
: v[0], v[1] = 1, 1-2*m/r
sage
: v.display()
v
= d/dt + (-2*m/r + 1) d/dr
sage
: nabla = g.connection(); nabla
Levi-Civita connection nabla_g associated with the Lorentzian metric g on the 4-dimensional differentiable manifold M
sage
: nab_v = nabla(v); nab_v
Tensor field nabla_g(v) of type (1,1) on the 4-dimensional differentiable manifold M
sage
: nab_v.display()
nabla_g
(v) = m/r^2 d/dt*dt - m/(2*m*r - r^2) d/dt*dr - (2*m^2 - m*r)/r^3 d/dr*dt + m/r^2 d/dr*dr - (2*m - r)/r^2 d/dth*dth - (2*m - r)/r^2 d/dph*dph

Best wishes,

Eric.
Reply all
Reply to author
Forward
0 new messages