Skip to content

Commit

Permalink
Wire up Hstart in the IVP API
Browse files Browse the repository at this point in the history
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
  • Loading branch information
lamont-granquist committed Aug 28, 2023
1 parent e69fdfd commit 4287b09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions MechJeb2/MechJebLib/Core/ODE/AbstractIVP.cs
Expand Up @@ -19,7 +19,6 @@ namespace MechJebLib.Core.ODE
// TODO:
// - Needs better MinStep based on next floating point number
// - Configurable to throw or just continue at MinStep
// - Needs better initial step guessing
// - Needs working event API
public abstract class AbstractIVP
{
Expand Down Expand Up @@ -51,7 +50,7 @@ public abstract class AbstractIVP
/// <summary>
/// Starting step-size (can be zero for automatic guess).
/// </summary>
public double Hstart { get; set; }
public double Hstart { get; set; } = 0.0;

/// <summary>
/// Interpolants are pulled on an evenly spaced grid
Expand Down Expand Up @@ -136,7 +135,7 @@ private double EventFuncWrapper(double x, object? o)

f(Y, T, Dy);

Habs = SelectInitialStep(f, T, Y, Dy, Direction);
Habs = Hstart > 0 ? Hstart : SelectInitialStep(f, T, Y, Dy, Direction);

interpolant?.Add(T, Y, Dy);

Expand Down Expand Up @@ -264,10 +263,10 @@ private int FillInterpolant(IVPFunc f, double t0, double tf, Hn interpolant, int
}

protected abstract (double, double) Step(IVPFunc f);
protected abstract double SelectInitialStep(IVPFunc f, double t0, IReadOnlyList<double> y0, IReadOnlyList<double> f0, int direction);
protected abstract void InitInterpolant();
protected abstract void Interpolate(double x, Vn yout);
protected abstract void Init();
protected abstract void Cleanup();
protected abstract double SelectInitialStep(IVPFunc f, double t0, IReadOnlyList<double> y0, IReadOnlyList<double> f0, int direction);
protected abstract void InitInterpolant();
protected abstract void Interpolate(double x, Vn yout);
protected abstract void Init();
protected abstract void Cleanup();
}
}
2 changes: 1 addition & 1 deletion MechJebLibTest/Maneuvers/ReturnFromMoonTests.cs
Expand Up @@ -24,7 +24,7 @@ private void NextManeuverToReturnFromMoonTest()
// this forces JIT compilation(?) of the SQL solver which takes ~250ms
ChangeOrbitalElement.ChangePeriapsis(1.0, new V3(1, 0, 0), new V3(0, 1.0, 0), 1.0);

Logger.Register(o => _testOutputHelper.WriteLine((string)o));
//Logger.Register(o => _testOutputHelper.WriteLine((string)o));
double centralMu = 398600435436096;
double moonMu = 4902800066163.8;
var moonR0 = new V3(325420116.073166, -166367503.579338, -138858150.96145);
Expand Down

0 comments on commit 4287b09

Please sign in to comment.