Skip to content

Commit

Permalink
fixes 300: Field Butcher array based integrators usable with non-Fiel…
Browse files Browse the repository at this point in the history
…d coefficients (#306)
  • Loading branch information
Serrof authored Feb 11, 2024
1 parent b10fdf6 commit 6f142f9
Show file tree
Hide file tree
Showing 21 changed files with 942 additions and 412 deletions.
3 changes: 3 additions & 0 deletions hipparchus-ode/src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ If the output is not quite correct, check for invisible trailing spaces!
</properties>
<body>
<release version="3.1" date="TBD" description="TBD.">
<action dev="serrof" type="add" issue="issues/300">
Add possibility to use real coefficients for Butcher array based Field integrators.
</action>
<action dev="serrof" type="fix" issue="issues/290">
Fixes regressions with Field in event detection.
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ public T[] computeDerivatives(final T t, final T[] y)
return equations.computeDerivatives(t, y);
}

/** Increment evaluations of derivatives.
*
* @param nTimes number of evaluations to increment
*/
protected void incrementEvaluations(final int nTimes) {
evaluations.increment(nTimes);
}

/** Set the stateInitialized flag.
* <p>This method must be called by integrators with the value
* {@code false} before they start integration, so a proper lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ public double[] computeDerivatives(final double t, final double[] y)
return equations.computeDerivatives(t, y);
}

/** Increment evaluations of derivatives.
*
* @param nTimes number of evaluations to increment
*/
protected void incrementEvaluations(final int nTimes) {
evaluations.increment(nTimes);
}

/** Set the stateInitialized flag.
* <p>This method must be called by integrators with the value
* {@code false} before they start integration, so a proper lazy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public T[][] getA() {
for (int i = 0; i < a.length; ++i) {
a[i] = MathArrays.buildArray(getField(), i + 1);
}
a[0][0] = fraction(1, 2);
a[0][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 2);
a[1][0] = getField().getZero();
a[1][1] = a[0][0];
a[2][0] = getField().getZero();
Expand All @@ -94,8 +94,8 @@ public T[][] getA() {
@Override
public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 4);
b[0] = fraction(1, 6);
b[1] = fraction(1, 3);
b[0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 6);
b[1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 3);
b[2] = b[1];
b[3] = b[0];
return b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public DormandPrince54FieldIntegrator(final Field<T> field,
@Override
public T[] getC() {
final T[] c = MathArrays.buildArray(getField(), 6);
c[0] = fraction(1, 5);
c[1] = fraction(3, 10);
c[2] = fraction(4, 5);
c[3] = fraction(8, 9);
c[0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 5);
c[1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 3, 10);
c[2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(),4, 5);
c[3] = FieldExplicitRungeKuttaIntegrator.fraction(getField(),8, 9);
c[4] = getField().getOne();
c[5] = getField().getOne();
return c;
Expand All @@ -118,40 +118,40 @@ public T[][] getA() {
for (int i = 0; i < a.length; ++i) {
a[i] = MathArrays.buildArray(getField(), i + 1);
}
a[0][0] = fraction( 1, 5);
a[1][0] = fraction( 3, 40);
a[1][1] = fraction( 9, 40);
a[2][0] = fraction( 44, 45);
a[2][1] = fraction( -56, 15);
a[2][2] = fraction( 32, 9);
a[3][0] = fraction( 19372, 6561);
a[3][1] = fraction(-25360, 2187);
a[3][2] = fraction( 64448, 6561);
a[3][3] = fraction( -212, 729);
a[4][0] = fraction( 9017, 3168);
a[4][1] = fraction( -355, 33);
a[4][2] = fraction( 46732, 5247);
a[4][3] = fraction( 49, 176);
a[4][4] = fraction( -5103, 18656);
a[5][0] = fraction( 35, 384);
a[0][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 1, 5);
a[1][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 3, 40);
a[1][1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 9, 40);
a[2][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 44, 45);
a[2][1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), -56, 15);
a[2][2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 32, 9);
a[3][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 19372, 6561);
a[3][1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), -25360, 2187);
a[3][2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 64448, 6561);
a[3][3] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), -212, 729);
a[4][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 9017, 3168);
a[4][1] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), -355, 33);
a[4][2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 46732, 5247);
a[4][3] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 49, 176);
a[4][4] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), -5103, 18656);
a[5][0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 35, 384);
a[5][1] = getField().getZero();
a[5][2] = fraction( 500, 1113);
a[5][3] = fraction( 125, 192);
a[5][4] = fraction( -2187, 6784);
a[5][5] = fraction( 11, 84);
a[5][2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 500, 1113);
a[5][3] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 125, 192);
a[5][4] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), -2187, 6784);
a[5][5] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 11, 84);
return a;
}

/** {@inheritDoc} */
@Override
public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 7);
b[0] = fraction( 35, 384);
b[0] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 35, 384);
b[1] = getField().getZero();
b[2] = fraction( 500, 1113);
b[3] = fraction( 125, 192);
b[4] = fraction(-2187, 6784);
b[5] = fraction( 11, 84);
b[2] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 500, 1113);
b[3] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 125, 192);
b[4] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), -2187, 6784);
b[5] = FieldExplicitRungeKuttaIntegrator.fraction(getField(), 11, 84);
b[6] = getField().getZero();
return b;
}
Expand Down
Loading

0 comments on commit 6f142f9

Please sign in to comment.