diff --git a/CMakeLists.txt b/CMakeLists.txt index 06536d057..de92e4a9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.18.4) include(config/petscCompilers.cmake) # Set the project details -project(ablateLibrary VERSION 0.12.34) +project(ablateLibrary VERSION 0.12.35) # Load the Required 3rd Party Libaries pkg_check_modules(PETSc REQUIRED IMPORTED_TARGET GLOBAL PETSc) diff --git a/src/eos/zerork/sourceCalculatorZeroRK.cpp b/src/eos/zerork/sourceCalculatorZeroRK.cpp index ad7795f3e..98de51c63 100644 --- a/src/eos/zerork/sourceCalculatorZeroRK.cpp +++ b/src/eos/zerork/sourceCalculatorZeroRK.cpp @@ -246,33 +246,42 @@ void ablate::eos::zerorkeos::SourceCalculator::ComputeSource(const ablate::domai flag = zerork_reactor_solve(1, time, dt, nReactorsEval, &reactorTEval[0], &reactorPEval[0], &reactorMassFracEval[0], zrm_handle); if (flag != ZERORK_STATUS_SUCCESS) { - std::cout << "Integration failed 0 source terms are used for rank " + std::cout << "Integration failed on some of the ranks, even after reducing tolerances in ZeroRK." << "\n"; - if (chemistryConstraints.errorhandle == 0) { - std::cout << "The simulation continues with 0 chemical source for the failing cells." - << "\n"; - } else if (chemistryConstraints.errorhandle == 1) { + if (chemistryConstraints.errorhandle == 1) { int ii = 0; // For now try to manually decrease the tolerances and recalculate every rank! - // Zerork in the future will have the ability to reintegrate only the failed ranks + // Zerork already reduced the tolerances + while (flag != ZERORK_STATUS_SUCCESS) { + ++ii; + std::cout << "Manually tightening tolerances further." + << "\n"; + zerork_reactor_set_double_option( + "abs_tol", chemistryConstraints.absTolerance * pow(chemistryConstraints.cvode_retry_absolute_tolerance_adjustment, ii * chemistryConstraints.cvode_num_retries), zrm_handle); + flag = zerork_reactor_solve(2, time, dt, nReactorsEval, &reactorTEval[0], &reactorPEval[0], &reactorMassFracEval[0], zrm_handle); + // Try tightening the tolerances + if (ii == 2) { + std::cout << "At this point the tolerances are probably too tight." + << "\n" + << "Consider dumping the state, by setting dumpfailed = 1 in the input file and try to understand why is it failing." + << "\n"; + break; + } + } + // Integration error usually only occur for certain specific states, which will hopefully be advected away for the next step... + // Resetting the tolerances to the original inputs + zerork_reactor_set_double_option("abs_tol", chemistryConstraints.absTolerance, zrm_handle); + zerork_reactor_set_double_option("rel_tol", chemistryConstraints.relTolerance, zrm_handle); + } + if (chemistryConstraints.errorhandle == 2) { try { - while (flag != ZERORK_STATUS_SUCCESS) { - ++ii; - std::cout << "Tightening tolerances." + // For errorhandle 2 stop the simualtion + if (flag != ZERORK_STATUS_SUCCESS) { + std::cout << "Warning: Could not integrate chemistry after reducing the tolerances multiple times." + << "\n"; + std::cout << "Option 2 was selected for error handling, the simulations exits now. " << "\n"; - zerork_reactor_set_double_option("abs_tol", chemistryConstraints.absTolerance * pow(0.01, ii), zrm_handle); - flag = zerork_reactor_solve(2, time, dt, nReactorsEval, &reactorTEval[0], &reactorPEval[0], &reactorMassFracEval[0], zrm_handle); - // If tigethening the - if (ii == 5) { - break; - } - if (flag != ZERORK_STATUS_SUCCESS) { - std::cout << "Warning: Could not integrate chemistry after reducing the tolerances multiple times." - << "\n"; - std::cout << "Consider reducing the timestep or using steplimiter option " - << "\n"; - throw std::runtime_error("ablate::eos::zerorkEOS::Computesource zerork couldn't integrate the simulation."); - } + throw std::runtime_error("ablate::eos::zerorkEOS::Computesource zerork couldn't integrate the simulation."); } } catch (const runtime_error& e) { exit(1); @@ -393,4 +402,4 @@ std::istream& ablate::eos::zerorkeos::operator>>(std::istream& is, ablate::eos:: " Default is Contstant volume"); } return is; -} +} \ No newline at end of file diff --git a/src/eos/zerork/sourceCalculatorZeroRK.hpp b/src/eos/zerork/sourceCalculatorZeroRK.hpp index c5046dcd4..1dafa5eec 100644 --- a/src/eos/zerork/sourceCalculatorZeroRK.hpp +++ b/src/eos/zerork/sourceCalculatorZeroRK.hpp @@ -24,8 +24,8 @@ class SourceCalculator : public ChemistryModel::SourceCalculator, private utilit //! hold a struct that can be used for chemistry constraints struct ChemistryConstraints { - double relTolerance = 1.0E-6; - double absTolerance = 1.0E-10; + double relTolerance = 1.0E-8; + double absTolerance = 1.0E-12; // set the limiter on chemical rates of progress, // for 1D flames set it to a value btw 1e18 and 1e20, @@ -39,7 +39,7 @@ class SourceCalculator : public ChemistryModel::SourceCalculator, private utilit int verbose = 0; // load balancing - int loadBalance = 1; + int loadBalance = 2; // default to time based load balancing // load balancing int gpu = 0; @@ -136,4 +136,4 @@ std::istream& operator>>(std::istream& is, SourceCalculator::ReactorType& v); } // namespace ablate::eos::zerorkeos -#endif // ABLATELIBRARY_BATCHSOURCE_HPP +#endif // ABLATELIBRARY_BATCHSOURCE_HPP \ No newline at end of file