IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase Class Referenceabstract

A template ODE solver without an actual implementation of the solving method (e.g. RK4). More...

+ Inheritance diagram for IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase:

Public Member Functions

abstract void SolvingAlgorithm ()
 The specific ODE solving method, which every child class implements on its own. It is used inside the Solve() method of this class. More...
 
void PrepareForSolving ()
 This method prepares the ODE solver for solving. It is called inside the Solve() method of this class. It checks whether the step size has been specified, etc. More...
 
void Solve ()
 The method that solves the ODE. It fills the solution list with values. The expected operations of every type of ODE solver are defined here (the solution list initialization, the calculation of the number of steps, ...) After these operations the specific ODE solver is called (e.g. RK4). Each child has to define its own specific ODE solver. More...
 
void CalculateErrors ()
 Estimates the solution errors by comparing a solution at the current step size with a solution at half the step size. More...
 
void PostProcessErrors (int pointsPerDomain)
 First calculates the absolutes of the errors, then tries to smoothen the errors curve. Useful when the curve is oscillating and you only need the envelope.

Parameters
pointsPerDomainThe number of selected equidistant points, if the curve was monotonic.
More...
 
void VerifyErrorsValidity (int checkNeighborhood)
 See: Richardson extrapolation. Calculates the solution at different step sizes. The step sizes differ one from another for an integer factor (usually 2). The method then calculates the errors for each of these solutions and saves their largest errors. The error differences are then sequentially divided between each other. These terms must converge to a constant related with the order of the solving method. More...
 
void PrintResults (TextWriter writer)
 Prints the solution to the specified text writer. More...
 
void PrintResults (string filePath)
 Prints the solution to the specified file. More...
 
void PrintResults ()
 Prints solution to the console. More...
 
void PrintResultsOld ()
 

Public Attributes

double _stepSize
 
int _nSteps
 
List< double[]> _solutionODE
 
int _solutionSize
 The size of the auxiliary array (the inner array), which contains all the data at a single step: More...
 
InitialProblemSolverStates _state
 

Protected Attributes

double[] _initialConditions
 
double _endPoint
 
HighestDerivativeFunctionDelegate _highestDerivative
 
List< double[]> _originalSolution
 A storage for the solution that has been created at the last call of the Solve() method. This list is used by the CalculateErrors() method, because it overwrites the old _solutionODE list. More...
 
List< double[]> _errors
 The calculated errors get stored here after the CalculateErrors() method call. Actually only the _solutionODE list is re-referenced to this list's name. More...
 
int _errorEstimateCoefficient = 2
 The geometric series coefficient that tells us the divisor between two sequential step sizes. More...
 

Properties

