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

fmu-runner

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

8 releases

0.4.3 Aug 8, 2024
0.4.2 Jul 15, 2024
0.4.1 Mar 6, 2024
0.4.0 Oct 18, 2023
0.1.1 Oct 10, 2023

#74 in Simulation

Download history 252/week @ 2024-07-29 321/week @ 2024-08-05 202/week @ 2024-08-12 236/week @ 2024-08-19 244/week @ 2024-08-26 248/week @ 2024-09-02 598/week @ 2024-09-09 333/week @ 2024-09-16 529/week @ 2024-09-23 386/week @ 2024-09-30 509/week @ 2024-10-07 452/week @ 2024-10-14 629/week @ 2024-10-21 527/week @ 2024-10-28 395/week @ 2024-11-04 229/week @ 2024-11-11

1,815 downloads per month

MIT/Apache

93KB
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–18MB
~251K SLoC