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
Note that in `dae-cpp`, the mass matrix can depend on time $$t$$ (but not on the state $$\mathbf{x}$$) and can be singular, which means that one or more of the rows of the matrix can contain zeros only, i.e., some of the equations in the system can be without time derivatives at all (nonlinear algebraic equations).
14
+
15
+
## Mass matrix definition
16
+
17
+
The main mass matrix class `daecpp::MassMatrix` is an abstract class that provides an interface to define the mass matrix $$\mathbf{M}(t)$$.
18
+
In order to make use of this class, the user should inherit it and overload the `()` operator:
Inhereting the `daecpp::MassMatrix` class is a good practice (it serves as a blueprint), however, the user is allowed to define mass matrices using their own custom classes, for example:
It is recommended to pre-allocate memory for the mass matrix using `reserve(N_elements)` method, where `N_elements` is the number of non-zero elements in the matrix. If the number of non-zeros is difficult to estimate, it is better to overestimate `N_elements` than underestimate it to avoid unnecessary copying and memory reallocations.
78
+
79
+
For more information about defining the matrix in sparse format, refer to the [Sparse Matrix](sparse-matrix.html) section.
80
+
81
+
## Identity mass matrix
82
+
83
+
A helper class `daecpp::MassMatrixIdentity` can be used to construct an identity matrix `N` by `N`:
84
+
85
+
```cpp
86
+
daecpp::MassMatrixIdentity identityMatrix(16); // Creates identity mass matrix 16x16
87
+
```
88
+
89
+
In the example above, we created an object `identityMatrix` which holds an identity matrix of size 16x16 in sparse format suitable for the solver.
90
+
91
+
## Zero mass matrix
92
+
93
+
Similar ot the example above, a helper class `daecpp::MassMatrixZero` can be used to construct a zero matrix (a matrix filled by zeros only). This matrix can be useful to solve pure algebraic systems without time derivatives.
13
94
14
-
## Subtitle
95
+
```cpp
96
+
daecpp::MassMatrixZero zeroMatrix; // Creates empty mass matrix for algebraic system
97
+
```
15
98
16
-
Text
99
+
Note that `daecpp::MassMatrixZero` does not require the matrix size (unlike `MassMatrixIdentity`), because zero matrix does not contain any non-zero elements. It's an empty sparse matrix, and its size will be derived from the initial state vector size.
0 commit comments