Skip to content

Latest commit

 

History

History
116 lines (88 loc) · 3.19 KB

README.md

File metadata and controls

116 lines (88 loc) · 3.19 KB

Open Loop Simulation Example

Introduction

Use a simple CSV file, via an input model, to operate an Open Loop simulation which represents an Linear Equation.

VS Code Simulation Dashboard

Usage

Make the most of this example by installing the following VS Code extensions:

  1. Install the "Edit csv" extension (Ctrl-Shift-X, then search "Edit csv").

  2. Install the "VS Plotter" extension (Ctrl-Shift-X, then search "VS Plotter").

Start a Codespace, then type the following commands in the terminal window.

Cloudspace Terminal

$ cd examples/openloop

# Install python package ASAMMDF.
$ pip install asammdf[gui]

# Run the example openloop simulation.
$ ./openloop.sh
...
Simulation complete.
Measurement file : out/sim/measurement.mf4
Measurement file : out/sim/measurement.ChannelGroup_0_linear.csv (converted)
# View the measurement, using VS Code extension "VS Plotter" to open CSV file.

# (Optional) View the measurement using ASAMMDF.
$ asammdf --measurements out/sim/measurement.mf4

# Adjust the simulation input/parameters, using VS Code extension "Edit csv":
# 1. Open the CSV file examples/openloop/input__value_set.csv
# 2. Adjust some values, save the file.
# 3. Run the simulation again.
$ ./openloop.sh

Juypter Notebook

Install Jupyter Notebook in WSL

Install Jupyter using apt:

sudo apt install jupyter-notebook

Verify the installation:

jupyter notebook --version

Install the following VS Code extensions:

  1. Install the "Jupyter" extension (Ctrl-Shift-X, then search "Jupyter").

Run Jupyter Notebooks in VSCode

  1. Open the existing open_loop_simulation.ipynb Jupyter Notebook file.
  2. When prompted, select the Python interpreter to use (from WSL). You can also manually select it:
    • Press Ctrl+Shift+P to open the Command Palette.
    • Type Python: Select Interpreter and choose your preferred Python environment in WSL.
  3. Click on any cell to start editing.
  4. Use the toolbar at the top of the file to run individual cells or the entire notebook.

Run Jupyter Notebooks in Browser

jupyter notebook --no-browser --ip=0.0.0.0

open a browser and copy and paste the URL printed in the terminal output.

Taskfile Automation

Cloudspace Terminal

$ cd examples/openloop

# Manually run the simulation using task.
$ export TASK_X_REMOTE_TASKFILES=1
$ task -y build
...
$ dse-simer out/sim -env linear:MEASUREMENT_FILE=/sim/measurement.mf4
...
$ task cleanall

Simulation Layout (generated by Taskfile)

L- data
  L- simulation.yaml    Simulation definition, contains stacks.
L- model/input
  L- data
    L- input.csv        Scenario definition in CSV format.
    L- model.yaml       Model definition.
    L- signalgroup.yaml Generated SignalGroup (based on input.csv).
  L- lib
    L- libcsv.so        Model implementation (shared library).
L- model/linear
  L- data
    L- model.yaml       Generated model definition.
    L- signalgroup.yaml Generated SignalGroup.
  L- fmu
    L- modelDescription.xml
    L- resources
    L- binaries/linux64
      L- libfmu2linear.so
  L- lib
    L- libfmimcl.so