# Invariant error plot for an arbitray system of ODE

i try to use InvariantErrorPlot command for a generic system of ODE but i find only example with pre-building equations from Mathematica Packages. This is one of them:

Needs["DifferentialEquationsNDSolveProblems"];
Needs["DifferentialEquationsNDSolveUtilities"];
system = GetNDSolveProblem["PerturbedKepler"]
vars = system["DependentVariables"]
H = system["Invariants"]
time = {T, 0, 290};
step = 1/25;
Met = {"SymplecticPartitionedRungeKutta", "DifferenceOrder" -> 10,
"PositionVariables" -> {Subscript[Y, 1][T], Subscript[Y, 2][T]}};
sol = NDSolve[system, time, Method -> Met, StartingStepSize -> step,
MaxSteps -> Infinity];
ParametricPlot[
Evaluate[{Subscript[Y, 1][T], Subscript[Y, 2][T]} /. sol],
Evaluate[time]]
InvariantErrorPlot[H, vars, T, sol, PlotStyle -> {Blue, Red}]

Now the question is simple: can I modify it to use InvariantErrorPlot for my equations? And if so, how?

Thanks a lot.

-

Just spelunking a little I got this for the harmonic oscillator problem:

eqs = {y[1]'[T] == y[2][T], y[2]'[T] == -y[1][T]};
iniconds = {y[1][0] == 1, y[2][0] == 0};
invariants = {1/2 (y[1][T]^2 + y[2][T]^2)};
vars = {y[1][T], y[2][T]};
system = {eqs, iniconds, vars, {T, 0, 10}, {}, invariants, {}};
erksol = NDSolve[NDSolveProblem@system, Method -> "ExplicitRungeKutta"];
InvariantErrorPlot[invariants, vars, T, erksol]

The two empty lists on the system definition requires some more work to find out what they are.

-
thanks a lot, this is a very good starting point for me ! –  Panichi Pattumeros PapaCastoro Mar 12 at 0:26