Commit b9eed96c authored by hazrmard's avatar hazrmard
Browse files

sample notebook to load FMU into python (simulate gives errors TODO)

parent 01c66f60
......@@ -3,6 +3,7 @@
*.o
*.libs
*.log
*_log.txt
*.makefile
*.c
*.h
......@@ -11,3 +12,4 @@
*_info.json
.ipynb_checkpoints/
dygraph-combined.js
*.fmu
\ No newline at end of file
......@@ -22,13 +22,13 @@
%% Cell type:code id: tags:
``` OpenModelica
class Pendulum "Pendulum"
Real F=0; // External force tengential to motion
constant Real PI=3.141592653589793;
parameter Real m=1, g=9.81, L=0.5;
Real F; // External force tengential to motion
output Real x(start=0.5),y(start=0);
output Real vx,vy; // x and y velocities
equation
// 5 variables, 5 equations
m*der(vx)=-(x/L)*F; // Force equation in x direction
......@@ -40,10 +40,16 @@
```
%% Cell type:code id: tags:
``` OpenModelica
translateModelFMU(Pendulum)
```
%% Cell type:code id: tags:
``` OpenModelica
// generates C code and complies an exe
// that produces a result file
buildModel(Pendulum fileNamePrefix="pendulum-")
```
......
%% Cell type:code id: tags:
``` python
from pyfmi import load_fmu
```
%% Cell type:code id: tags:
``` python
model = load_fmu('Pendulum.fmu')
```
%% Cell type:code id: tags:
``` python
res = model.simulate(final_time=5, input=('F', lambda t: 1.))
```
%% Cell type:code id: tags:
``` python
```
......@@ -6,5 +6,6 @@ rm *.c
rm *.h
rm *.xml
rm *.exe
rm *_log.txt
rm *_info.json
rm dygraph-combined.js
\ No newline at end of file
......@@ -8,5 +8,6 @@ rm *.log
rm *.xml
rm *.libs
rm *.makefile
rm *_log.txt
find . -type f ! -name "*.*" -delete
clear
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment