Code implementation of my Bachelors thesis on numerical method C++23 library https://www.vut.cz/en/students/final-thesis/detail/172950
  • C++ 69.5%
  • Gnuplot 15.4%
  • MATLAB 7.6%
  • Makefile 3.2%
  • CMake 2.6%
  • Other 1.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-07-10 06:23:28 +02:00
src try to fix ben 2026-07-10 05:50:42 +02:00
tests fix the test 10 relative error calculation 2026-07-10 05:50:42 +02:00
.gitignore add gitignore 2026-07-10 06:23:28 +02:00
CMakeLists.txt add precision test 2026-07-10 05:50:33 +02:00
docker-compose.yml add dockerfile + docker compose 2026-07-10 05:50:38 +02:00
Dockerfile fix dockerfile 2026-07-10 05:50:40 +02:00
LICENSE.txt add license 2026-07-10 05:57:12 +02:00
Makefile t10 diagnostic, t2 gp rename 2026-07-10 05:50:40 +02:00
README.md update integrify readme 2026-07-10 05:50:39 +02:00
thesis.pdf add thesis text 2026-07-10 05:59:22 +02:00

integrify

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.
  • make run

    • Runs the main test executable from build/test_circle (this can be either circle test or Van der Pol oscillator - define macro in src/test-circle.cpp)
    • Also generates plots for all available methods and step sizes using gnuplot.
  • make clean

    • Removes the build/ and data/ folders, deletes generated PDFs, and recreates clean directories.
  • make cleandata

    • Removes generated data files only.
  • make cleandatarun

    • Cleans data and then runs make run.
  • make remake

    • Equivalent to make clean followed by make all.
  • make test1 - Circle test

    • Builds the project, runs build/t1-circle, writes data.txt, and creates the tests/t1-circle.gp plot.
  • make test2 - Van der Pol oscillator test

    • Builds the project, generates reference data from Octave, runs build/t2-vdp, and plots tests/t2-vdp.gp.
  • make test3 - Lorenz equations test

    • Builds the project, generates reference data, runs build/t3-lorenz, and creates the Lorenz error plot.
  • make test4 - Ideal pendulum test

    • Builds the project, generates reference data, runs build/t4-pendulum, and creates the pendulum plot.
  • 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.
  • make test6 - HIRES test

    • Builds the project and runs build/t6-hires.
  • make test7 - Robertson problem test

    • Builds the project and runs build/t7-rober.
  • make test8 - Duffing oscillator test

    • Builds the project, generates reference data, runs build/t8-duffing, and plots the Duffing results.
  • make test9 - RLC series circuit test

    • Builds the project, generates reference data, and runs build/t9-rlc.
  • make test10 - Exponential decay test

    • Builds the project and runs build/t10-decay.

Notes

  • Each test program in tests/t*.cpp uses the numerical method selected in its source code.
  • You can swap the numerical method in any tests/t*.cpp file for a different one if you want to compare methods.
  • make run performs the main test with all methods and a range of different step sizes automatically.