Skip to content

Commit 0e6285f

Browse files
committed
Added banner to the app for UI improvement
Fix structural imbalance by optimizing model equations - `Tank.mo`: Added `flowConnect.P = h`, simplified `Qo` assignment, removed `assert`. - `Tank2.mo`: Added `flowConnect.P = h`, removed redundant variable `T`. - `FlowConnect.mo`: Defined `P` (potential) and `F` (flow) for continuity and conservation. - `TwoConnectedTanks.mo`: Verified connection enforcing flow balance and potential equality. Models now have balanced equations and variables.
1 parent 2588924 commit 0e6285f

File tree

6 files changed

+221
-14
lines changed

6 files changed

+221
-14
lines changed

NonInteractingTanks/Tank.mo

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ equation
1212
// Assigning potential variable (height/pressure)
1313
flowConnect.P = h;
1414
der(h) = (Qin - Qo)/A;
15-
if time<=5 then
16-
Qo = 0;
17-
else
18-
Qo = if h > 0 then sqrt(h) else 0; //protecting against h <=0
19-
end if;
15+
Qo = max(0, if time <= 5 then 0 else sqrt(h));
16+
17+
2018
// Ensure h remains non-negative
21-
assert(h >= 0, "Error: Tank height (h) must be non-negative!");
19+
//assert(h >= 0, "Error: Tank height (h) must be non-negative!");
2220
annotation(
2321
Icon(graphics = {Line(origin = {-7, 10}, points = {{-33, 28}, {-33, -28}, {33, -28}, {33, 28}, {33, 28}}), Line(origin = {-54, 47}, points = {{-24, 7}, {24, 7}, {24, -7}}), Line(origin = {-30, 43.416}, points = {{-4, 2.58397}, {0, -3.41603}, {4, 2.58397}}), Text(origin = {-61, 47}, extent = {{-45, 25}, {-25, -9}}, textString = "Qin"), Text(textColor = {0, 0, 255}, extent = {{0, 30}, {50, 80}}, textString = "%name")}));
2422
end Tank;

NonInteractingTanks/Tank2.mo

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ within NonInteractingTanks;
33
model Tank2
44
parameter Real A =1, V =10;
55
Real h(start = 1.0),Q1;
6-
parameter Real T;
76
FlowConnect flowConnect annotation(
87
Placement(visible = true, transformation(origin = {-42, 42}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-36, 34}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
98
equation
109
// Assigning potential variable (height/pressure)
1110
flowConnect.P = h;
12-
Q1 = flowConnect.F;
11+
flowConnect.F = Q1;
1312
der(h) = Q1 / A;
14-
// Prevent division by zero in T calculation
15-
16-
T = if Q1 > 0 then V / Q1 else 0;
1713
annotation(
1814
Icon(graphics = {Line(origin = {-13, 13.5}, points = {{-35, 28.5}, {-35, -31.5}, {33, -31.5}, {35, -31.5}, {35, 26.5}, {35, 28.5}, {35, 24.5}}), Text(lineColor = {0, 0, 255}, extent = {{0, 30}, {50, 80}}, textString = "%name")}));
1915
end Tank2;

NonInteractingTanks/TwoConnectedTanks.mo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ equation
1313
protected
1414
annotation(
1515
Diagram(coordinateSystem(extent = {{-100, 20}, {60, -120}})),
16-
__OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS", s = "dassl", variableFilter = ".*"));
16+
__OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS", s = "dassl", variableFilter = ".*", maxIntegrationOrder = "3"),
17+
__OpenModelica_commandLineOptions = "--matchingAlgorithm=PFPlusExt --indexReductionMethod=dynamicStateSelection -d=initialization,NLSanalyticJacobian");
1718

1819
end TwoConnectedTanks;

banner.png

133 KB
Loading

0 commit comments

Comments
 (0)