# How to add new coordinate chart?

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?

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];

SymbolicTensorsCoordinateChartDataDumpchartInfo["Euclidean",
"Minkowski"] := {"Metric" ->
Function[{dim, vars},
SymbolicTensorsTensor[
IdentityMatrix[dim]*
Flatten[{-1,
Table[1, {dim - 1}]}], {SymbolicTensorsCotangentBasis@vars,
SymbolicTensorsCotangentBasis@vars}]],
"LeviCivitaConnect" -> "Zero", "RiemannTensor" -> "Zero",
"RepresentativeDimensions" :>
Range[SymbolicTensorsCoordinateChartDataDump$DimensionsToShow], "CoordinateRangeAssumptions" -> Function[{dim, vars}, Apply[And, Map[Element[#, Reals] &, vars]]], "AlternateCoordinateNames" -> Function[{dim}, Switch[dim, 2 | 3, {SymbolicTensorsCoordinateChartDataDump\ repeatedSubscripts["x", dim]}, _, {}]], "StandardCoordinateNames" -> Function[{dim}, Switch[dim, 1, {"x"}, 2, {"x", "y"}, 3, {"x", "y", "z"}, _, SymbolicTensorsCoordinateChartDataDumprepeatedSubscripts["x", dim]]]}; SymbolicTensorsCoordinateChartDataDump$$AllMetricChartPairs = Flatten[{SymbolicTensorsCoordinateChartDataDump$$\ AllMetricChartPairs, {{"Euclidean", "Minkowski"}}}, 1]; AppendTo[SymbolicTensorsCoordinateChartDataDump$\
AllowedNameOnlyCharts, "Minkowski"];

AppendTo[SymbolicTensorsCoordinateChartDataDump\$\
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.

SymbolicTensorsCoordinateChartDataDumpknownChartQ["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= [DifferentialD]t Sqrt[-Derivative[x][t]^2 + Derivative[y][t]^2]