Skip to content

Commit 3eee04f

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

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
@@ -1513,6 +1513,62 @@ def getLinearStates(self):
15131513
class ModelicaSystemDoE:
15141514
"""
15151515
Class to run DoEs based on a (Open)Modelica model using ModelicaSystem
1516+
1517+
Example
1518+
-------
1519+
```
1520+
import OMPython
1521+
import pathlib
1522+
1523+
1524+
def run_doe():
1525+
mypath = pathlib.Path('.')
1526+
1527+
model = mypath / "M.mo"
1528+
model.write_text(
1529+
" model M\n"
1530+
" parameter Integer p=1;\n"
1531+
" parameter Integer q=1;\n"
1532+
" parameter Real a = -1;\n"
1533+
" parameter Real b = -1;\n"
1534+
" Real x[p];\n"
1535+
" Real y[q];\n"
1536+
" equation\n"
1537+
" der(x) = a * fill(1.0, p);\n"
1538+
" der(y) = b * fill(1.0, q);\n"
1539+
" end M;\n"
1540+
)
1541+
1542+
param = {
1543+
# structural
1544+
'p': [1, 2],
1545+
'q': [3, 4],
1546+
# simple
1547+
'a': [5, 6],
1548+
'b': [7, 8],
1549+
}
1550+
1551+
resdir = mypath / 'DoE'
1552+
resdir.mkdir(exist_ok=True)
1553+
1554+
mod_doe = OMPython.ModelicaSystemDoE(
1555+
fileName=model.as_posix(),
1556+
modelName="M",
1557+
parameters=param,
1558+
resultpath=resdir,
1559+
simargs={"override": {'stopTime': 1.0}},
1560+
)
1561+
mod_doe.prepare()
1562+
df_doe = mod_doe.get_doe()
1563+
mod_doe.simulate()
1564+
var_list = mod_doe.get_solutions()
1565+
sol_dict = mod_doe.get_solutions(var_list=var_list)
1566+
1567+
1568+
if __name__ == "__main__":
1569+
run_doe()
1570+
```
1571+
15161572
"""
15171573

15181574
DF_COLUMNS_RESULTFILENAME: str = 'resultfilename'

0 commit comments

Comments
 (0)