Skip to content

Commit bed91a8

Browse files
committed
- Simulated the model TwoConnectedTanks.mo again.
- Added the ability to run the OpenModelica model `.exe` directly from the GUI. - Implemented input validation for executable path, start time, and stop time. - Dynamically set the working directory and output file paths for the simulation. - Updated the `run_app` method to execute the `.exe` using subprocess. - Captured and displayed output, errors, and exceptions during the simulation. - Improved error handling for missing files, invalid inputs, and OS-related issues. - Refactored UI layout and added docstrings to improve readability and maintainability.
1 parent 0e6285f commit bed91a8

File tree

11 files changed

+131
-110
lines changed

11 files changed

+131
-110
lines changed
-2.47 KB
Binary file not shown.
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1-
C:/Users/SHRI/AppData/Local/Temp/OpenModelica/OMEdit/NonInteractingTanks.TwoConnectedTanks/TwoConnectedTanks.exe -port=57894 -logFormat=xmltcp -override=startTime=0,stopTime=1,stepSize=0.002,tolerance=1e-06,solver=dassl,outputFormat=mat,variableFilter=.* -r=C:/Users/SHRI/AppData/Local/Temp/OpenModelica/OMEdit/NonInteractingTanks.TwoConnectedTanks/TwoConnectedTanks_res.mat -w -lv=LOG_STDOUT,LOG_ASSERT,LOG_STATS -inputPath=C:/Users/SHRI/AppData/Local/Temp/OpenModelica/OMEdit/NonInteractingTanks.TwoConnectedTanks -outputPath=C:/Users/SHRI/AppData/Local/Temp/OpenModelica/OMEdit/NonInteractingTanks.TwoConnectedTanks
2-
division by zero at time 0, (a=10) / (b=-0), where divisor b expression is: tank2.Q1
3-
simulation terminated by an assertion at initialization
1+
D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks.TwoConnectedTanks/TwoConnectedTanks.exe -port=62000 -logFormat=xmltcp -override=startTime=0,stopTime=5,stepSize=0.01,tolerance=1e-06,solver=dassl,outputFormat=mat,variableFilter=.* -r=D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks.TwoConnectedTanks/TwoConnectedTanks_res.mat -maxIntegrationOrder=3 -w -lv=LOG_STDOUT,LOG_ASSERT,LOG_STATS -inputPath=D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks.TwoConnectedTanks -outputPath=D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks.TwoConnectedTanks
2+
The initialization finished successfully without homotopy method.
3+
### STATISTICS ###
4+
timer
5+
0.0021397s reading init.xml
6+
0.0031933s reading info.xml
7+
0.0021684s [ 8.1%] pre-initialization
8+
0.0002307s [ 0.9%] initialization
9+
2.85e-05s [ 0.1%] steps
10+
0.0004566s [ 1.7%] solver (excl. callbacks)
11+
0.0023803s [ 8.9%] creating output-file
12+
0.0002415s [ 0.9%] event-handling
13+
0.0003358s [ 1.3%] overhead
14+
0.0209704s [ 78.2%] simulation
15+
0.0268122s [100.0%] total
16+
events
17+
0 state events
18+
0 time events
19+
solver: dassl
20+
24 steps taken
21+
24 calls of functionODE
22+
23 evaluations of jacobian
23+
0 error test failures
24+
0 convergence test failures
25+
1.73e-05s time of jacobian evaluation
26+
The simulation finished successfully.
-12 Bytes
Binary file not shown.

