Skip to content

Commit 7d3e825

Browse files
syntronadeas31
andauthored
[ModelicaSystem] improve lintime checks (#406)
Co-authored-by: Adeel Asghar <adeel.asghar@liu.se>
1 parent 7ba2bea commit 7d3e825

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

OMPython/ModelicaSystem.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,14 @@ def linearize(
18081808
csvfile = self._createCSVData()
18091809
om_cmd.arg_set(key="csvInput", val=csvfile.as_posix())
18101810

1811-
om_cmd.arg_set(key="l", val=str(lintime or self._linearization_options["stopTime"]))
1811+
if lintime is None:
1812+
lintime = float(self._linearization_options["stopTime"])
1813+
if (float(self._linearization_options["startTime"]) > lintime
1814+
or float(self._linearization_options["stopTime"]) < lintime):
1815+
raise ModelicaSystemError(f"Invalid linearisation time: {lintime=}; "
1816+
f"expected value: {self._linearization_options['startTime']} "
1817+
f"<= lintime <= {self._linearization_options['stopTime']}")
1818+
om_cmd.arg_set(key="l", val=str(lintime))
18121819

18131820
# allow runtime simulation flags from user input
18141821
if simflags is not None:

0 commit comments

Comments
 (0)