A Notebook style interface (Jupyter) is used to run an Open Loop simulation.
The example simulation uses a simple CSV file, presented in a Notebook, to operate an Open Loop simulation which represents an Linear Equation.
Install the following VS Code extensions:
- Install the "Jupyter" extension (Ctrl-Shift-X, then search "Jupyter").
- Install the "Python" extension (Ctrl-Shift-X, then search "Python").
And then install the following PIP packages (via the Terminal):
$ pip install \
ipywidgets \
asammdf[gui] \
numpy.typing \
;
Start a DevContainer (in WSL):
- Open the Jupyter Notebook file:
examples/notebook/open_loop_simulation.ipynb
. - Click
Run All
to start the Notebook. - If (or when) prompted, select a kernel to run the Notebook with:
- Select
Python Environments...
- Select the installed (Codespace/WSL) Python environment, for example 'Python 3.12.1'.
- Select
- Using the toolbar at the top of the Notebook, select
Run All
to run the simulation. The results will appear at the bottom of the Notebook. - (Optional )Click on any cell in the Notebook to edit the simulaiton.
Note: The Python interpreter can also be selected manuall; press
Ctrl+Shift+P
to open the Command Palette, and then typePython: Select Interpreter
and choose your preferred Python environment in WSL.
Start a Codespace, then type the following commands in the terminal window.
# Start the notebook server.
$ cd examples/notebook
$ jupyter notebook --no-browser --ip=0.0.0.0
[I 15:21:09.858 NotebookApp] Writing notebook server cookie secret to /home/codespace/.local/share/jupyter/runtime/notebook_cookie_secret
[I 15:21:10.087 NotebookApp] Serving notebooks from local directory: /workspaces/dse.sdp/examples/notebook
[I 15:21:10.087 NotebookApp] The Jupyter Notebook is running at:
[I 15:21:10.087 NotebookApp] http://codespaces-2855a0:8888/?token=feb7ded293f8890565e514331728d261f3d28bc690a1d39c
[I 15:21:10.087 NotebookApp] or http://127.0.0.1:8888/?token=feb7ded293f8890565e514331728d261f3d28bc690a1d39c
[I 15:21:10.087 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:21:10.089 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/codespace/.local/share/jupyter/runtime/nbserver-4999-open.html
Or copy and paste one of these URLs:
http://codespaces-2855a0:8888/?token=feb7ded293f8890565e514331728d261f3d28bc690a1d39c
or http://127.0.0.1:8888/?token=feb7ded293f8890565e514331728d261f3d28bc690a1d39c
Next, open the Notebook:
- Open the Notebook URL (from the above command output) in a browser.
- Using the toolbar at the top of the Notebook, select
Run All
to run the simulation. The results will appear at the bottom of the Notebook. - (Optional )Click on any cell in the Notebook to edit the simulaiton.