NonInteractingTanks.TwoConnectedTanks/TwoConnectedTanks_info.json

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
{"format":"Transformational debugger info","version":1,
22
"info":{"name":"NonInteractingTanks.TwoConnectedTanks","description":""},
33
"variables":{
4-
"tank1.h":{"comment":"","kind":"state","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":22},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank"]}},
5-
"tank2.h":{"comment":"","kind":"state","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":12},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
6-
"der(tank1.h)":{"comment":"","kind":"derivative","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":22},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank"]}},
7-
"der(tank2.h)":{"comment":"","kind":"derivative","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":12},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
8-
"tank2.Q1":{"comment":"","kind":"variable","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":12},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
9-
"tank2.T":{"comment":"","kind":"variable","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":12},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
4+
"tank2.h":{"comment":"","kind":"state","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":23},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
5+
"der(tank2.h)":{"comment":"","kind":"derivative","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":23},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
6+
"tank1.Qo":{"comment":"","kind":"variable","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":22},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank"]}},
7+
"tank2.Q1":{"comment":"","kind":"variable","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":5,"lineEnd":5,"colStart":1,"colEnd":23},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
108
"tank1.A":{"comment":"","kind":"parameter","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank.mo","lineStart":4,"lineEnd":4,"colStart":1,"colEnd":29},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank"]}},
119
"tank1.Qin":{"comment":"","kind":"parameter","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank.mo","lineStart":4,"lineEnd":4,"colStart":1,"colEnd":29},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank"]}},
1210
"tank2.A":{"comment":"","kind":"parameter","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":4,"lineEnd":4,"colStart":1,"colEnd":27},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}},
1311
"tank2.V":{"comment":"","kind":"parameter","type":"Real","unit":"","displayUnit":"","source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":4,"lineEnd":4,"colStart":1,"colEnd":27},"typeLst":["NonInteractingTanks.TwoConnectedTanks","NonInteractingTanks.Tank2"]}}
1412
},
1513
"equations":[{"eqIndex":0,"tag":"dummy"},
1614
{"eqIndex":1,"section":"initial","tag":"assign","defines":["tank2.h"],"uses":["$START.tank2.h"],"equation":["$START.tank2.h"],"source":{"info":{"file":"","lineStart":0,"lineEnd":0,"colStart":0,"colEnd":0},"operations":[{"op":"info","display":"solved","data":["tank2.h = $START.tank2.h"]},{"op":"info","display":"solved","data":["tank2.h = $START.tank2.h"]}]}},
17-
{"eqIndex":2,"section":"initial","tag":"assign","defines":["tank1.h"],"uses":["$START.tank1.h"],"equation":["$START.tank1.h"],"source":{"info":{"file":"","lineStart":0,"lineEnd":0,"colStart":0,"colEnd":0},"operations":[{"op":"info","display":"solved","data":["tank1.h = $START.tank1.h"]},{"op":"info","display":"solved","data":["tank1.h = $START.tank1.h"]}]}},
18-
{"eqIndex":3,"tag":"alias","equation":[7],"section":"initial"},
19-
{"eqIndex":4,"tag":"alias","equation":[10],"section":"initial"},
20-
{"eqIndex":5,"tag":"alias","equation":[9],"section":"initial"},
21-
{"eqIndex":6,"tag":"alias","equation":[8],"section":"initial"},
22-
{"eqIndex":7,"section":"regular","tag":"assign","defines":["tank2.Q1"],"uses":["tank1.h","time"],"equation":["-(if time <= 5.0 then 0.0 else if tank1.h > 0.0 then sqrt(tank1.h) else 0.0)"],"source":{"info":{"file":"","lineStart":0,"lineEnd":0,"colStart":0,"colEnd":0},"operations":[{"op":"info","display":"solved","data":["tank2.Q1 = -(if time <= 5.0 then 0.0 else if tank1.h > 0.0 then sqrt(tank1.h) else 0.0)"]},{"op":"info","display":"solved","data":["tank2.Q1 = -(if time <= 5.0 then 0.0 else if tank1.h > 0.0 then sqrt(tank1.h) else 0.0)"]},{"op":"chain","display":"substitution","data":["tank1.Qo","-tank2.Q1"]}]}},
23-
{"eqIndex":8,"section":"regular","tag":"assign","defines":["der(tank1.h)"],"uses":["tank1.A","tank2.Q1","tank1.Qin"],"equation":["(tank1.Qin + tank2.Q1) / tank1.A"],"source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank.mo","lineStart":12,"lineEnd":12,"colStart":1,"colEnd":22},"operations":[{"op":"info","display":"solved","data":["der(tank1.h) = (tank1.Qin + tank2.Q1) / tank1.A"]},{"op":"info","display":"solved","data":["der(tank1.h) = (tank1.Qin + tank2.Q1) / tank1.A"]},{"op":"before-after","display":"simplify","data":["der(tank1.h) = (tank1.Qin - (-tank2.Q1)) / tank1.A","der(tank1.h) = (tank1.Qin + tank2.Q1) / tank1.A"]},{"op":"chain","display":"substitution","data":["(tank1.Qin - tank1.Qo) / tank1.A","(tank1.Qin - (-tank2.Q1)) / tank1.A"]},{"op":"before-after","display":"differentiate d/dtime","data":["der(tank1.h)","der(tank1.h)"]}]}},
24-
{"eqIndex":9,"section":"regular","tag":"assign","defines":["tank2.T"],"uses":["tank2.Q1","tank2.V"],"equation":["tank2.V / tank2.Q1"],"source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":11,"lineEnd":11,"colStart":1,"colEnd":11},"operations":[{"op":"info","display":"solved","data":["tank2.T = tank2.V / tank2.Q1"]},{"op":"info","display":"solved","data":["tank2.T = tank2.V / tank2.Q1"]}]}},
25-
{"eqIndex":10,"section":"regular","tag":"assign","defines":["der(tank2.h)"],"uses":["tank2.A","tank2.Q1"],"equation":["tank2.Q1 / tank2.A"],"source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":10,"lineEnd":10,"colStart":1,"colEnd":16},"operations":[{"op":"info","display":"solved","data":["der(tank2.h) = tank2.Q1 / tank2.A"]},{"op":"info","display":"solved","data":["der(tank2.h) = tank2.Q1 / tank2.A"]},{"op":"before-after","display":"differentiate d/dtime","data":["der(tank2.h)","der(tank2.h)"]}]}}
15+
{"eqIndex":2,"tag":"alias","equation":[5],"section":"initial"},
16+
{"eqIndex":3,"tag":"alias","equation":[6],"section":"initial"},
17+
{"eqIndex":4,"section":"initial","tag":"assign","defines":["tank2.Q1"],"uses":["tank2.A","der(tank2.h)"],"equation":["$DER.tank2.h * tank2.A"],"source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":12,"lineEnd":12,"colStart":1,"colEnd":16},"operations":[{"op":"info","display":"solved","data":["tank2.Q1 = $DER.tank2.h * tank2.A"]},{"op":"info","display":"solved","data":["tank2.Q1 = $DER.tank2.h * tank2.A"]},{"op":"before-after","display":"differentiate d/dtime","data":["der(tank2.h)","der(tank2.h)"]}]}},
18+
{"eqIndex":5,"section":"regular","tag":"assign","defines":["tank1.Qo"],"uses":["tank2.h","time"],"equation":["max(0.0, if time <= 5.0 then 0.0 else sqrt(tank2.h))"],"source":{"info":{"file":"","lineStart":0,"lineEnd":0,"colStart":0,"colEnd":0},"operations":[{"op":"info","display":"solved","data":["tank1.Qo = max(0.0, if time <= 5.0 then 0.0 else sqrt(tank2.h))"]},{"op":"info","display":"solved","data":["tank1.Qo = max(0.0, if time <= 5.0 then 0.0 else sqrt(tank2.h))"]}]}},
19+
{"eqIndex":6,"section":"regular","tag":"assign","defines":["der(tank2.h)"],"uses":["tank1.A","tank1.Qin","tank1.Qo"],"equation":["(tank1.Qin - tank1.Qo) / tank1.A"],"source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank.mo","lineStart":14,"lineEnd":14,"colStart":1,"colEnd":22},"operations":[{"op":"info","display":"solved","data":["der(tank2.h) = (tank1.Qin - tank1.Qo) / tank1.A"]},{"op":"info","display":"solved","data":["der(tank2.h) = (tank1.Qin - tank1.Qo) / tank1.A"]},{"op":"chain","display":"substitution","data":["der(tank1.h)","der(tank2.h)"]},{"op":"before-after","display":"differentiate d/dtime","data":["der(tank1.h)","der(tank1.h)"]}]}},
20+
{"eqIndex":7,"section":"regular","tag":"assign","defines":["tank2.Q1"],"uses":["tank2.A","der(tank2.h)"],"equation":["der(tank2.h) * tank2.A"],"source":{"info":{"file":"D:/SHRI1/github/OpenModelica-GUI/NonInteractingTanks/Tank2.mo","lineStart":12,"lineEnd":12,"colStart":1,"colEnd":16},"operations":[{"op":"info","display":"solved","data":["tank2.Q1 = der(tank2.h) * tank2.A"]},{"op":"info","display":"solved","data":["tank2.Q1 = der(tank2.h) * tank2.A"]},{"op":"before-after","display":"differentiate d/dtime","data":["der(tank2.h)","der(tank2.h)"]}]}}
2621
],
2722
"functions":[
2823
]

0 commit comments

Comments
 (0)