commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r590749 - in /commons/proper/math/trunk/src/test/org/apache/commons/math/ode: DormandPrince54IntegratorTest.java GraggBulirschStoerIntegratorTest.java
Date Wed, 31 Oct 2007 16:54:51 GMT
Author: luc
Date: Wed Oct 31 09:54:48 2007
New Revision: 590749

URL: http://svn.apache.org/viewvc?rev=590749&view=rev
Log:
improved test coverage

Modified:
    commons/proper/math/trunk/src/test/org/apache/commons/math/ode/DormandPrince54IntegratorTest.java
    commons/proper/math/trunk/src/test/org/apache/commons/math/ode/GraggBulirschStoerIntegratorTest.java

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/ode/DormandPrince54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/ode/DormandPrince54IntegratorTest.java?rev=590749&r1=590748&r2=590749&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/ode/DormandPrince54IntegratorTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/ode/DormandPrince54IntegratorTest.java
Wed Oct 31 09:54:48 2007
@@ -143,14 +143,20 @@
       double scalAbsoluteTolerance = Math.pow(10.0, i);
       double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
 
-      FirstOrderIntegrator integ = new DormandPrince54Integrator(minStep, maxStep,
-                                                                 scalAbsoluteTolerance,
-                                                                 scalRelativeTolerance);
+      RungeKuttaFehlbergIntegrator integ =
+          new DormandPrince54Integrator(minStep, maxStep,
+                                        scalAbsoluteTolerance, scalRelativeTolerance);
       TestProblemHandler handler = new TestProblemHandler(pb);
+      integ.setSafety(0.8);
+      integ.setMaxGrowth(5.0);
+      integ.setMinReduction(0.3);
       integ.setStepHandler(handler);
       integ.integrate(pb,
                       pb.getInitialTime(), pb.getInitialState(),
                       pb.getFinalTime(), new double[pb.getDimension()]);
+      assertEquals(0.8, integ.getSafety(), 1.0e-12);
+      assertEquals(5.0, integ.getMaxGrowth(), 1.0e-12);
+      assertEquals(0.3, integ.getMinReduction(), 1.0e-12);
 
       // the 0.7 factor is only valid for this test
       // and has been obtained from trial and error

Modified: commons/proper/math/trunk/src/test/org/apache/commons/math/ode/GraggBulirschStoerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/org/apache/commons/math/ode/GraggBulirschStoerIntegratorTest.java?rev=590749&r1=590748&r2=590749&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/org/apache/commons/math/ode/GraggBulirschStoerIntegratorTest.java
(original)
+++ commons/proper/math/trunk/src/test/org/apache/commons/math/ode/GraggBulirschStoerIntegratorTest.java
Wed Oct 31 09:54:48 2007
@@ -68,9 +68,9 @@
     throws DerivativeException, IntegratorException {
 
     try {
-      TestProblem1 pb  = new TestProblem1();
-      double minStep   = 0.1 * (pb.getFinalTime() - pb.getInitialTime());
-      double maxStep   = pb.getFinalTime() - pb.getInitialTime();
+      TestProblem5 pb  = new TestProblem5();
+      double minStep   = 0.1 * Math.abs(pb.getFinalTime() - pb.getInitialTime());
+      double maxStep   = Math.abs(pb.getFinalTime() - pb.getInitialTime());
       double[] vecAbsoluteTolerance = { 1.0e-20, 1.0e-21 };
       double[] vecRelativeTolerance = { 1.0e-20, 1.0e-21 };
 
@@ -123,6 +123,45 @@
 
     }
 
+  }
+
+  public void testIntegratorControls()
+  throws DerivativeException, IntegratorException {
+
+    TestProblem3 pb = new TestProblem3(0.999);
+    GraggBulirschStoerIntegrator integ =
+        new GraggBulirschStoerIntegrator(0, pb.getFinalTime() - pb.getInitialTime(),
+                1.0e-8, 1.0e-10);
+
+    double errorWithDefaultSettings = getMaxError(integ, pb);
+
+    // stability control
+    integ.setStabilityCheck(true, 2, 1, 0.99);
+    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    integ.setStabilityCheck(true, -1, -1, -1);
+
+    integ.setStepsizeControl(0.5, 0.99, 0.1, 2.5);
+    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    integ.setStepsizeControl(-1, -1, -1, -1);
+
+    integ.setOrderControl(10, 0.7, 0.95);
+    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    integ.setOrderControl(-1, -1, -1);
+
+    integ.setInterpolationControl(true, 3);
+    assertTrue(errorWithDefaultSettings < getMaxError(integ, pb));
+    integ.setInterpolationControl(true, -1);
+
+  }
+
+  private double getMaxError(FirstOrderIntegrator integrator, TestProblemAbstract pb)
+    throws DerivativeException, IntegratorException {
+      TestProblemHandler handler = new TestProblemHandler(pb);
+      integrator.setStepHandler(handler);
+      integrator.integrate(pb,
+                           pb.getInitialTime(), pb.getInitialState(),
+                           pb.getFinalTime(), new double[pb.getDimension()]);
+      return handler.getMaximalError();
   }
 
   public void testSwitchingFunctions()



Mime
View raw message