Skip to content

Commit 3aeb692

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

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
@@ -1784,6 +1784,62 @@ def getLinearStates(self) -> list[str]:
17841784
class ModelicaSystemDoE:
17851785
"""
17861786
Class to run DoEs based on a (Open)Modelica model using ModelicaSystem
1787+
1788+
Example
1789+
-------
1790+
```
1791+
import OMPython
1792+
import pathlib
1793+
1794+
1795+
def run_doe():
1796+
mypath = pathlib.Path('.')
1797+
1798+
model = mypath / "M.mo"
1799+
model.write_text(
1800+
" model M\n"
1801+
" parameter Integer p=1;\n"
1802+
" parameter Integer q=1;\n"
1803+
" parameter Real a = -1;\n"
1804+
" parameter Real b = -1;\n"
1805+
" Real x[p];\n"
1806+
" Real y[q];\n"
1807+
" equation\n"
1808+
" der(x) = a * fill(1.0, p);\n"
1809+
" der(y) = b * fill(1.0, q);\n"
1810+
" end M;\n"
1811+
)
1812+
1813+
param = {
1814+
# structural
1815+
'p': [1, 2],
1816+
'q': [3, 4],
1817+
# simple
1818+
'a': [5, 6],
1819+
'b': [7, 8],
1820+
}
1821+
1822+
resdir = mypath / 'DoE'
1823+
resdir.mkdir(exist_ok=True)
1824+
1825+
mod_doe = OMPython.ModelicaSystemDoE(
1826+
fileName=model.as_posix(),
1827+
modelName="M",
1828+
parameters=param,
1829+
resultpath=resdir,
1830+
simargs={"override": {'stopTime': 1.0}},
1831+
)
1832+
mod_doe.prepare()
1833+
df_doe = mod_doe.get_doe()
1834+
mod_doe.simulate()
1835+
var_list = mod_doe.get_solutions()
1836+
sol_dict = mod_doe.get_solutions(var_list=var_list)
1837+
1838+
1839+
if __name__ == "__main__":
1840+
run_doe()
1841+
```
1842+
17871843
"""
17881844

17891845
DF_COLUMNS_RESULTFILENAME: str = 'resultfilename'

0 commit comments

Comments
 (0)