Skip to content

Commit

Permalink
Merge pull request #537 from ModECI/nml_examples
Browse files Browse the repository at this point in the history
 Ensure numpy<2.0.0 in tests, due to lingering issues with other modules
  • Loading branch information
pgleeson authored Jun 18, 2024
2 parents f8f8635 + 98ecf2e commit 59aebdd
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ jobs:
brew install hdf5
- name: Install core package
run: python -m pip install .[dev]
run: |
pip install 'numpy<2.0.0' # due to lingering issues with other modules & numpy v2...
python -m pip install .[dev]
- name: Version info for installed packages
run: |
pip list
pip list
- name: Test core package
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,5 @@ examples/TensorFlow/Keras/keras_to_MDF
/examples/TensorFlow/Keras/IRIS/keras_model_on_iris.keras
/examples/TensorFlow/Keras/MNIST/kr_N_model.keras
/checkoutpngs.sh
/docs/sphinx/source/api/export_format/MDF/images/newton.png
/docs/sphinx/source/api/export_format/MDF/images/newton_plot.png
12 changes: 11 additions & 1 deletion docs/sphinx/source/api/export_format/MDF/MDF.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Examples of [Python](https://python.org), [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON#:~:text=JavaScript%20Object%20Notation%20(JSON)%20is,page%2C%20or%20vice%20versa) and [YAML](https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/) files to illustrate the structure and usage of MDF.

<a href="#simple"> Simple </a>| <a href="#abcd"> ABCD </a> | <a href="#arrays"> Arrays </a> | <a href="#st"> States </a> | <a href="#conditions"> Conditions </a> | <a href="#parameters-and-functions"> Parameters and Functions </a>
<a href="#simple"> Simple </a>| <a href="#abcd"> ABCD </a> | <a href="#arrays"> Arrays </a> | <a href="#st"> States </a> | <a href="#conditions"> Conditions </a> | <a href="#parameters-and-functions"> Parameters and Functions </a>| <a href="#newton"> Newton's Law of Cooling</a>

<p id="simple"></p>

Expand Down Expand Up @@ -73,6 +73,16 @@ A simple 3 [Nodes](https://mdf.readthedocs.io/en/latest/api/Specification.html#n
A simple [Node](https://mdf.readthedocs.io/en/latest/api/Specification.html#node) with a number of different types of [Parameters](https://mdf.readthedocs.io/en/latest/api/Specification.html#parameter) (in blue; fixed and **stateful**) and [Functions](https://mdf.readthedocs.io/en/latest/api/Specification.html#function) (in purple; can be built in or ONNX based).

<img src="https://raw.githubusercontent.com/ModECI/MDF/main/examples/MDF/images/params_funcs.png" width="250" height="198" />
<p id="newton"></p>

## Newton's Law of Cooling

[Python Source](https://github.com/ModECI/MDF/blob/main/examples/MDF/newton.py) | [JSON](https://github.com/ModECI/MDF/blob/main/examples/MDF/NewtonCoolingModel.json) | [YAML](https://github.com/ModECI/MDF/blob/main/examples/MDF/NewtonCoolingModel.yaml)

A simple [Newtonian cooling process](https://en.wikipedia.org/wiki/Newton%27s_law_of_cooling) model that demonstrates the use of time derivative simulating the cooling of an object to the ambient temperature over time.

<img src="https://raw.githubusercontent.com/ModECI/MDF/development/examples/MDF/images/newton.png" width="250"/>
<img src="https://raw.githubusercontent.com/ModECI/MDF/development/examples/MDF/images/newton_plot.png" width="250"/>


## More examples
Expand Down
2 changes: 1 addition & 1 deletion examples/MDF/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Examples of [Python](https://python.org), [JSON](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON#:~:text=JavaScript%20Object%20Notation%20(JSON)%20is,page%2C%20or%20vice%20versa) and [YAML](https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/) files to illustrate the structure and usage of MDF.

<a href="#simple"> Simple </a>| <a href="#abcd"> ABCD </a> | <a href="#arrays"> Arrays </a> | <a href="#st"> States </a> | <a href="#conditions"> Conditions </a> | <a href="#parameters-and-functions"> Parameters and Functions </a>| <a href="#newton"> Newton'a Law of Cooling</a>
<a href="#simple"> Simple </a>| <a href="#abcd"> ABCD </a> | <a href="#arrays"> Arrays </a> | <a href="#st"> States </a> | <a href="#conditions"> Conditions </a> | <a href="#parameters-and-functions"> Parameters and Functions </a>| <a href="#newton"> Newton's Law of Cooling</a>

<p id="simple"></p>

Expand Down
15 changes: 8 additions & 7 deletions examples/MDF/newton.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@ def main():
s.append(eg.enodes["cool_node"].evaluable_outputs["out_port"].curr_value)
t += dt

# Plotting the results
plt.plot(times, s)
plt.xlabel("Time")
plt.ylabel("Temperature")
plt.title("Newton's Cooling Law Simulation")
plt.savefig("newton_plot.png")
plt.show()
if "-nogui" not in sys.argv:
# Plotting the results
plt.plot(times, s)
plt.xlabel("Time")
plt.ylabel("Temperature")
plt.title("Newton's Cooling Law Simulation")
plt.savefig("newton_plot.png")
plt.show()

if "-graph" in sys.argv:
mod.to_graph_image(
Expand Down
2 changes: 1 addition & 1 deletion examples/NeuroML/LEMS_SimABCD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--
This LEMS file has been automatically generated using PyNeuroML v1.2.12 (libNeuroML v0.5.8)
This LEMS file has been automatically generated using PyNeuroML v1.2.14 (libNeuroML v0.5.8)
-->

Expand Down
2 changes: 1 addition & 1 deletion examples/NeuroML/LEMS_SimFN.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--
This LEMS file has been automatically generated using PyNeuroML v1.2.12 (libNeuroML v0.5.8)
This LEMS file has been automatically generated using PyNeuroML v1.2.14 (libNeuroML v0.5.8)
-->

Expand Down
2 changes: 1 addition & 1 deletion examples/NeuroML/LEMS_SimIzhikevichTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!--
This LEMS file has been automatically generated using PyNeuroML v1.2.12 (libNeuroML v0.5.8)
This LEMS file has been automatically generated using PyNeuroML v1.2.14 (libNeuroML v0.5.8)
-->

Expand Down

0 comments on commit 59aebdd

Please sign in to comment.