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