Skip to content

Commit b361860

Browse files
committed
[ModelicaSystemDoE] add example to show the usage
1 parent 3f701c6 commit b361860

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,62 @@ def getLinearStates(self):
14271427
class ModelicaSystemDoE:
14281428
"""
14291429
Class to run DoEs based on a (Open)Modelica model using ModelicaSystem
1430+
1431+
Example
1432+
-------
1433+
```
1434+
import OMPython
1435+
import pathlib
1436+
1437+
1438+
def run_doe():
1439+
mypath = pathlib.Path('.')
1440+
1441+
model = mypath / "M.mo"
1442+
model.write_text(
1443+
" model M\n"
1444+
" parameter Integer p=1;\n"
1445+
" parameter Integer q=1;\n"
1446+
" parameter Real a = -1;\n"
1447+
" parameter Real b = -1;\n"
1448+
" Real x[p];\n"
1449+
" Real y[q];\n"
1450+
" equation\n"
1451+
" der(x) = a * fill(1.0, p);\n"
1452+
" der(y) = b * fill(1.0, q);\n"
1453+
" end M;\n"
1454+
)
1455+
1456+
param = {
1457+
# structural
1458+
'p': [1, 2],
1459+
'q': [3, 4],
1460+
# simple
1461+
'a': [5, 6],
1462+
'b': [7, 8],
1463+
}
1464+
1465+
resdir = mypath / 'DoE'
1466+
resdir.mkdir(exist_ok=True)
1467+
1468+
mod_doe = OMPython.ModelicaSystemDoE(
1469+
fileName=model.as_posix(),
1470+
modelName="M",
1471+
parameters=param,
1472+
resultpath=resdir,
1473+
simargs={"override": {'stopTime': 1.0}},
1474+
)
1475+
mod_doe.prepare()
1476+
df_doe = mod_doe.get_doe()
1477+
mod_doe.simulate()
1478+
var_list = mod_doe.get_solutions()
1479+
sol_dict = mod_doe.get_solutions(var_list=var_list)
1480+
1481+
1482+
if __name__ == "__main__":
1483+
run_doe()
1484+
```
1485+
14301486
"""
14311487

14321488
DF_COLUMNS_RESULTFILENAME: str = 'resultfilename'

0 commit comments

Comments
 (0)