I want to add my own coordinate system to existing CoordinateChartData[All]
, which would mimic the standard functionality as much as possible. As a simple work example I would like first to define "Minkowski"
like coordinate system in 4D. In Descartes' (orthogonal) frame this only result in changing Euclidean metric to {1,-1,-1,-1} (or {-1,1,1,1}). What internal commands I should modify?
1 Answer
The current implementation of CoordinateChartData[ ] is based on {metricName, chartName} pair. Unfortunately at the moment only two types of metric are available "Euclidean" and "Sphere". Adding additional metric would be proper way, however it will require much more intervention into the internals. Therefore before considering the other way I first decided to use oxymoron construction chartInfo["Euclidean", "Minkowski"], which seems work after modification of a number internal variables. In my opinion Wolfram should consider possibility to allow user to add it's own chart in a legal way on his own risk, since "Minkowski" type metric is important in physics. Below I include modifications to internals. Before starting to modify we have to load CoordinateChartData definitions into the kernel, therefore we first execute CoordinateChartData[All].
CoordinateChartData[All];
SymbolicTensors`CoordinateChartDataDump`chartInfo["Euclidean",
"Minkowski"] := {"Metric" ->
Function[{dim, vars},
SymbolicTensors`Tensor[
IdentityMatrix[dim]*
Flatten[{-1,
Table[1, {dim - 1}]}], {SymbolicTensors`CotangentBasis@vars,
SymbolicTensors`CotangentBasis@vars}]],
"LeviCivitaConnect" -> "Zero", "RiemannTensor" -> "Zero",
"RepresentativeDimensions" :>
Range[SymbolicTensors`CoordinateChartDataDump`$DimensionsToShow],
"CoordinateRangeAssumptions" ->
Function[{dim, vars}, Apply[And, Map[Element[#, Reals] &, vars]]],
"AlternateCoordinateNames" ->
Function[{dim},
Switch[dim,
2 | 3, {SymbolicTensors`CoordinateChartDataDump`\
repeatedSubscripts["x", dim]}, _, {}]],
"StandardCoordinateNames" ->
Function[{dim},
Switch[dim, 1, {"x"}, 2, {"x", "y"}, 3, {"x", "y", "z"}, _,
SymbolicTensors`CoordinateChartDataDump`repeatedSubscripts["x",
dim]]]};
SymbolicTensors`CoordinateChartDataDump`$AllMetricChartPairs =
Flatten[{SymbolicTensors`CoordinateChartDataDump`$\
AllMetricChartPairs, {{"Euclidean", "Minkowski"}}}, 1];
AppendTo[SymbolicTensors`CoordinateChartDataDump`$\
AllowedNameOnlyCharts, "Minkowski"];
AppendTo[SymbolicTensors`CoordinateChartDataDump`$\
NameOnlyChartsImpliedDimensionRules, "Minkowski" -> 2];
Note that here I explicitly provide explicit dimension. So, in fact it is just 2D metric. Adding arbitrary dimensions requires more modifications.
SymbolicTensors`CoordinateChartDataDump`knownChartQ["Minkowski"] :=
True;
ds[curve_List, t_, chart_] := Module[{metric, tangent},
metric = CoordinateChartData[chart, "Metric", curve];
tangent = D[curve, t];
Sqrt[tangent . metric . tangent] \[DifferentialD]t
]
ds[{x[t], y[t]}, t, {"Minkowski"}]
Out[9]= [DifferentialD]t Sqrt[-Derivative[1][x][t]^2 + Derivative[1][y][t]^2]