This package ports the csdms/bmi-example-python heat equation demo to R. It shows how to wrap an R-based model with the bmi package so it can be controlled through the Basic Model Interface.
Assuming you have the bmi package installed locally, you can install this example from a checkout:
# from within the bmi-example-r directory
devtools::install()library(bmi.example.heat)
bmi <- BmiHeat$new()
bmi$bmi_initialize(system.file("extdata", "heat.yaml", package = "bmi.example.heat"))
bmi$get_component_name()
#> "The 2D Heat Equation"
bmi$get_time_step()
#> 0.25
bmi$update() # advance one step
bmi$update_until(2.0) # run to model time = 2.0 seconds
temps <- bmi$get_value_ptr("plate_surface__temperature")
dim(temps)
#> 6 8
bmi$bmi_finalize()To run the automated checks:
library(testthat)
testthat::test_local()This example preserves the original MIT license from the Python version.