Skip to content

Commit ac37aae

Browse files
committed
Update utilities and examples pages
1 parent 33db0b4 commit ac37aae

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

docs/examples.md

+17
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,24 @@ Work in progress
1111

1212
## Quick Start
1313

14+
The Quick Start example can be found in the [Quick Start](quick-start.html) section and in the [quick_start.cpp](https://github.com/dae-cpp/dae-cpp/blob/master/examples/quick_start/quick_start.cpp) source file.
15+
{: .fs-5 .fw-400 }
16+
17+
A basic example of how to start solving a very simple DAE using the [`System`](solve.html#system-class) class.
18+
1419
## Simple DAE
1520

21+
Simple DAE source file example: [simple_dae.cpp](https://github.com/dae-cpp/dae-cpp/blob/master/examples/simple_dae/simple_dae.cpp)
22+
{: .fs-5 .fw-400 }
23+
24+
Here we solve another simple system of DAEs.
25+
This example introduces [Solution Manager](solution-manager.html), that will work as solution observer.
26+
1627
## Perovskite model
1728

29+
Perovskite model source file example: [perovskite.cpp](https://github.com/dae-cpp/dae-cpp/blob/master/examples/perovskite_model/perovskite.cpp)
30+
{: .fs-5 .fw-400 }
31+
32+
A more sophisticated example, where we solve a big DAE system that describes potential distribution and ion concentration in a perovskite solar cell.
33+
We show how to add parameters to the user-defined mass matrix, vector function, and Jacobian.
34+
This example also demonstrates a custom [Solution Manager](solution-manager.html) implementation that can work as an observer and event function.

docs/utilities.md

+38-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,44 @@ layout: default
44
nav_order: 9
55
---
66

7-
Work in progress
8-
{: .label .label-red }
9-
107
# Utility functions and constants
118

12-
TODO:
9+
This section describes utility functions and constants that can be useful in the user's project.
10+
11+
## Get the solver version
12+
13+
The current version of `dae-cpp` can be obtained either by using the following macro:
14+
15+
```cpp
16+
DAECPP_VERSION_MAJOR
17+
DAECPP_VERSION_MINOR
18+
DAECPP_VERSION_PATCH
19+
```
20+
21+
or by accessing the following constants (`static constexpr uint16_t`) in the `daecpp` namespace:
22+
23+
```cpp
24+
daecpp::version_major
25+
daecpp::version_minor
26+
daecpp::version_patch
27+
```
28+
29+
## Timer
30+
31+
`dae-cpp` provides a simple timer based on `std::chrono::steady_clock` which is used internally in the solver, but it is also exposed for the user in the `daecpp` namespace.
32+
The timer measures time spent by the program in the given scope and saves it in **milliseconds** in a variable of type `double`:
33+
34+
```cpp
35+
double time{0.0}; // Stores time (in ms)
36+
{
37+
daecpp::Timer timer(&time); // Starts the timer
38+
39+
// << TASK >>
40+
41+
} // End of scope stops the timer
42+
```
43+
44+
In the example above, we initialize the variable `time`, which will store the time in milliseconds.
45+
Then we define the scope and create an object of class `daecpp::Timer` by passing the address of the variable `time`. Constructing this object starts the timer. When we reach the end of the scope that we defined, the `timer` object will be destroyed. This stops the timer, and the computation time (in milliseconds) will be written into the `time` variable.
1346
14-
- [ ] Get solver version
15-
- [ ] Timer
47+
Note that the `time` variable can be reused. We can start a new timer in another scope passing the address of `time` again. The computation time will be added to the previous value.

0 commit comments

Comments
 (0)