You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/jacobian-matrix.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ For more information about defining the matrix in sparse format, refer to the [S
106
106
107
107
## Automatic Jacobian matrix
108
108
109
-
{: .important }
109
+
{: .note }
110
110
*Automatic* (or *algorithmic*) differentiation is a [special technique](https://en.wikipedia.org/wiki/Automatic_differentiation) to compute the partial derivatives of a function by a computer program exactly (to working precision), by applying the [chain rule](https://en.wikipedia.org/wiki/Chain_rule). By automatic (algorithmic) Jacobian matrix in this documentation, we refer to the Jacobian computed using automatic differentiation.
111
111
112
112
The solver provides a helper class `daecpp::JacobianAutomatic` to compute the Jacobian matrix for the given vector function $$\mathbf{f}(\mathbf{x}, t)$$ algorithmically using [`autodiff`](https://autodiff.github.io/) package.
Copy file name to clipboardExpand all lines: docs/solution-manager.md
+78-8
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,11 @@ layout: default
4
4
nav_order: 6
5
5
---
6
6
7
-
Work in progress
8
-
{: .label .label-red }
9
-
10
7
# Solution Manager class
11
8
12
-
The Solution Manager class can serve as a solution observer and/or as an event function that stops computation when a certain event occurs. Solution Manager functor will be called every time step, providing the time `t` and the corresponding solution `x` for the user for further post-processing. If the functor returns an integer which is not equal to `0` (i.e., `true`), the computation will immediately stop.
9
+
The Solution Manager class can serve as a solution observer and/or as an event function that stops computation when a certain event occurs. Solution Manager functor will be called every time step, providing the time `t` and the corresponding solution vector `x` for the user for further post-processing. If the functor returns an integer which is not equal to `0` (i.e., `true`), the computation will immediately stop.
13
10
14
-
The solver provides a derived from the Solution Manager class called [`daecpp::Solution`](#solution-class), which writes the solution vector `x` and time `t` every time step or every specific time defined by the user into the [solution holder](#solution-holder) object. The user can access this object for further post-processing, printing the solution on the screen or writing it to a file.
11
+
The solver provides a derived from the Solution Manager class called [`daecpp::Solution`](#solution-class), which writes the solution vector `x` and time `t` every time step or every specific times defined by the user into the [Solution Holder](#solution-holder) object. The user can access this object for further post-processing, printing the solution on the screen or writing it to a file.
15
12
16
13
{: .important }
17
14
By default, the DAE solver does nothing with the solution, i.e., it does not print it on the screen or save it anywhere. It is the user's responsibility to define a Solution Manager object that processes the solution (saves it to a vector, to a file, etc.). The solver, however, provides a basic Solution Manager called [`daecpp::Solution`](#solution-class).
@@ -52,7 +49,7 @@ In the following example, we define a custom Solution Manager that performs the
daecpp::state_vector &m_x_sol; // Vector of solution x[0]
52
+
daecpp::state_vector &m_x_sol; // Vector of solutions x[0]
56
53
std::vector<double> &m_t_sol; // Vector of the corresponding times t
57
54
58
55
public:
@@ -83,6 +80,79 @@ Vectors `x_sol` and `t_sol` should be defined before calling the `UserDefinedSol
83
80
84
81
Similar to the mass matrix, vector function, Jacobian matrix definitions, inhereting the `daecpp::SolutionManager` class is a good practice (it serves as a blueprint), but it is not necessary. The user is allowed to define custom Solution Managers without inhereting `daecpp::SolutionManager`.
85
82
86
-
## Solution holder
83
+
----
84
+
85
+
# Solution Holder class
86
+
87
+
The Solution Holder class `daecpp::SolutionHolder` is a helper class that stores solution vectors `x` and the corresponding times `t`. In addition, it provides a utility method that prints the entire solution or selected elements of the solution versus time on the screen.
88
+
The objects of the Solution Holder class can be used with the user-defined Solution Managers or together with the [Solution](#solution-class) class.
89
+
90
+
## Solution Holder class public data
91
+
92
+
| Variable | Type | Description |
93
+
| -------- | ---- | ----------- |
94
+
|`x`|[`std::vector<daecpp::state_vector>`](prerequisites.html#dae-cpp-types)| Vector of solution vectors |
95
+
|`t`|`std::vector<double>`| Vector of the corresponding solution times |
96
+
97
+
Thus, for example, the solution time `t_end` (time at the final time step) and the corresponding solution `x_end` can be accessed by
98
+
99
+
```cpp
100
+
daecpp::SolutionHolder sol;
101
+
102
+
double t_end = sol.t.back(); // Time `t_end` at the last time step
103
+
daecpp::state_vector x_end = sol.x.back(); // Solution vector at time `t_end`
By default, prints the entire vector `x` and the corresponding time `t`.
113
+
114
+
### Parameter:
115
+
116
+
- (optional) `ind` - vector of solution indices (out of range indices will be ignored) for printing (`std::vector<std::size_t>`)
117
+
118
+
### Example:
119
+
120
+
```cpp
121
+
daecpp::SolutionHolder sol;
122
+
123
+
// Prints only 0th, 1st, and 42nd elements of the solution vector
124
+
sol.print({0, 1, 42});
125
+
```
126
+
127
+
----
128
+
129
+
# Solution class
130
+
131
+
Solution class `daecpp::Solution` is derived from `daecpp::SolutionManager` and serves as a basic solution *observer* that writes solution vectors `x` and the corresponding times `t` every time step or every specific time from `t_output` vector (that can be optionally provided in the constructor) into `daecpp::SolutionHolder` class object. The Solution class is also used in the [`daecpp::System`](solve.html) class as a default Solution Manager.
0 commit comments