- C++ 69.5%
- Gnuplot 15.4%
- MATLAB 7.6%
- Makefile 3.2%
- CMake 2.6%
- Other 1.7%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| tests | ||
| .gitignore | ||
| CMakeLists.txt | ||
| docker-compose.yml | ||
| Dockerfile | ||
| LICENSE.txt | ||
| Makefile | ||
| README.md | ||
| thesis.pdf | ||
integrify
Build and run in Docker (recommended)
The project provides a Dockerfile for a reproducible build environment.
Build the Docker image:
docker compose up
Run a shell inside the container:
docker compose run integrify
Then inside the container, run:
make
Warning
Docker compose mounts current directory into the container - this allows live development without rebuilding the image - but be careful to only build from a container or from the host machine, but never both at the same time.
Build locally
From the integrify directory:
make
This creates build/ with CMake and Ninja, then builds all executable targets.
Prerequisites
See Dockerfile to see the complete list of requirements. But the main
requirements are:
- Clang 21
- GNU Make
- cmake
- gnuplot (for tests)
- GNU octave (for tests)
Directory structure
-
build/- Generated build directory created by CMake and Ninja.
- Contains compiled binaries and build artifacts for all targets.
-
data/- Stores generated output data and results from test runs.
- Used for plots and metadata
-
src/- Main C++ source files for the integrify project.
- Includes implementations of numerical methods, the project entry point, test harnesses, and helper modules.
-
tests/- Individual test source files for the supported problems.
- Includes plots, reference generation scripts, and example problem setups for circle, Van der Pol, Lorenz, pendulum, predator-prey, HIRES, Robertson, Duffing, RLC, and decay tests.
-
Dockerfile- Defines the container environment used for reproducible builds.
-
docker-compose.yml- Enables building and running the container with Docker Compose.
-
Makefile- Top-level build script for configuring, building, cleaning, and running the project.
-
README.md- This documentation file.
Write your own simulation
To write your own simulation and link the library, do the following.
Create your simulation file (e. g. sim.cpp)
/* sim.cpp */
#include <array>
#include <print>
import integrify;
using state_t = std::array<double, 1>;
void system(const state_t &y, state_t &dydt, double /* t */) {
/* exponential decay */
double k = 4.0;
dydt[0] = - k * y[0];
}
void simulate(integrify::steppable auto& stepper) {
/* initial value */
state_t y = { 100.0 };
/* simulation parameters */
double t_start = 0.0;
double t_end = 10.0;
double step_size = 0.001;
double t = 0.0;
while (t < t_end) {
std::println("{} {}", t, y[0]);
stepper.do_step(system, y, t, step_size);
t += step_size;
}
}
int main() {
/* choose method for the simulation */
integrify::rk4_method<state_t> rk4;
simulate(rk4);
}
Add your file as a build target
Add the following two lines at the end of CMakeLists.txt
add_executable(sim sim.cpp)
target_link_libraries(sim PRIVATE integrify_lib)
Simulation will be compiled into build/sim.
Make targets
-
make/make all- Configures the
build/folder with CMake and builds all binaries with Ninja.
- Configures the
-
make run- Runs the main test executable from
build/test_circle(this can be either circle test or Van der Pol oscillator - define macro insrc/test-circle.cpp) - Also generates plots for all available methods and step sizes using
gnuplot.
- Runs the main test executable from
-
make clean- Removes the
build/anddata/folders, deletes generated PDFs, and recreates clean directories.
- Removes the
-
make cleandata- Removes generated data files only.
-
make cleandatarun- Cleans data and then runs
make run.
- Cleans data and then runs
-
make remake- Equivalent to
make cleanfollowed bymake all.
- Equivalent to
-
make test1- Circle test- Builds the project, runs
build/t1-circle, writesdata.txt, and creates thetests/t1-circle.gpplot.
- Builds the project, runs
-
make test2- Van der Pol oscillator test- Builds the project, generates reference data from Octave, runs
build/t2-vdp, and plotstests/t2-vdp.gp.
- Builds the project, generates reference data from Octave, runs
-
make test3- Lorenz equations test- Builds the project, generates reference data, runs
build/t3-lorenz, and creates the Lorenz error plot.
- Builds the project, generates reference data, runs
-
make test4- Ideal pendulum test- Builds the project, generates reference data, runs
build/t4-pendulum, and creates the pendulum plot.
- Builds the project, generates reference data, runs
-
make test5- Predator-Prey (Lotka-Volterra) test- Builds the project, generates reference data, runs
build/t5-predator-prey, produces predator-prey plots, and generates error output.
- Builds the project, generates reference data, runs
-
make test6- HIRES test- Builds the project and runs
build/t6-hires.
- Builds the project and runs
-
make test7- Robertson problem test- Builds the project and runs
build/t7-rober.
- Builds the project and runs
-
make test8- Duffing oscillator test- Builds the project, generates reference data, runs
build/t8-duffing, and plots the Duffing results.
- Builds the project, generates reference data, runs
-
make test9- RLC series circuit test- Builds the project, generates reference data, and runs
build/t9-rlc.
- Builds the project, generates reference data, and runs
-
make test10- Exponential decay test- Builds the project and runs
build/t10-decay.
- Builds the project and runs
Notes
- Each test program in
tests/t*.cppuses the numerical method selected in its source code. - You can swap the numerical method in any
tests/t*.cppfile for a different one if you want to compare methods. make runperforms the main test with all methods and a range of different step sizes automatically.