Skip to content

Commit 3ff6aa4

Browse files
committed
[ModelicaSystemDoE] add example to show the usage
1 parent 66fc3a6 commit 3ff6aa4

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
@@ -1418,6 +1418,62 @@ def getLinearStates(self):
14181418
class ModelicaSystemDoE:
14191419
"""
14201420
Class to run DoEs based on a (Open)Modelica model using ModelicaSystem
1421+
1422+
Example
1423+
-------
1424+
```
1425+
import OMPython
1426+
import pathlib
1427+
1428+
1429+
def run_doe():
1430+
mypath = pathlib.Path('.')
1431+
1432+
model = mypath / "M.mo"
1433+
model.write_text(
1434+
" model M\n"
1435+
" parameter Integer p=1;\n"
1436+
" parameter Integer q=1;\n"
1437+
" parameter Real a = -1;\n"
1438+
" parameter Real b = -1;\n"
1439+
" Real x[p];\n"
1440+
" Real y[q];\n"
1441+
" equation\n"
1442+
" der(x) = a * fill(1.0, p);\n"
1443+
" der(y) = b * fill(1.0, q);\n"
1444+
" end M;\n"
1445+
)
1446+
1447+
param = {
1448+
# structural
1449+
'p': [1, 2],
1450+
'q': [3, 4],
1451+
# simple
1452+
'a': [5, 6],
1453+
'b': [7, 8],
1454+
}
1455+
1456+
resdir = mypath / 'DoE'
1457+
resdir.mkdir(exist_ok=True)
1458+
1459+
mod_doe = OMPython.ModelicaSystemDoE(
1460+
fileName=model.as_posix(),
1461+
modelName="M",
1462+
parameters=param,
1463+
resultpath=resdir,
1464+
simargs={"override": {'stopTime': 1.0}},
1465+
)
1466+
mod_doe.prepare()
1467+
df_doe = mod_doe.get_doe()
1468+
mod_doe.simulate()
1469+
var_list = mod_doe.get_solutions()
1470+
sol_dict = mod_doe.get_solutions(var_list=var_list)
1471+
1472+
1473+
if __name__ == "__main__":
1474+
run_doe()
1475+
```
1476+
14211477
"""
14221478

14231479
DF_COLUMNS_RESULTFILENAME: str = 'resultfilename'

0 commit comments

Comments
 (0)