Skip to content

Commit

Permalink
Massively lower some IDA solver tolerances.
Browse files Browse the repository at this point in the history
ida_02 presently fails with a numdiff difference of about 1e-6: this makes sense
since that's the provided solver tolerance. We can get consistent results by
making it a few orders of magnitude lower.
  • Loading branch information
drwells committed May 23, 2022
1 parent a56c2ee commit 311287a
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 115 deletions.
9 changes: 4 additions & 5 deletions tests/sundials/ida_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class HarmonicOscillator
, A(2, 2)
, Jinv(2, 2)
, kappa(_kappa)
, out("output")
{
using VectorType = Vector<double>;

Expand Down Expand Up @@ -117,8 +116,8 @@ class HarmonicOscillator
const VectorType & sol,
const VectorType & sol_dot,
const unsigned int step_number) -> int {
out << t << ' ' << sol[0] << ' ' << sol[1] << ' ' << sol_dot[0] << ' '
<< sol_dot[1] << std::endl;
deallog << t << ' ' << sol[0] << ' ' << sol[1] << ' ' << sol_dot[0] << ' '
<< sol_dot[1] << std::endl;
return 0;
};
}
Expand All @@ -139,8 +138,6 @@ class HarmonicOscillator
FullMatrix<double> A;
FullMatrix<double> Jinv;
double kappa;

std::ofstream out;
};


Expand All @@ -149,6 +146,8 @@ main(int argc, char **argv)
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(
argc, argv, numbers::invalid_unsigned_int);
mpi_initlog();
deallog << std::setprecision(10);

SUNDIALS::IDA<Vector<double>>::AdditionalData data;
ParameterHandler prm;
Expand Down
34 changes: 34 additions & 0 deletions tests/sundials/ida_01.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

DEAL::0.000000000 0.000000000 1.000000000 1.000000000 0.000000000
DEAL::0.2000000000 0.1986693306 0.9800665773 0.9800665770 -0.1986693330
DEAL::0.4000000000 0.3894183419 0.9210609931 0.9210609922 -0.3894183442
DEAL::0.6000000000 0.5646424726 0.8253356137 0.8253356127 -0.5646424742
DEAL::0.8000000000 0.7173560896 0.6967067080 0.6967067063 -0.7173560914
DEAL::1.000000000 0.8414709829 0.5403023046 0.5403023026 -0.8414709843
DEAL::1.200000000 0.9320390834 0.3623577534 0.3623577521 -0.9320390840
DEAL::1.400000000 0.9854497269 0.1699671423 0.1699671398 -0.9854497274
DEAL::1.600000000 0.9995735994 -0.02919952231 -0.02919952456 -0.9995735995
DEAL::1.800000000 0.9738476269 -0.2272020939 -0.2272020963 -0.9738476265
DEAL::2.000000000 0.9092974227 -0.4161468348 -0.4161468372 -0.9092974217
DEAL::2.200000000 0.8084963997 -0.5885011145 -0.5885011162 -0.8084963987
DEAL::2.400000000 0.6754631768 -0.7373937117 -0.7373937135 -0.6754631750
DEAL::2.600000000 0.5155013686 -0.8568887485 -0.8568887499 -0.5155013666
DEAL::2.800000000 0.3349881478 -0.9422223349 -0.9422223355 -0.3349881464
DEAL::3.000000000 0.1411200068 -0.9899924900 -0.9899924905 -0.1411200044
DEAL::3.200000000 -0.05837414331 -0.9982947687 -0.9982947687 0.05837414560
DEAL::3.400000000 -0.2555411004 -0.9667981852 -0.9667981850 0.2555411014
DEAL::3.600000000 -0.4425204401 -0.8967584090 -0.8967584080 0.4425204424
DEAL::3.800000000 -0.6118578861 -0.7909677050 -0.7909677039 0.6118578878
DEAL::4.000000000 -0.7568024889 -0.6536436148 -0.6536436130 0.7568024906
DEAL::4.200000000 -0.8715757645 -0.4902608164 -0.4902608143 0.8715757658
DEAL::4.400000000 -0.9516020648 -0.3073328666 -0.3073328650 0.9516020654
DEAL::4.600000000 -0.9936909936 -0.1121525253 -0.1121525228 0.9936909940
DEAL::4.800000000 -0.9961645982 0.08749898300 0.08749898532 0.9961645981
DEAL::5.000000000 -0.9589242639 0.2836621828 0.2836621839 0.9589242637
DEAL::5.200000000 -0.8834546453 0.4685166664 0.4685166687 0.8834546443
DEAL::5.400000000 -0.7727644780 0.6346928688 0.6346928705 0.7727644768
DEAL::5.600000000 -0.6312666296 0.7755658693 0.7755658710 0.6312666278
DEAL::5.800000000 -0.4646021729 0.8855195059 0.8855195072 0.4646021708
DEAL::6.000000000 -0.2794154939 0.9601702741 0.9601702747 0.2794154923
DEAL::6.200000000 -0.08308940102 0.9965420835 0.9965420838 0.08308939852
DEAL::6.300000000 0.01681390092 0.9998586225 0.9998586225 -0.01681390017
33 changes: 0 additions & 33 deletions tests/sundials/ida_01.with_sundials.geq.4.0.0.output

