Added tests for derivatives consistency.
This commit is contained in:
parent
a961a2ec9c
commit
de90332490
|
@ -42,6 +42,7 @@ import org.apache.commons.math4.ode.events.Action;
|
|||
import org.apache.commons.math4.ode.events.FieldEventHandler;
|
||||
import org.apache.commons.math4.ode.sampling.FieldStepHandler;
|
||||
import org.apache.commons.math4.ode.sampling.FieldStepInterpolator;
|
||||
import org.apache.commons.math4.ode.sampling.StepInterpolatorTestUtils;
|
||||
import org.apache.commons.math4.util.FastMath;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.junit.Assert;
|
||||
|
@ -507,4 +508,14 @@ public abstract class AbstractRungeKuttaFieldIntegratorTest {
|
|||
Assert.assertEquals(8.0, result.getState()[0].getReal(), epsilon);
|
||||
}
|
||||
|
||||
@Test
|
||||
public abstract void testDerivativesConsistency();
|
||||
|
||||
protected <T extends RealFieldElement<T>> void doTestDerivativesConsistency(final Field<T> field, double epsilon) {
|
||||
TestFieldProblem3<T> pb = new TestFieldProblem3<T>(field);
|
||||
T step = pb.getFinalTime().subtract(pb.getInitialState().getTime()).multiply(0.001);
|
||||
RungeKuttaFieldIntegrator<T> integ = createIntegrator(field, step);
|
||||
StepInterpolatorTestUtils.checkDerivativesConsistency(integ, pb, 1.0e-10);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -91,4 +91,9 @@ public class ClassicalRungeKuttaFieldIntegratorTest extends AbstractRungeKuttaFi
|
|||
doTestUnstableDerivative(Decimal64Field.getInstance(), 1.0e-12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDerivativesConsistency() {
|
||||
doTestDerivativesConsistency(Decimal64Field.getInstance(), 1.0e-10);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,4 +92,9 @@ public class EulerFieldIntegratorTest extends AbstractRungeKuttaFieldIntegratorT
|
|||
doTestUnstableDerivative(Decimal64Field.getInstance(), 1.0e-12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDerivativesConsistency() {
|
||||
doTestDerivativesConsistency(Decimal64Field.getInstance(), 1.0e-10);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,12 +20,7 @@ package org.apache.commons.math4.ode.nonstiff;
|
|||
|
||||
import org.apache.commons.math4.Field;
|
||||
import org.apache.commons.math4.RealFieldElement;
|
||||
import org.apache.commons.math4.ode.FieldExpandableODE;
|
||||
import org.apache.commons.math4.ode.FieldODEState;
|
||||
import org.apache.commons.math4.ode.FieldODEStateAndDerivative;
|
||||
import org.apache.commons.math4.util.Decimal64Field;
|
||||
import org.apache.commons.math4.util.MathArrays;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GillFieldIntegratorTest extends AbstractRungeKuttaFieldIntegratorTest {
|
||||
|
@ -96,4 +91,9 @@ public class GillFieldIntegratorTest extends AbstractRungeKuttaFieldIntegratorTe
|
|||
doTestUnstableDerivative(Decimal64Field.getInstance(), 1.0e-12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDerivativesConsistency() {
|
||||
doTestDerivativesConsistency(Decimal64Field.getInstance(), 1.0e-10);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue