OMCompiler/SimulationRuntime/cpp/Solver/Newton/NewtonSettings.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | /** @addtogroup solverNewton | ||
| 29 | * | ||
| 30 | * @{ | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include <Core/ModelicaDefine.h> | ||
| 34 | #include <Core/Modelica.h> | ||
| 35 | |||
| 36 | #include <Solver/Newton/NewtonSettings.h> | ||
| 37 | |||
| 38 | 52 | NewtonSettings::NewtonSettings() | |
| 39 | 52 | : _iNewt_max (50) | |
| 40 | 52 | , _dRtol (1e-8) | |
| 41 | 52 | , _dAtol (1e-8) | |
| 42 | 52 | , _dDelta (1) | |
| 43 | 52 | , _continueOnError (false) | |
| 44 | { | ||
| 45 | 52 | } | |
| 46 | |||
| 47 | 104 | NewtonSettings::~NewtonSettings() | |
| 48 | { | ||
| 49 | 104 | } | |
| 50 | |||
| 51 | /*max. Anzahl an Newtonititerationen pro Schritt (default: 50)*/ | ||
| 52 | 768026 | long int NewtonSettings::getNewtMax() | |
| 53 | { | ||
| 54 | 768026 | return _iNewt_max; | |
| 55 | } | ||
| 56 | |||
| 57 | ✗ | void NewtonSettings::setNewtMax(long int max) | |
| 58 | { | ||
| 59 | ✗ | _iNewt_max = max; | |
| 60 | ✗ | } | |
| 61 | |||
| 62 | /* Relative Toleranz für die Newtoniteration (default: 1e-6)*/ | ||
| 63 | 1885782 | double NewtonSettings::getRtol() | |
| 64 | { | ||
| 65 | 1885782 | return _dRtol; | |
| 66 | } | ||
| 67 | |||
| 68 | ✗ | void NewtonSettings::setRtol(double t) | |
| 69 | { | ||
| 70 | ✗ | _dRtol=t; | |
| 71 | ✗ | } | |
| 72 | |||
| 73 | /*Absolute Toleranz für die Newtoniteration (default: 1e-6)*/ | ||
| 74 | 1527195 | double NewtonSettings::getAtol() | |
| 75 | { | ||
| 76 | 1527195 | return _dAtol; | |
| 77 | } | ||
| 78 | |||
| 79 | ✗ | void NewtonSettings::setAtol(double t) | |
| 80 | { | ||
| 81 | ✗ | _dAtol =t; | |
| 82 | ✗ | } | |
| 83 | |||
| 84 | /*Dämpfungsfaktor (default: 0.9)*/ | ||
| 85 | ✗ | double NewtonSettings::getDelta() | |
| 86 | { | ||
| 87 | ✗ | return _dDelta; | |
| 88 | } | ||
| 89 | |||
| 90 | ✗ | void NewtonSettings::setDelta(double t) | |
| 91 | { | ||
| 92 | ✗ | _dDelta = t; | |
| 93 | ✗ | } | |
| 94 | |||
| 95 | ✗ | void NewtonSettings::load(string) | |
| 96 | { | ||
| 97 | ✗ | } | |
| 98 | |||
| 99 | 52 | void NewtonSettings::setGlobalSettings(IGlobalSettings *settings) | |
| 100 | { | ||
| 101 | 52 | _globalSettings = settings; | |
| 102 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
|
52 | _dAtol = max(settings->getTolerance() * 1e-2, 1e-12); |
| 103 | 52 | _dRtol = _dAtol; | |
| 104 | 52 | } | |
| 105 | |||
| 106 | 52 | void NewtonSettings::setContinueOnError(bool value) | |
| 107 | { | ||
| 108 | 52 | _continueOnError = value; | |
| 109 | 52 | } | |
| 110 | |||
| 111 | ✗ | bool NewtonSettings::getContinueOnError() | |
| 112 | { | ||
| 113 | ✗ | return _continueOnError; | |
| 114 | } | ||
| 115 | |||
| 116 | /** @} */ // end of solverNewton | ||
| 117 |