This file was deleted.

33 changes: 0 additions & 33 deletions tests/sundials/ida_01.with_sundials.le.4.0.0.output

This file was deleted.

10 changes: 5 additions & 5 deletions tests/sundials/ida_01_in.prm
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ set Final time = 6.3
set Initial time = 0
set Time interval between each output = 0.2
subsection Error control
set Absolute error tolerance = 1e-6
set Absolute error tolerance = 1e-10
set Ignore algebraic terms for error computations = true
set Relative error tolerance = 1e-5
set Relative error tolerance = 1e-10
end
subsection Initial condition correction parameters
set Correction type at initial time = none
set Correction type after restart = none
set Maximum number of nonlinear iterations = 5
set Maximum number of nonlinear iterations = 10
end
subsection Running parameters
set Initial step size = 0.1
set Initial step size = 1e-6
set Maximum number of nonlinear iterations = 10
set Maximum order of BDF = 5
set Minimum step size = 0.000001
set Minimum step size = 1e-7
end
15 changes: 9 additions & 6 deletions tests/sundials/ida_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class HarmonicOscillator
, A(2, 2)
, Jinv(2, 2)
, kappa(_kappa)
, out("output")
{
using VectorType = Vector<double>;

Expand Down Expand Up @@ -104,7 +103,7 @@ class HarmonicOscillator
time_stepper.solve_with_jacobian = [&](const VectorType &src,
VectorType & dst,
const double tolerance) -> int {
SolverControl solver_control(1000, tolerance);
SolverControl solver_control(1000, tolerance, false, false);
SolverGMRES<Vector<double>> solver(solver_control);
solver.solve(J, dst, src, PreconditionIdentity());
return 0;
Expand All @@ -114,8 +113,8 @@ class HarmonicOscillator
const VectorType & sol,
const VectorType & sol_dot,
const unsigned int step_number) -> int {
out << t << ' ' << sol[0] << ' ' << sol[1] << ' ' << sol_dot[0] << ' '
<< sol_dot[1] << std::endl;
deallog << t << ' ' << sol[0] << ' ' << sol[1] << ' ' << sol_dot[0] << ' '
<< sol_dot[1] << std::endl;
return 0;
};
}
Expand All @@ -136,16 +135,20 @@ class HarmonicOscillator
FullMatrix<double> A;
FullMatrix<double> Jinv;
double kappa;

std::ofstream out;
};


