File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020bmi-example-python
2121==================
2222
23- An example BMI implementation written in Python
23+ An example of implementing the `Python bindings `_
24+ for the CSDMS `Basic Model Interface `_ (BMI).
25+
26+ Overview
27+ --------
28+
29+ This is an example of implementing a BMI for a simple model
30+ that solves the diffusion equation
31+ on a uniform rectangular plate
32+ with Dirichlet boundary conditions.
33+ The model and its BMI are written in Python 3.
34+ Tests of the BMI are provided.
35+
36+ This repository is organized with the following directories:
37+
38+ *heat *
39+ Holds the model and the BMI for the model
40+
41+ *tests *
42+ Tests that cover the BMI of the model
43+
44+ Build/Install
45+ -------------
46+
47+ This example can be built and installed on Linux, macOS, and Windows.
48+
49+ **Prerequisites: **
50+
51+ * Python 3
52+ * The Python BMI bindings. Follow the build and install directions
53+ given in the `README `_ in that repository. You can choose to install
54+ them from source, or through pip, or conda.
55+
56+ To build/install this example from source,
57+ using the current Python BMI version, run
58+
59+ .. code-block :: bash
60+
61+ $ make install
62+
63+ To run the tests,
64+
65+ .. code-block :: bash
66+
67+ $ pip install -r requirements.txt
68+ $ make test
69+
70+
71+ .. _Python bindings : https://github.com/csdms/bmi-python
72+ .. _Basic Model Interface : https://bmi-spec.readthedocs.io
73+ .. _README : https://github.com/csdms/bmi-python/blob/master/README.rst
Original file line number Diff line number Diff line change @@ -263,6 +263,14 @@ def get_component_name(self):
263263 """Name of the component."""
264264 return self ._name
265265
266+ def get_input_item_count (self ):
267+ """Get names of input variables."""
268+ return len (self ._input_var_names )
269+
270+ def get_output_item_count (self ):
271+ """Get names of output variables."""
272+ return len (self ._output_var_names )
273+
266274 def get_input_var_names (self ):
267275 """Get names of input variables."""
268276 return self ._input_var_names
@@ -323,6 +331,9 @@ def get_grid_node_count(self, grid):
323331 def get_grid_nodes_per_face (self , grid , nodes_per_face ):
324332 raise NotImplementedError ("get_grid_nodes_per_face" )
325333
334+ def get_grid_face_edges (self , grid , face_edges ):
335+ raise NotImplementedError ("get_grid_face_edges" )
336+
326337 def get_grid_x (self , grid , x ):
327338 raise NotImplementedError ("get_grid_x" )
328339
Original file line number Diff line number Diff line change 1919 "Programming Language :: Python :: 3" ,
2020 "Programming Language :: Python :: 3.6" ,
2121 "Programming Language :: Python :: 3.7" ,
22+ "Programming Language :: Python :: 3.8" ,
2223 "Programming Language :: Python :: Implementation :: CPython" ,
2324 "Topic :: Scientific/Engineering :: Physics" ,
2425 ],
Original file line number Diff line number Diff line change @@ -18,6 +18,17 @@ def test_grid_var_names():
1818 assert names == ("plate_surface__temperature" ,)
1919
2020
21+ def test_grid_var_item_count ():
22+ model = BmiHeat ()
23+ model .initialize ()
24+
25+ count = model .get_input_item_count ()
26+ assert count == 1
27+
28+ count = model .get_output_item_count ()
29+ assert count == 1
30+
31+
2132def test_grid_var_units ():
2233 model = BmiHeat ()
2334 model .initialize ()
You can’t perform that action at this time.
0 commit comments