On Wed, Oct 14, 2015 at 3:25 PM, Ondřej Čertík <[email protected]> wrote: > Hi Imran, > > On Wed, Oct 14, 2015 at 10:14 AM, Imran Ali <[email protected]> wrote: >> I have implemented a SymPy program that can calculate the Riemann curvature >> tensor for a given curve element. However, I am encountering problems >> solving for the case when the curve element is the surface of a sphere >> >> \begin{align} >> ds^2 = r^2d\theta^2 + r^2 \sin^2\theta d\phi^2 >> \end{align} >> >> This is obviously a 2D curve element, so the non-zero elements of the metric >> become >> \begin{align} >> g_{11} = r^2, \qquad g_{22} = r^2 \sin^2\theta. >> \end{align} >> The entries of metric are clearly a function of two variables $r$ and >> $\theta$. But the way I have created the program it treats them according to >> their differentials $d\theta$ and $d\phi$. Since $dr$ is 'zero', my metric >> is computed as >> \begin{align} >> \begin{bmatrix} >> 0 &0 &0\\ >> 0 &r^2 &0\\ >> 0 &0 &r^2 \sin^2\theta >> \end{bmatrix}. >> \end{align} >> The way I have coded my implementation is by asking the user for the metric >> defined as a matrix. If the matrix is 2D, then I use $u$,$v$ to represent >> the coordinates. Which in the 2D case assign $r$ as $u$ and $\theta$ as $v$. >> For 3D (with metric above), the additional value $\phi$ is assigned $w$. > > If your space/surface is only 2D, then the metric tensor is a 2x2 > matrix, I think it's just: > > [r^2, 0] > [0, r^2 sin^2(theta)] > > And that's what you need to feed into your program. Then things should > work. If you have a zero entry in the 3x3 metrix tensor, then the > coordinates are degenerate, and I guess your code can't handle it.
Ok, looks like somebody there already gave you an essentially identical answer: http://physics.stackexchange.com/a/212571/6396 Ondrej > >> >> Does anyone see my dilemma here? For 3D, I am basically trying to calculate >> the Riemann tensor for a metric with the determinant equal to zero. And for >> 2D, the $\phi$ component does not even exist. >> >> This element is important for me to test my code as this generates a >> non-zero Riemann curvature tensor. I would really appreciate any suggestions >> how I can handle this case and thereby improve my code....which fails >> completely for this case. >> >> (I posted the exact post at physics on stackexchange : >> http://physics.stackexchange.com/questions/212541/finding-the-riemann-tensor-for-the-surface-of-a-sphere-with-sympy-diffgeom#212541 >> , and they gently directed my here. I have posted the code on pastebin : >> http://pastebin.com/DPxW38L0 - the problem lies in the way I have defined >> the constructor for Riemann class) > > If you want to look at a working code in 4D, look here: > > https://github.com/sympy/sympy/blob/master/examples/advanced/relativity.py > > Then you can adapt it for a 2D case. > > Ondrej -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CADDwiVA0u_uhmuMjAtQ3EFfY%3DpkOgmokGfEUJx4HGwMSOD22sw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