double[] InitialConditions [get, set]
 Initial conditions: values of every derivative and the function itself at step zero. Format for a II. order ODE: [x, f, f', f'']. The array length is thus equal to the Order(ODE) + 2. More...
 
double EndPoint [get, set]
 The end value of the independent variable at which the ODE solver stops the solving process. More...
 
double StepSize [get, set]
 The ODE solver's step size. More...
 
int NSteps [get, set]
 The number of steps for which the solution is going to be calculated. More...
 
List< double[]> SolutionODE [get, protected set]
 The solution is a list of points. The list is filled with values after a Solve() method call. Example format for a II. order ODE: [ [x0,f(0),f'(0),f''(0)], [x(1),f(1),f'(1),f''(1)], [x(2),f(2),f'(2),f''(2)], ... ] More...
 
HighestDerivativeFunctionDelegate HighestDerivative [get, set]
 A delegate instance which binds the ODE solver with the appropriate ODE. Each model defines its own ODE. More...
 
InitialProblemSolverStates State [get, set]
 The state in which the ODE solver is currently in: which parameters are already specified, which method have been called. More...
 

Detailed Description

A template ODE solver without an actual implementation of the solving method (e.g. RK4).

Member Function Documentation

abstract void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.SolvingAlgorithm ( )
pure virtual

The specific ODE solving method, which every child class implements on its own. It is used inside the Solve() method of this class.

Implemented in IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverRK4.

void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.PrepareForSolving ( )
inline

This method prepares the ODE solver for solving. It is called inside the Solve() method of this class. It checks whether the step size has been specified, etc.

void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.Solve ( )
inline

The method that solves the ODE. It fills the solution list with values. The expected operations of every type of ODE solver are defined here (the solution list initialization, the calculation of the number of steps, ...) After these operations the specific ODE solver is called (e.g. RK4). Each child has to define its own specific ODE solver.

Referenced by IG.MPetekLib.Algorithms.PlottableModels.Oscillators.DrivenOscillatorBase.PinpointExtreme(), IG.MPetekLib.Application.Scripts.LinearOscillator._01NondrivenPrintSolution.ReturnSolver(), and IG.MPetekLib.Algorithms.PlottableModels.PlottableODEModelBase.SolveNumerically().

void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.CalculateErrors ( )
inline

Estimates the solution errors by comparing a solution at the current step size with a solution at half the step size.

Referenced by IG.MPetekLib.Algorithms.PlottableModels.PlottableODEModelBase.CalculateErrors().

void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.PostProcessErrors ( int  pointsPerDomain)
inline

First calculates the absolutes of the errors, then tries to smoothen the errors curve. Useful when the curve is oscillating and you only need the envelope.

Parameters
pointsPerDomainThe number of selected equidistant points, if the curve was monotonic.

Referenced by IG.MPetekLib.Algorithms.PlottableModels.PlottableODEModelBase.PostProcessErrors().

void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.VerifyErrorsValidity ( int  checkNeighborhood)
inline

See: Richardson extrapolation. Calculates the solution at different step sizes. The step sizes differ one from another for an integer factor (usually 2). The method then calculates the errors for each of these solutions and saves their largest errors. The error differences are then sequentially divided between each other. These terms must converge to a constant related with the order of the solving method.

Parameters
checkNeighborhoodHow many times the step size should be reduced.

Referenced by IG.MPetekLib.Algorithms.PlottableModels.PlottableODEModelBase.VerifyErrorsValidity().

void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.PrintResults ( TextWriter  writer)
inline

Prints the solution to the specified text writer.

Parameters
writer
void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.PrintResults ( string  filePath)
inline

Prints the solution to the specified file.

If the file exists then it is overwritten.

Parameters
inputFilePathPath of the file where solution is written.
void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.PrintResults ( )
inline

Prints solution to the console.

void IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.PrintResultsOld ( )
inline

Member Data Documentation

double [] IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._initialConditions
protected
double IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._endPoint
protected
double IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._stepSize
int IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._nSteps
int IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._solutionSize

The size of the auxiliary array (the inner array), which contains all the data at a single step:

[x0,f(0),f'(0),f''(0)] —> Its size is equal to: Order(ODE) + 2.

HighestDerivativeFunctionDelegate IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._highestDerivative
protected
List<double[]> IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._originalSolution
protected

A storage for the solution that has been created at the last call of the Solve() method. This list is used by the CalculateErrors() method, because it overwrites the old _solutionODE list.

List<double[]> IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._errors
protected

The calculated errors get stored here after the CalculateErrors() method call. Actually only the _solutionODE list is re-referenced to this list's name.

int IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._errorEstimateCoefficient = 2
protected

The geometric series coefficient that tells us the divisor between two sequential step sizes.

InitialProblemSolverStates IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase._state

Property Documentation

double [] IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.InitialConditions
getset

Initial conditions: values of every derivative and the function itself at step zero. Format for a II. order ODE: [x, f, f', f'']. The array length is thus equal to the Order(ODE) + 2.

Referenced by IG.MPetekLib.Algorithms.PlottableModels.Oscillators.DrivenOscillatorBase.PinpointExtreme(), and IG.MPetekLib.Application.Scripts.LinearOscillator._01NondrivenPrintSolution.ReturnSolver().

double IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.StepSize
getset

The ODE solver's step size.

Referenced by IG.MPetekLib.Application.Scripts.LinearOscillator._11MultipleResCurvesPlot3D.ResonanceCurveHarmonicFamily3dWithManualScaling(), IG.MPetekLib.Application.Scripts.LinearOscillator._01NondrivenPrintSolution.ReturnSolver(), IG.MPetekLib.Application.Scripts.NonlinearOscNondim._17SteadyStateAmplitude.Run(), IG.MPetekLib.Application.Scripts.NonlinearOscNondim._16SolutionPlot.Run(), IG.MPetekLib.Application.Scripts.NonlinearOscillator._15SolutionPlot.Run(), IG.MPetekLib.Application.Scripts.NonlinearOscillator._19SingleResonancePlot.Run(), IG.MPetekLib.Application.Scripts.NonlinearOscillator._22SingleResCurveManyPhases.Run(), IG.MPetekLib.Application.Scripts.MagOscHardSpring._23SingleResCurveManyPhases.Run(), IG.Script._18ChaoticPlot.Run(), IG.MPetekLib.Application.Scripts.NonlinearOscillator._21MultipleResCurvesPlot.Run(), IG.MPetekLib.Application.Scripts.LinearOscillator._08SteadyStateAmplitude.Run(), IG.MPetekLib.Application.Scripts.LinearOscillator._12MultipleResCurvesPlot.Run(), IG.MPetekLib.Application.Scripts.LinearOscillator._13SolutionAndDrivingFunctionPlot.Run(), IG.MPetekLib.Application.Scripts.LinearOscillator._09SingleResonanceCurvePlot.Run(), IG.MPetekLib.Application.Scripts.NonlinearOscNondim._20MultipleResCurvesPlot.Run(), IG.MPetekLib.Application.Scripts.LinearOscillator._05AnalytAndNumSolutionPlot.Run(), IG.MPetekLib.Application.Scripts.MagOscHardSpring._24MultiResCurvesPlotPhaseScan.Run(), IG.MPetekLib.Application.Scripts.LinearOscillator._02DrivenPlotSolution.Run(), IG.MPetekLib.Application.Scripts.LinearOscillator._10MultipleResCurvesPlotObsolete.Run(), IG.Script.DemoResonanceCurvePlot.Run(), IG.Script.DemoResonanceCurvePlotExt.Run(), and IG.MPetekLib.Application.Scripts.LinearOscillator._11MultipleResCurvesPlot3D.Run().

int IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.NSteps
getset

The number of steps for which the solution is going to be calculated.

Referenced by IG.MPetekLib.Algorithms.PlottableModels.Oscillators.DrivenOscillatorBase.PinpointExtreme().

List<double[]> IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.SolutionODE
getprotected set

The solution is a list of points. The list is filled with values after a Solve() method call. Example format for a II. order ODE: [ [x0,f(0),f'(0),f''(0)], [x(1),f(1),f'(1),f''(1)], [x(2),f(2),f'(2),f''(2)], ... ]

After calling the error estimator methods this list can contain the calculated error values.

HighestDerivativeFunctionDelegate IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.HighestDerivative
getset

A delegate instance which binds the ODE solver with the appropriate ODE. Each model defines its own ODE.

Referenced by IG.MPetekLib.Algorithms.PlottableModels.Oscillators.DrivenOscillatorBase.FindSteadyStateAmplitude(), and IG.MPetekLib.Application.Scripts.LinearOscillator._01NondrivenPrintSolution.ReturnSolver().

InitialProblemSolverStates IG.MPetekLib.Algorithms.Solvers.InitialProblemODE_RK4.InitialProblemSolverBase.State
getset

The state in which the ODE solver is currently in: which parameters are already specified, which method have been called.


The documentation for this class was generated from the following file: