Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 1.16 KB

File metadata and controls

49 lines (32 loc) · 1.16 KB

BMI Heat Example in R

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.

Installation

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()

Usage

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()

Tests

To run the automated checks:

library(testthat)
testthat::test_local()

License

This example preserves the original MIT license from the Python version.