int
main(int argc, char **argv)
{
#ifdef DEAL_II_WITH_MPI
Utilities::MPI::MPI_InitFinalize mpi_initialization(
argc, argv, numbers::invalid_unsigned_int);
mpi_initlog();
#else
initlog();
#endif
deallog << std::setprecision(10);

SUNDIALS::IDA<Vector<double>>::AdditionalData data;
ParameterHandler prm;
Expand Down
67 changes: 34 additions & 33 deletions tests/sundials/ida_02.with_sundials.geq.4.0.0.output
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
0 0 1 1 0
0.2 0.198666 0.98005 0.980056 -0.198635
0.4 0.389414 0.92105 0.921063 -0.3894
0.6 0.564639 0.825325 0.825346 -0.564653
0.8 0.717354 0.696694 0.696713 -0.717367
1 0.841469 0.540288 0.540295 -0.841478
1.2 0.932034 0.362343 0.362339 -0.932034
1.4 0.985441 0.169954 0.169952 -0.985442
1.6 0.999562 -0.0292108 -0.0292135 -0.999563
1.8 0.973833 -0.227211 -0.227214 -0.973833
2 0.909281 -0.416152 -0.416155 -0.909281
2.2 0.808479 -0.588503 -0.588506 -0.808478
2.4 0.675445 -0.737392 -0.737394 -0.675443
2.6 0.515484 -0.856883 -0.856885 -0.515482
2.8 0.334972 -0.942213 -0.942214 -0.334969
3 0.141106 -0.989979 -0.98998 -0.141103
3.2 -0.0583858 -0.998279 -0.998279 0.0583887
3.4 -0.255549 -0.966779 -0.966779 0.255552
3.6 -0.442525 -0.896738 -0.896737 0.442528
3.8 -0.611858 -0.790946 -0.790945 0.61186
4 -0.756798 -0.653622 -0.65362 0.7568
4.2 -0.871566 -0.49024 -0.490238 0.871568
4.4 -0.951588 -0.307314 -0.307312 0.95159
4.6 -0.993674 -0.112137 -0.112134 0.993674
4.8 -0.996144 0.0875108 0.0875137 0.996144
5 -0.958901 0.28367 0.283673 0.958901
5.2 -0.88343 0.468519 0.468522 0.883429
5.4 -0.772739 0.63469 0.634693 0.772738
5.6 -0.631242 0.775558 0.77556 0.63124
5.8 -0.464579 0.885506 0.885508 0.464577
6 -0.279395 0.960152 0.960154 0.279393
6.2 -0.0830731 0.99652 0.996521 0.0830703
6.3 0.016828 0.999835 0.999835 -0.0168267

DEAL::0.000000000 0.000000000 1.000000000 1.000000000 0.000000000
DEAL::0.2000000000 0.1986693306 0.9800665773 0.9800665770 -0.1986693330
DEAL::0.4000000000 0.3894183419 0.9210609931 0.9210609922 -0.3894183442
DEAL::0.6000000000 0.5646424726 0.8253356137 0.8253356127 -0.5646424742
DEAL::0.8000000000 0.7173560896 0.6967067080 0.6967067063 -0.7173560914
DEAL::1.000000000 0.8414709829 0.5403023046 0.5403023026 -0.8414709843
DEAL::1.200000000 0.9320390834 0.3623577534 0.3623577521 -0.9320390840
DEAL::1.400000000 0.9854497269 0.1699671423 0.1699671398 -0.9854497274
DEAL::1.600000000 0.9995735994 -0.02919952231 -0.02919952456 -0.9995735995
DEAL::1.800000000 0.9738476269 -0.2272020939 -0.2272020963 -0.9738476265
DEAL::2.000000000 0.9092974227 -0.4161468348 -0.4161468372 -0.9092974217
DEAL::2.200000000 0.8084963997 -0.5885011145 -0.5885011162 -0.8084963987
DEAL::2.400000000 0.6754631768 -0.7373937117 -0.7373937135 -0.6754631750
DEAL::2.600000000 0.5155013686 -0.8568887485 -0.8568887499 -0.5155013666
DEAL::2.800000000 0.3349881478 -0.9422223349 -0.9422223355 -0.3349881464
DEAL::3.000000000 0.1411200068 -0.9899924900 -0.9899924905 -0.1411200044
DEAL::3.200000000 -0.05837414331 -0.9982947687 -0.9982947687 0.05837414560
DEAL::3.400000000 -0.2555411004 -0.9667981852 -0.9667981850 0.2555411014
DEAL::3.600000000 -0.4425204401 -0.8967584090 -0.8967584080 0.4425204424
DEAL::3.800000000 -0.6118578861 -0.7909677050 -0.7909677039 0.6118578878
DEAL::4.000000000 -0.7568024889 -0.6536436148 -0.6536436130 0.7568024906
DEAL::4.200000000 -0.8715757645 -0.4902608164 -0.4902608143 0.8715757658
DEAL::4.400000000 -0.9516020648 -0.3073328666 -0.3073328650 0.9516020654
DEAL::4.600000000 -0.9936909936 -0.1121525253 -0.1121525228 0.9936909940
DEAL::4.800000000 -0.9961645982 0.08749898300 0.08749898532 0.9961645981
DEAL::5.000000000 -0.9589242639 0.2836621828 0.2836621839 0.9589242637
DEAL::5.200000000 -0.8834546453 0.4685166664 0.4685166687 0.8834546443
DEAL::5.400000000 -0.7727644780 0.6346928688 0.6346928705 0.7727644768
DEAL::5.600000000 -0.6312666296 0.7755658693 0.7755658710 0.6312666278
DEAL::5.800000000 -0.4646021729 0.8855195059 0.8855195072 0.4646021708
DEAL::6.000000000 -0.2794154939 0.9601702741 0.9601702747 0.2794154923
DEAL::6.200000000 -0.08308940102 0.9965420835 0.9965420838 0.08308939852
DEAL::6.300000000 0.01681390092 0.9998586225 0.9998586225 -0.01681390017

0 comments on commit 311287a

Please sign in to comment.