differential_geometry.symbolic.compute_Lterm#

differential_geometry.symbolic.compute_Lterm(inverse_metric: ImmutableDenseMatrix | MutableDenseMatrix | ImmutableDenseNDimArray | MutableDenseNDimArray, metric_density: Basic, axes: Sequence[Symbol]) ImmutableDenseNDimArray[source]#

Compute the L-term components for a general or orthogonal coordinate system from the metric density \(\rho\) and the inverse metric \(g^{\mu\nu}\).

The Laplacian in curvilinear coordinates can be written as:

\[\nabla^2 \phi \;=\; \frac{1}{\rho} \,\partial_\mu\!\Bigl(\rho\, g^{\mu\nu}\,\partial_\nu \phi\Bigr) \;=\; L^\nu \,\partial_\nu \phi \;+\; g^{\mu\nu}\,\partial^2_{\mu\nu} \phi,\]

where the L-term is:

\[L^\nu \;=\; \frac{1}{\rho}\,\partial_\mu\,\bigl(\rho\,g^{\mu\nu}\bigr).\]

Usage:

  • If inverse_metric is a full \((n{\times}n)\) matrix, the standard formula for \(\partial_\mu(\rho\,g^{\mu\nu})\) is used (summing over \(\mu\)).

  • If inverse_metric is a 1D array of length \(n\), we assume an orthogonal system, and use the diagonal simplification:

    \[L^\nu \;=\;\frac{1}{\rho}\,\partial_\nu\!\Bigl(\rho\,g^{\nu\nu}\Bigr).\]
Parameters:
  • inverse_metric (MutableDenseMatrix or MutableDenseNDimArray) – Either a full inverse metric \(g^{\mu\nu}\) (shape (n, n)) or a 1D diagonal array of shape (n,) for orthogonal coordinates.

  • metric_density (Basic) – The metric density \(\rho = \sqrt{\det g}\).

  • axes (list of Symbol) – The coordinate variables, \(x^\mu\).

Returns:

A 1D array of L-term components \(L^\nu\).

Return type:

MutableDenseNDimArray

See also

compute_Dterm

D-term used in divergence

compute_metric_density

For obtaining \(\rho\)

Examples

1) Full Inverse Metric

Spherical coordinates, with \(g_{\mu\nu} = \mathrm{diag}\bigl(1,\;r^2,\;r^2\,\sin^2\theta\bigr)\):

>>> import sympy as sp
>>> from pymetric.differential_geometry.symbolic import compute_Lterm
>>> r, theta, phi = sp.symbols('r theta phi')
>>> rho = r**2*sp.sin(theta)  # metric density
>>> g_inv = sp.Matrix([       # full inverse metric
...     [1,     0,                   0],
...     [0, 1/r**2,                0],
...     [0,     0, 1/(r**2*sp.sin(theta)**2)]
... ])
>>> L = compute_Lterm(g_inv, rho, [r,theta,phi])
>>> L
[2/r, 1/(r**2*tan(theta)), 0]

2) Orthogonal (Diagonal) Inverse Metric

Provide just the diagonal as a 1D array:

>>> g_inv_diag = sp.Array([1, 1/r**2, 1/(r**2*sp.sin(theta)**2)])
>>> L_orth = compute_Lterm(g_inv_diag, rho, [r,theta,phi])
>>> L_orth
[2/r, 1/(r**2*tan(theta)), 0]