Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into pullrequest
- Loading branch information
Showing
18 changed files
with
997 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/** @addtogroup solverBroyden | ||
* | ||
* @{ | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "FactoryExport.h" | ||
|
||
#include <Core/System/IAlgLoop.h> // Interface to AlgLoo | ||
#include <Core/Solver/IAlgLoopSolver.h> // Export function from dll | ||
#include <Core/Solver/INonLinSolverSettings.h> | ||
#include <Solver/Broyden/BroydenSettings.h> | ||
|
||
#include <Core/Utils/extension/logger.hpp> | ||
#if defined(__vxworks) | ||
//#include <klu.h> | ||
#else | ||
//#include <Solver/KLU/klu.h> | ||
#endif | ||
|
||
/*****************************************************************************/ | ||
/** | ||
Damped Broyden-Raphson Method | ||
The purpose of Broyden is to find a zero of a system F of n nonlinear functions in n | ||
variables y of the form | ||
F(t,y_1,...,y_n) = 0, (1) | ||
or | ||
f_1(t,y_1,...,y_n) = 0 | ||
... ... | ||
f_n(t,y_1,...,y_n) = 0 | ||
by the use of an iterative Broyden method. The solution of the linear system is done | ||
by Lapack/DGESV, which computes the solution to a real system of linear equations | ||
A * y = B, (2) | ||
where A is an n-by-n matrix and y and B are n-by-n(right hand side) matrices. | ||
\date 2008, September, 16th | ||
\author | ||
*/ | ||
/***************************************************************************** | ||
OSMS(c) 2008 | ||
*****************************************************************************/ | ||
class Broyden : public IAlgLoopSolver | ||
{ | ||
public: | ||
|
||
Broyden(IAlgLoop* algLoop,INonLinSolverSettings* settings); | ||
|
||
virtual ~Broyden(); | ||
|
||
/// (Re-) initialize the solver | ||
virtual void initialize(); | ||
|
||
/// Solution of a (non-)linear system of equations | ||
virtual void solve(); | ||
|
||
/// Returns the status of iteration | ||
virtual ITERATIONSTATUS getIterationStatus(); | ||
virtual void stepCompleted(double time); | ||
virtual void restoreOldValues(); | ||
virtual void restoreNewValues(); | ||
private: | ||
/// Encapsulation of determination of residuals to given unknowns | ||
void calcFunction(const double* y, double* residual); | ||
|
||
/// Encapsulation of determination of Jacobian | ||
void calcJacobian(); | ||
|
||
// Member variables | ||
//--------------------------------------------------------------- | ||
INonLinSolverSettings | ||
*_BroydenSettings; ///< Settings for the solver | ||
|
||
IAlgLoop | ||
*_algLoop; ///< Algebraic loop to be solved | ||
|
||
ITERATIONSTATUS | ||
_iterationStatus; ///< Output - Denotes the status of iteration | ||
|
||
long int | ||
_dimSys, ///< Temp - Number of unknowns (=dimension of system of equations) | ||
_lwork, | ||
_iONE; | ||
|
||
bool | ||
_firstCall; ///< Temp - Denotes the first call to the solver, init() is called | ||
|
||
double | ||
*_y, ///< Temp - Unknowns | ||
*_yHelp, | ||
*_fnew, ///< Temp - Residuals | ||
*_fold, ///< Temp - Residuals | ||
*_fHelp, | ||
*_delta_s, ///< Temp - Auxillary variables | ||
*_delta_b, ///< Temp - Auxillary variables | ||
*_jac, ///< Temp - Jacobian | ||
*_jacHelpMat1, | ||
*_jacHelpMat2, | ||
*_jacHelpVec1, | ||
*_jacHelpVec2, | ||
*_work; | ||
|
||
int | ||
_broydenMethod; | ||
|
||
double _fNormTol, | ||
_dONE, | ||
_dZERO, | ||
_dMINUSONE; | ||
|
||
|
||
long int *_iHelp; | ||
|
||
char | ||
_N, | ||
_T; | ||
|
||
bool _sparse; | ||
|
||
|
||
int _dim; | ||
/* | ||
klu_symbolic* _kluSymbolic ; | ||
klu_numeric* _kluNumeric ; | ||
klu_common* _kluCommon ; | ||
int* _Ai; | ||
int* _Ap; | ||
double* _Ax; | ||
int _nonzeros; | ||
*/ | ||
long int* _ihelpArray; | ||
double * _zeroVec; | ||
double * _f ; | ||
|
||
|
||
|
||
|
||
double* _identity; | ||
}; | ||
/** @} */ // end of solverBroyden |
38 changes: 38 additions & 0 deletions
38
SimulationRuntime/cpp/Include/Solver/Broyden/BroydenSettings.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#pragma once | ||
/** @addtogroup solverBroyden | ||
* | ||
* @{ | ||
*/ | ||
|
||
#include <Core/Solver/INonLinSolverSettings.h> | ||
class BroydenSettings :public INonLinSolverSettings | ||
{ | ||
public: | ||
BroydenSettings(); | ||
|
||
virtual ~BroydenSettings(); | ||
/*max. Anzahl an Broydenititerationen pro Schritt (default: 25)*/ | ||
virtual long int getNewtMax(); | ||
virtual void setNewtMax(long int); | ||
/* Relative Toleranz für die Broydeniteration (default: 1e-6)*/ | ||
virtual double getRtol(); | ||
virtual void setRtol(double); | ||
/*Absolute Toleranz für die Broydeniteration (default: 1e-6)*/ | ||
virtual double getAtol(); | ||
virtual void setAtol(double); | ||
/*Dämpfungsfaktor (default: 0.9)*/ | ||
virtual double getDelta(); | ||
virtual void setDelta(double); | ||
virtual void load(string); | ||
|
||
virtual void setContinueOnError(bool); | ||
virtual bool getContinueOnError(); | ||
private: | ||
long int _iNewt_max; ///< max. Anzahl an Broydenititerationen pro Schritt (default: 25) | ||
|
||
double _dRtol; ///< Relative Toleranz für die Broydeniteration (default: 1e-6) | ||
double _dAtol; ///< Absolute Toleranz für die Broydeniteration (default: 1e-6) | ||
double _dDelta; ///< Dämpfungsfaktor (default: 0.9) | ||
bool _continueOnError; | ||
}; | ||
/** @} */ // end of solverBroyden |
19 changes: 19 additions & 0 deletions
19
SimulationRuntime/cpp/Include/Solver/Broyden/FactoryExport.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
/** @defgroup solverNewton Solver.Broyden | ||
* Nonlineaar solver class for Broyden methods | ||
* @{ | ||
*/ | ||
#if defined(__vxworks) || defined(RUNTIME_STATIC_LINKING) | ||
#define BOOST_EXTENSION_LOGGER_DECL | ||
#define BOOST_EXTENSION_SOLVER_DECL | ||
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL | ||
#elif defined(OMC_BUILD) || defined(SIMSTER_BUILD) | ||
#define BOOST_EXTENSION_LOGGER_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#define BOOST_EXTENSION_SOLVER_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#define BOOST_EXTENSION_SOLVERSETTINGS_DECL BOOST_EXTENSION_IMPORT_DECL | ||
#else | ||
error "operating system not supported" | ||
#endif | ||
/** @} */ // end of solverBroyden | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.