Skip to content

eWaterCycle/bmi-example-r

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

An example of wrapping a model written in R with a BMI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages