IGLib
1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
|
Base class for definition of a system of first order ordinary differential equations (initial problem). More...
Public Member Functions | |
DifferentialFirstOrderSolverBase (DifferentialFirstOrderSystemBase equations) | |
Constructs a solver for the specified system of first order ordinary differential equations. More... | |
double[][] | GetResultsArray () |
Creates and returns an array containing all stored results. More... | |
void | StoreSavedState () |
Stores the saved solver-extended state of the problem (property SavedState) to the list of results (property Results). More... | |
void | SaveState (double parameterValue, double[] functionValues, int stepNumber, double stepLength) |
Saves the current values of the problem parameter (independent variable) and function values to the auxiliary state array (property SavedState), together with the specified step number and step length. More... | |
void | SaveState (double[] state, int stepNumber, int stepLength) |
Saves the current state of the problem (including the current parameter and function values, step number and step length) to the auxiliary state array (property SavedState). More... | |
double | GetSavedParameter (double[] savedState) |
Retrieves the value of parameter (independent variable) from the saved state and returns it. More... | |
int | GetSavedStepNumber (double[] savedState) |
Retrieves the step number from the saved state and returns it. More... | |
double | GetSavedStepSize (double[] savedState) |
Retrieves the step size from the saved state and returns it. More... | |
void | GetSavedFunctionValues (double[] savedState, double[] functionValues) |
Retrieves the calculated function values from the saved state and copies them to the provided array. More... | |
void | GetSavedState (double[] savedState, double[] state) |
Retrieves the calculated function values from the saved state and copies them to the provided array. More... | |
void | InitializeSolver () |
Performs all the initializations that are necessary before solving the equations. This includes transcribing basic problem data from the problem object, transcribing initial state from equations object as well as allocating all auxiliary variables. More... | |
abstract void | CalculateTrial (double stepLength) |
Calculates a trial solution after the specified increase in step size. More... | |
virtual void | CalculateWithFixedStep (double finalTime) |
Public Attributes | |
int | _outputFrequency |
bool | _doOutput = (DefaultOutputLevel > 0 && DefaultOutputFrequency!=0) |
int | _storingFrequency = DefaultStoringFrequency |
bool | _doStoreResults = DefaultStoringFrequency != 0 |
Static Public Attributes | |
static int | DefaultOutputLevel = 0 |
Default output level for solvers of first order systems of differential equations. More... | |
static int | DefaultOutputFrequency = 5 |
Default output frequency, sefines how often output is made. More... | |
static int | DefaultFileSaveFrequency = 5 |
static int | DefaultStoringFrequency = 1 |
Protected Member Functions | |
virtual void | InitializeProblemData () |
Initializes basic problem data according to equations. More... | |
virtual void | InitializeSolverInternals () |
Initializes the solver state. More... | |
Protected Attributes | |
int | _outputLevel = DefaultOutputLevel |
int | _fileSaveFrequency = DefaultFileSaveFrequency |
bool | _doFileSave |
List< double[]> | _results = new List<double[]>() |
int | _numEquations |
int | _numStateVariables |
int | _numSavedStateVariables = 0 |
bool | _isHistoryDependent = false |
DifferentialFirstOrderSystemBase | _problem |
double | _initialParameter |
double | _finalParameter |
double | _numSteps |
bool | _isFixedStep = true |
double | _initialStepLength |
double | _stepLength |
double | _stepNumber = 0 |
double | _parameter |
double | _nextParameter |
double[] | _functionValues |
double[] | _nextFunctionValues |
double[] | _state |
double[] | _nextState |
double[] | _savedState |
Properties | |
int | OutputLevel [get, set] |
Level of output to console produced during operation (0 means no output). More... | |
int | OutputFrequency [get, set] |
bool | DoOutput [get, set] |
int | FileSaveFrequency [get, set] |
bool | DoFileSave [get, set] |
TextWriter | FileSaver [get, set] |
int | StoringFrequency [get, protected set] |
bool | DoStoreResults [get, protected set] |
List< double[]> | Results [get] |
Gets a reference to the list where results are stored. More... | |
virtual int | NumEquations [get, protected set] |
Number of equations in the system of equations. More... | |
int | NumStateVariables [get, set] |
Number of state variables, including independent variable and function values. More... | |
virtual int | NumSavedStateVariables [get] |
Gets the required length of the saved state array. More... | |
bool | IsHistoryDependent [get, set] |
Flag indicating whether the problem is history dependent (meaning that it has additional state variables that are not calculated by the solver). More... | |
DifferentialFirstOrderSystemBase | Problem [get, protected set] |
Definition of a system of first order ordinary differential equations with initial condition. More... | |
double | InitialParameter [get, protected set] |
Initial value of parameter (independent variable). More... | |
double | FinalParameter [get, protected set] |
Final value of parameter (independent variable). More... | |
double | NumSteps [get, protected set] |
Number of steps. More... | |
bool | IsFixedStep [get, protected set] |
Flag indicating whether a fixed step is used (as contrary to adaptive step). More... | |
double | InitialStepLength [get, set] |
Initial step length. More... | |
double | StepLength [get, set] |
Step length. More... | |
double | StepNumber [get, protected set] |
Current step number. More... | |
double | Parameter [get, protected set] |
Current value of independent parameter. More... | |
double | NextParameter [get, protected set] |
Value of independent parameter in the next step. More... | |
double[] | FunctionValues [get, protected set] |
Array of current function values. More... | |
double[] | NextFunctionValues [get, protected set] |
Array of function values in the next step. More... | |
double[] | State [get, protected set] |
Current state of the problem. More... | |
double[] | NextState [get, protected set] |
State of the problem for the next step. More... | |
double[] | SavedState [get, protected set] |
Array of state and other variables to be saved or restored. More... | |
Private Member Functions | |
DifferentialFirstOrderSolverBase () | |
Private Attributes | |
TextWriter | _fileSaver = null |
Base class for definition of a system of first order ordinary differential equations (initial problem).
Notes on storing the current state:
Solver is only aware of the parameter (independent variable) and function values. These are stored separately (function values are stored in an array) and define the current state of the problem for the solver (beside the step number and step length).
Problem definition may include additional state variables. Current state of the problem includes the current parameter (independent variable) and function values and eventually some additional state variables (such a history variables) but exclude step number and step length.
Problem definition object stores its state into (or restores from) a packed state array. In this array, the first element is always the vlue of independent variable (problem parameter), followed by values of searched functions (solutions of the problem), followed by eventual additional state variables.
When saving the state from the solver, the solver packs the state into an array that includes the complete problem state (as vould be stored by the problem definition object) plus the step number and step length. Sometimes this array does not include all the data, e.g. it may exclude additional values of state variables of the problem definition object (this is when the state that is saved was not created by the problem definition object but by solver, which is not aware of the additional state variables). However, the order of the saved parameters is always the same as that of the problem definition object, only some data may be unavailable. The solver gets the number of problem state parameters from the problem definition object when it is initialized.
In view of the above, the order of values in the saved state array is as follows
- value of independent variable (problem parameter, e.g. time).
- valus of functions that are searched for
- eventual additional state variables of the problem; these have unspecified values when the saved state is packed merely by the solver, without assistance of the problem definition object.
- step number; this has unspecified value when the saved state is packed by the problem definition object, since it is not aware of the solver.
- step size used to calculate the saved state; this has unspecified value when the saved state is packed by the problem definition object, since it is not aware of the solver.
$A Igor Mar2009;
|
inlineprivate |
|
inline |
Constructs a solver for the specified system of first order ordinary differential equations.
equations |
|
inline |
Creates and returns an array containing all stored results.
The returned array does not change when new results are stored by the solver. To include new results, either call this method again or use the Results property, which gives a reference to teh actual result list that is updated.
|
inline |
Stores the saved solver-extended state of the problem (property SavedState) to the list of results (property Results).
|
inline |
Saves the current values of the problem parameter (independent variable) and function values to the auxiliary state array (property SavedState), together with the specified step number and step length.
This does not necessarily include the complete state of the problem as defined by the Problem object (since the problem can include additional state variables that the solver is not aware of, such as history variables), but the order of elements will be the same (eventually missed parameters are just set to 0).
state | State to be saved. Stat will normally be obtained from the Problem object. |
stepNumber | The step number to be stored with the state (this is not part of the state as defined by the Problem object). |
stepLength | The step length to be stored with the state (this is not part of the state as defined by the Problem object). |
|
inline |
Saves the current state of the problem (including the current parameter and function values, step number and step length) to the auxiliary state array (property SavedState).
state | State to be saved. Stat will normally be obtained from the Problem object. |
stepNumber | The step number to be stored with the state (this is not part of the state as defined by the Problem object). |
stepLength | The step length to be stored with the state (this is not part of the state as defined by the Problem object). |
|
inline |
Retrieves the value of parameter (independent variable) from the saved state and returns it.
savedState | Array containing saved state. |
ArgumentException | When the specified array containing the saved state is null or it has too few elements. |
|
inline |
Retrieves the step number from the saved state and returns it.
savedState | Array containing saved state. |
ArgumentException | When the specified array containing the saved state is null or it has too few elements. |
|
inline |
Retrieves the step size from the saved state and returns it.
savedState | Array containing saved state. |
ArgumentException | When the specified array containing the saved state is null or it has too few elements. |
|
inline |
Retrieves the calculated function values from the saved state and copies them to the provided array.
savedState | Array containing saved state. |
functionValues | Array where state will be restored. It must be allocated with size greater or equal to the number of state parameters. |
ArgumentException | When the specified array containing the saved state is null or it has too few elements, or when the provided array to store copied values is null or has too few elements. |
|
inline |
Retrieves the calculated function values from the saved state and copies them to the provided array.
savedState | Array containing saved state. |
state | Array where state will be stored. It must be allocated with size greater or equal to the number of elements of the state parameters (property NumStateVariables). |
ArgumentException | When the specified array containing the state is null or its has too few elements, or when the provided array to store copied values is null or has too few elements. |
|
inlineprotectedvirtual |
Initializes basic problem data according to equations.
Problem must be defined before running this.
Call base class method wen overriding!
|
inlineprotectedvirtual |
Initializes the solver state.
Allocates auxiliary variables and sets the initial conditions from the problem object.
Call base class method when overriding!
|
inline |
Performs all the initializations that are necessary before solving the equations. This includes transcribing basic problem data from the problem object, transcribing initial state from equations object as well as allocating all auxiliary variables.
|
pure virtual |
Calculates a trial solution after the specified increase in step size.
stepLength | Length by which parameter value is incremented. |
|
inlinevirtual |
|
static |
Default output level for solvers of first order systems of differential equations.
|
protected |
|
static |
Default output frequency, sefines how often output is made.
int IG.Num.DifferentialFirstOrderSolverBase._outputFrequency |
bool IG.Num.DifferentialFirstOrderSolverBase._doOutput = (DefaultOutputLevel > 0 && DefaultOutputFrequency!=0) |
|
static |
|
protected |
|
protected |
|
private |
|
static |
int IG.Num.DifferentialFirstOrderSolverBase._storingFrequency = DefaultStoringFrequency |
bool IG.Num.DifferentialFirstOrderSolverBase._doStoreResults = DefaultStoringFrequency != 0 |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
getset |
Level of output to console produced during operation (0 means no output).
|
getset |
|
getset |
|
getset |
|
getsetprivate |
|
getset |
|
getprotected set |
|
getprotected set |
|
get |
Gets a reference to the list where results are stored.
Results after each step are stored as plain double array where elements are ordered the same as when the solver state is stored. The array is usually copied from the array addressed by the SavedState property by using the StoreSavedState function.
|
getprotected set |
Number of equations in the system of equations.
|
getset |
Number of state variables, including independent variable and function values.
|
get |
Gets the required length of the saved state array.
|
getset |
Flag indicating whether the problem is history dependent (meaning that it has additional state variables that are not calculated by the solver).
|
getprotected set |
Definition of a system of first order ordinary differential equations with initial condition.
|
getprotected set |
Initial value of parameter (independent variable).
|
getprotected set |
Final value of parameter (independent variable).
|
getprotected set |
Number of steps.
|
getprotected set |
Flag indicating whether a fixed step is used (as contrary to adaptive step).
|
getset |
Initial step length.
|
getset |
Step length.
|
getprotected set |
Current step number.
|
getprotected set |
Current value of independent parameter.
|
getprotected set |
Value of independent parameter in the next step.
|
getprotected set |
Array of current function values.
|
getprotected set |
Array of function values in the next step.
|
getprotected set |
Current state of the problem.
This array contains complete state of the problem, which makes possible to restore the state witout losing anything. State is generated by the problem object and has nothing to do with solver. It includes value of independent variable (function parameter), all function values and eventual additional (history) variables necessary to define the state.
|
getprotected set |
State of the problem for the next step.
This array contains complete state of the problem, which makes possible to restore the state witout losing anything. State is generated by the problem object and has nothing to do with solver. It includes value of independent variable (function parameter), all function values and eventual additional (history) variables necessary to define the state.
|
getprotected set |
Array of state and other variables to be saved or restored.
Number of elements is two more than number of elements in state array, the one before the last element being the step number (cast to double), and the last being the step length used to produce the current results.
This array can be used to just save the normal state because the order of the first elements is the same.