{"id":23832043,"url":"https://github.com/csdms/bmi-example-java","last_synced_at":"2025-02-22T03:14:46.161Z","repository":{"id":45630346,"uuid":"429604805","full_name":"csdms/bmi-example-java","owner":"csdms","description":"An example of wrapping a model written in Java with a BMI ","archived":false,"fork":false,"pushed_at":"2022-02-22T00:41:14.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-01-02T14:17:01.833Z","etag":null,"topics":["bmi","csdms","java","maven"],"latest_commit_sha":null,"homepage":"https://bmi.csdms.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csdms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-18T23:02:45.000Z","updated_at":"2024-12-03T22:41:40.000Z","dependencies_parsed_at":"2022-09-10T21:01:03.235Z","dependency_job_id":null,"html_url":"https://github.com/csdms/bmi-example-java","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csdms%2Fbmi-example-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csdms%2Fbmi-example-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csdms%2Fbmi-example-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csdms%2Fbmi-example-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csdms","download_url":"https://codeload.github.com/csdms/bmi-example-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240118427,"owners_count":19750491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bmi","csdms","java","maven"],"created_at":"2025-01-02T14:17:09.053Z","updated_at":"2025-02-22T03:14:46.142Z","avatar_url":"https://github.com/csdms.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Basic Model Interface](https://img.shields.io/badge/CSDMS-Basic%20Model%20Interface-green.svg)](https://bmi.readthedocs.io/)\n[![Build CI](https://github.com/csdms/bmi-example-java/actions/workflows/build.yml/badge.svg)](https://github.com/csdms/bmi-example-java/actions/workflows/build.yml)\n\n# bmi-example-java\n\nAn example of implementing the [Java specification][bmi-java]\nfor the CSDMS [Basic Model Interface][bmi] (BMI).\n\n\n## Overview\n\nThis is an example of implementing a BMI\nfor a simple model that solves the diffusion equation\non a uniform rectangular plate\nwith Dirichlet boundary conditions.\nTests and examples of using the BMI are provided.\nThe model and its BMI are written in Java.\n\nThis project is organized as follows:\n\n\u003cdl\u003e\n    \u003cdt\u003esrc/main/java\u003c/dt\u003e\n\t\u003cdd\u003e\u003cem\u003eedu.colorado.csdms.heat\u003c/em\u003e: Holds the model and a sample main program\u003c/dd\u003e\n\t\u003cdd\u003e\u003cem\u003eedu.colorado.csdms.bmiheat\u003c/em\u003e: Holds the BMI for the model and a main   program to run the model through its BMI\u003c/dd\u003e\n\t\u003cdd\u003e\u003cem\u003eedu.colorado.csdms.example\u003c/em\u003e: A helper to hold the main programs\u003c/dd\u003e\n\t\u003cdt\u003esrc/test/java\u003c/dt\u003e\n\t\u003cdd\u003e\u003cem\u003eedu.colorado.csdms.heat\u003c/em\u003e: Unit tests for the model\u003c/dd\u003e\n\t\u003cdd\u003e\u003cem\u003eedu.colorado.csdms.bmiheat\u003c/em\u003e: Unit tests for the model BMI\u003c/dd\u003e\n\u003c/dl\u003e\n\n## Build/Install\n\nThis example can be built on Linux, macOS, and Windows.\n\n**Prerequisites:**\n* A Java compiler\n* [Maven](http://maven.apache.org)\n* The Java BMI specification. The `pom.xml` in this project is configured to automatically download the `bmi` package from the [CSDMS Apache Maven Repository][csdms-maven-repo]\n\nTo compile and package the BMI Java bindings, run\n\n    $ mvn clean verify\n\nThis will generate files in the project directory `target`.\nThe result will look like\n```bash\ntarget\n|-- bmi-example-java.jar\n|-- classes\n|   `-- edu\n|       `-- colorado\n|           `-- csdms\n|               |-- bmiheat\n|               |   `-- BmiHeat.class\n|               |-- example\n|               |   `-- Examples.class\n|               `-- heat\n|                   |-- Heat.class\n|                   |-- HeatConfigFile.class\n|                   `-- Solve2D.class\n|-- generated-sources\n|   `-- annotations\n|-- generated-test-sources\n|   `-- test-annotations\n|-- maven-archiver\n|   `-- pom.properties\n|-- maven-status\n|   `-- maven-compiler-plugin\n|       |-- compile\n|       |   `-- default-compile\n|       |       |-- createdFiles.lst\n|       |       `-- inputFiles.lst\n|       `-- testCompile\n|           `-- default-testCompile\n|               |-- createdFiles.lst\n|               `-- inputFiles.lst\n|-- surefire-reports\n|   |-- TEST-edu.colorado.csdms.bmiheat.TestGetAndSetValue.xml\n|   |-- TEST-edu.colorado.csdms.bmiheat.TestGridMethods.xml\n|   |-- TEST-edu.colorado.csdms.bmiheat.TestIRF.xml\n|   |-- TEST-edu.colorado.csdms.bmiheat.TestVarMethods.xml\n|   |-- TEST-edu.colorado.csdms.heat.HeatTest.xml\n|   |-- edu.colorado.csdms.bmiheat.TestGetAndSetValue.txt\n|   |-- edu.colorado.csdms.bmiheat.TestGridMethods.txt\n|   |-- edu.colorado.csdms.bmiheat.TestIRF.txt\n|   |-- edu.colorado.csdms.bmiheat.TestVarMethods.txt\n|   `-- edu.colorado.csdms.heat.HeatTest.txt\n`-- test-classes\n    |-- data\n    |   `-- heat.xml\n    `-- edu\n        `-- colorado\n            `-- csdms\n                |-- bmiheat\n                |   |-- TestGetAndSetValue.class\n                |   |-- TestGridMethods.class\n                |   |-- TestIRF.class\n                |   `-- TestVarMethods.class\n                `-- heat\n                    `-- HeatTest.class\n\n26 directories, 27 files\n```\n\nTo install the jar file to your local Maven repository\n(typically `~/.m2/repository`), run\n\n    $ mvn install\n\nThe result in the local repository will look like\n```bash\nedu\n`-- colorado\n    `-- csdms\n        |-- bmi\n        |   |-- 2.0\n        |   |   |-- _remote.repositories\n        |   |   |-- bmi-2.0.jar\n        |   |   |-- bmi-2.0.jar.md5\n        |   |   |-- bmi-2.0.jar.sha1\n        |   |   |-- bmi-2.0.pom\n        |   |   |-- bmi-2.0.pom.md5\n        |   |   `-- bmi-2.0.pom.sha1\n        |   |-- maven-metadata-local.xml\n        |   |-- maven-metadata-local.xml.md5\n        |   `-- maven-metadata-local.xml.sha1\n        `-- bmi-example-java\n            |-- 1.0\n            |   |-- _remote.repositories\n            |   |-- bmi-example-java-1.0.jar\n            |   `-- bmi-example-java-1.0.pom\n            `-- maven-metadata-local.xml\n\n6 directories, 14 files\n```\nNote that the `bmi` package is also present.\n\n\n## Use\n\nRun the Heat model through its BMI with\n\n    $ mvn exec:java\n\nBoth the Heat and the BmiHeat examples are run, with output\n```\n*\n* Example: Heat Model\n*\nshape: [8, 6]\nspacing: [1.0, 1.0]\norigin: [0.0, 0.0]\ntime = 0.0\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00 100.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\ntime = 0.25\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00  12.50   0.00   0.00   0.00\n   0.00  12.50  50.00  12.50   0.00   0.00\n   0.00   0.00  12.50   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\ntime = 0.5\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   1.56   0.00   0.00   0.00\n   0.00   3.13  12.50   3.13   0.00   0.00\n   0.00  12.50  31.25  12.50   1.56   0.00\n   0.00   3.13  12.50   3.13   0.00   0.00\n   0.00   0.00   1.56   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\ntime = 0.75\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.59   2.34   0.59   0.00   0.00\n   0.00   4.69  11.13   4.69   0.59   0.00\n   0.00  10.94  21.88  11.13   2.34   0.00\n   0.00   4.69  11.13   4.69   0.59   0.00\n   0.00   0.59   2.34   0.59   0.00   0.00\n   0.00   0.00   0.20   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n*\n* Example: Heat Model run through its BMI\n*\nModel name: Heat\nStart time: 0.0\nEnd time: 1.7976931348623157E308\nCurrent time: 0.0\nTime step: 0.25\nTime unit: null\nInput variables: \n- plate_surface__temperature\nOutput variables: \n- plate_surface__temperature\nVariable: plate_surface__temperature\n- grid_id: 0\n- grid type: uniform_rectilinear\n- grid rank: 2\n- grid size: 48\n- grid shape:\n  - 8\n  - 6\n- grid spacing:\n  - 1.0\n  - 1.0\n- grid origin:\n  - 0.0\n  - 0.0\n- var type: double\n- var units: K\n- var itemsize: 8\n- var nbytes: 384\ntime = 0.0\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00 100.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\ntime = 0.25\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00  12.50   0.00   0.00   0.00\n   0.00  12.50  50.00  12.50   0.00   0.00\n   0.00   0.00  12.50   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\ntime = 0.5\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   1.56   0.00   0.00   0.00\n   0.00   3.13  12.50   3.13   0.00   0.00\n   0.00  12.50  31.25  12.50   1.56   0.00\n   0.00   3.13  12.50   3.13   0.00   0.00\n   0.00   0.00   1.56   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\ntime = 0.75\ntemperature =\n   0.00   0.00   0.00   0.00   0.00   0.00\n   0.00   0.59   2.34   0.59   0.00   0.00\n   0.00   4.69  11.13   4.69   0.59   0.00\n   0.00  10.94  21.88  11.13   2.34   0.00\n   0.00   4.69  11.13   4.69   0.59   0.00\n   0.00   0.59   2.34   0.59   0.00   0.00\n   0.00   0.00   0.20   0.00   0.00   0.00\n   0.00   0.00   0.00   0.00   0.00   0.00\n```\n\nIf you'd like to experiment,\ntry changing the model parameter values in the file\n`src/test/resources/data/heat.xml`,\nthen recompiling and running the examples again.\nIs temperature on the plate conserved?\n\n\u003c!-- Links --\u003e\n[bmi]: https://bmi-spec.readthedocs.io\n[bmi-java]: https://github.com/csdms/bmi-java\n[csdms-maven-repo]: https://csdms.colorado.edu/repository\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsdms%2Fbmi-example-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsdms%2Fbmi-example-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsdms%2Fbmi-example-java/lists"}