#model #ode #fmu #modelica #api-bindings #fmi

fmu-runner

A high level Rust wrapper for executing FMU's that follow the FMI 2.0 standard

6 releases (3 breaking)

0.4.1 Mar 6, 2024
0.4.0 Oct 18, 2023
0.3.0 Oct 17, 2023
0.2.0 Oct 11, 2023
0.1.1 Oct 10, 2023

#70 in Simulation

Download history 149/week @ 2023-12-22 117/week @ 2023-12-29 474/week @ 2024-01-05 141/week @ 2024-01-12 169/week @ 2024-01-19 278/week @ 2024-01-26 395/week @ 2024-02-02 145/week @ 2024-02-09 95/week @ 2024-02-16 183/week @ 2024-02-23 359/week @ 2024-03-01 206/week @ 2024-03-08 159/week @ 2024-03-15 77/week @ 2024-03-22 111/week @ 2024-03-29 111/week @ 2024-04-05

556 downloads per month

MIT/Apache

91KB
2.5K SLoC

Rust FMU Runner library

Crates.io Documentation Crates.io

A high level Rust wrapper for executing FMU's that follow the FMI 2.0 standard.

This library contains bindings to the fmi-standard and offers a high-level, safe API for unpacking, parsing, loading and executing FMU's.

Example

use std::{collections::HashMap, path::Path};
use fmu_runner::{Fmu, FmuInstance, fmi2Type};

let fmu = Fmu::unpack(Path::new("./tests/fmu/bouncing_ball.fmu"))?
    .load(fmi2Type::fmi2CoSimulation)?;

let fmu_cs = FmuInstance::instantiate(&fmu, true)?;
let signals = fmu_cs.lib.variables();

fmu_cs.setup_experiment(0.0, None, None)?;

// Set initial height to 10m.
fmu_cs.set_reals(&HashMap::from([(&signals["h_start"], 10.0)]))?;

// Initialize model.
fmu_cs.enter_initialization_mode()?;
fmu_cs.exit_initialization_mode()?;

// Step model 1 second.
fmu_cs.do_step(0.0, 1.0, true)?;

// Get the current height.
let outputs = fmu_cs.get_reals(&[&signals["h_m"]])?;
println!("{}", fmu_runner::outputs_to_string(&outputs));

Dependencies

~8–19MB
~241K SLoC