Skip to content

Commit

Permalink
Added banner to the app for UI improvement
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
techy4shri committed Jan 30, 2025
1 parent 2588924 commit 0e6285f
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 14 deletions.
10 changes: 4 additions & 6 deletions NonInteractingTanks/Tank.mo
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ equation
// Assigning potential variable (height/pressure)
flowConnect.P = h;
der(h) = (Qin - Qo)/A;
if time<=5 then
Qo = 0;
else
Qo = if h > 0 then sqrt(h) else 0; //protecting against h <=0
end if;
Qo = max(0, if time <= 5 then 0 else sqrt(h));


// Ensure h remains non-negative
assert(h >= 0, "Error: Tank height (h) must be non-negative!");
//assert(h >= 0, "Error: Tank height (h) must be non-negative!");
annotation(
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")}));
end Tank;
6 changes: 1 addition & 5 deletions NonInteractingTanks/Tank2.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@ within NonInteractingTanks;
model Tank2
parameter Real A =1, V =10;
Real h(start = 1.0),Q1;
parameter Real T;
FlowConnect flowConnect annotation(
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)));
equation
// Assigning potential variable (height/pressure)
flowConnect.P = h;
Q1 = flowConnect.F;
flowConnect.F = Q1;
der(h) = Q1 / A;
// Prevent division by zero in T calculation

T = if Q1 > 0 then V / Q1 else 0;
annotation(
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")}));
end Tank2;
3 changes: 2 additions & 1 deletion NonInteractingTanks/TwoConnectedTanks.mo
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ equation
protected
annotation(
Diagram(coordinateSystem(extent = {{-100, 20}, {60, -120}})),
__OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS", s = "dassl", variableFilter = ".*"));
__OpenModelica_simulationFlags(lv = "LOG_STDOUT,LOG_ASSERT,LOG_STATS", s = "dassl", variableFilter = ".*", maxIntegrationOrder = "3"),
__OpenModelica_commandLineOptions = "--matchingAlgorithm=PFPlusExt --indexReductionMethod=dynamicStateSelection -d=initialization,NLSanalyticJacobian");

end TwoConnectedTanks;
Binary file added banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0e6285f

Please sign in to comment.