Components.mo 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. package Components "Library with models for flow circuits."
  2. extends Modelica.Icons.Package;
  3. package Actuators "Package with all the actuators."
  4. extends Modelica.Icons.Package;
  5. model Actuator "Time-based linear actuator with stroke time and absolute input position"
  6. // Import Configuration
  7. outer Components.Configurations.Configuration config;
  8. parameter Real delta(min = 0, max = 0.5) = 0.005 "Hysteresis";
  9. Modelica.Blocks.Sources.RealExpression totalOpeningTime(y = config.total_opening_time) annotation(
  10. Placement(transformation(origin = {-92, 172}, extent = {{-10, 10}, {10, -10}})));
  11. Modelica.Blocks.Sources.RealExpression totalClosingTime(y = config.total_closing_time) annotation(
  12. Placement(transformation(origin = {-93, 24}, extent = {{-10, 10}, {10, -10}})));
  13. Modelica.Blocks.Sources.RealExpression minMotorPosition(y = config.min_motor_position) annotation(
  14. Placement(transformation(origin = {-292, 86}, extent = {{-10, -10}, {10, 10}})));
  15. Modelica.Blocks.Sources.RealExpression maxMotorPosition(y = config.max_motor_position) annotation(
  16. Placement(transformation(origin = {-252, 70}, extent = {{-10, -10}, {10, 10}})));
  17. Modelica.Blocks.Sources.RealExpression realOpen(y = 1) annotation(
  18. Placement(transformation(origin = {-92, 184}, extent = {{-10, -10}, {10, 10}})));
  19. Modelica.Blocks.Sources.RealExpression realClose(y = -1) annotation(
  20. Placement(transformation(origin = {-92, 36}, extent = {{-10, -10}, {10, 10}})));
  21. Modelica.Blocks.Interfaces.RealInput setpoint_motor annotation(
  22. Placement(transformation(origin = {-338, 110}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-40, 140}, extent = {{-20, -20}, {20, 20}}, rotation = -90)));
  23. Modelica.Blocks.Interfaces.RealOutput norm_motor_position annotation(
  24. Placement(transformation(origin = {251, 103}, extent = {{-11, -11}, {11, 11}}), iconTransformation(origin = {100, 50}, extent = {{-20, -20}, {20, 20}})));
  25. Modelica.Blocks.Math.Feedback motorRange annotation(
  26. Placement(transformation(origin = {-222, 70}, extent = {{-10, 10}, {10, -10}})));
  27. Modelica.Blocks.Math.Feedback nominator annotation(
  28. Placement(transformation(origin = {-252, 110}, extent = {{-10, -10}, {10, 10}})));
  29. Modelica.Blocks.Math.Division setpointNorm annotation(
  30. Placement(transformation(origin = {-192, 104}, extent = {{-10, -10}, {10, 10}})));
  31. Modelica.Blocks.Math.Division divisionOpen annotation(
  32. Placement(transformation(origin = {-52, 178}, extent = {{-10, -10}, {10, 10}})));
  33. Modelica.Blocks.Math.Division divisionClose annotation(
  34. Placement(transformation(origin = {-52, 30}, extent = {{-10, -10}, {10, 10}})));
  35. Modelica.Blocks.Logical.Hysteresis uppHys(final pre_y_start = false, uHigh = delta, final uLow = 0) annotation(
  36. Placement(transformation(origin = {-1, 103}, extent = {{-60, 20}, {-40, 40}})));
  37. Modelica.Blocks.Logical.Hysteresis lowHys(final pre_y_start = true, final uHigh = 0, uLow = -delta) "Lower hysteresis" annotation(
  38. Placement(transformation(origin = {-1, 101}, extent = {{-60, -40}, {-40, -20}})));
  39. Modelica.Blocks.Logical.Switch uppSwi annotation(
  40. Placement(transformation(origin = {-1, 103}, extent = {{0, 20}, {20, 40}})));
  41. parameter Real scaled_start_position = (config.start_motor_position - config.min_motor_position)/(config.max_motor_position - config.min_motor_position);
  42. final parameter Real y_start = if scaled_start_position >= 0.01 then scaled_start_position else 0.01;
  43. Modelica.Blocks.Continuous.LimIntegrator int(initType = Modelica.Blocks.Types.Init.InitialState, final k = 1, limitsAtInit = true, outMax = 1, outMin = 0, y(stateSelect = StateSelect.always), final y_start = y_start) "Integrator for valve opening position" annotation(
  44. Placement(transformation(origin = {19, 103}, extent = {{60, -10}, {80, 10}})));
  45. final Modelica.Blocks.Sources.Constant zer(final k = 0) "Zero signal" annotation(
  46. Placement(transformation(origin = {-21, 103}, extent = {{-40, -10}, {-20, 10}})));
  47. Modelica.Blocks.Logical.Switch lowSwi annotation(
  48. Placement(transformation(origin = {-1, 101}, extent = {{0, -40}, {20, -20}})));
  49. Modelica.Blocks.Math.Add add annotation(
  50. Placement(transformation(origin = {7, 103}, extent = {{32, -10}, {52, 10}})));
  51. Modelica.Blocks.Math.Feedback feedback annotation(
  52. Placement(transformation(origin = {-132, 104}, extent = {{-10, -10}, {10, 10}})));
  53. Modelica.Blocks.Math.Max max annotation(
  54. Placement(transformation(origin = {142, 96}, extent = {{-10, -10}, {10, 10}})));
  55. Modelica.Blocks.Math.Min min annotation(
  56. Placement(transformation(origin = {190, 104}, extent = {{-10, -10}, {10, 10}})));
  57. Modelica.Blocks.Sources.RealExpression clamp_zero annotation(
  58. Placement(transformation(origin = {100, 68}, extent = {{-10, -10}, {10, 10}})));
  59. Modelica.Blocks.Sources.RealExpression clamp_one(y = 1) annotation(
  60. Placement(transformation(origin = {134, 130}, extent = {{-10, -10}, {10, 10}})));
  61. Modelica.Blocks.Math.Product product annotation(
  62. Placement(transformation(origin = {116, -16}, extent = {{-10, -10}, {10, 10}})));
  63. Modelica.Blocks.Math.Add add1 annotation(
  64. Placement(transformation(origin = {190, -30}, extent = {{-10, -10}, {10, 10}})));
  65. Modelica.Blocks.Interfaces.RealOutput motor_position annotation(
  66. Placement(transformation(origin = {248, 52}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {100, -12}, extent = {{-20, -20}, {20, 20}})));
  67. protected
  68. equation
  69. connect(maxMotorPosition.y, motorRange.u1) annotation(
  70. Line(points = {{-241, 70}, {-230, 70}}, color = {0, 0, 127}));
  71. connect(setpoint_motor, nominator.u1) annotation(
  72. Line(points = {{-338, 110}, {-260, 110}}, color = {0, 0, 127}));
  73. connect(minMotorPosition.y, motorRange.u2) annotation(
  74. Line(points = {{-281, 86}, {-222, 86}, {-222, 78}}, color = {0, 0, 127}));
  75. connect(minMotorPosition.y, nominator.u2) annotation(
  76. Line(points = {{-281, 86}, {-252, 86}, {-252, 102}}, color = {0, 0, 127}));
  77. connect(nominator.y, setpointNorm.u1) annotation(
  78. Line(points = {{-243, 110}, {-204, 110}}, color = {0, 0, 127}));
  79. connect(motorRange.y, setpointNorm.u2) annotation(
  80. Line(points = {{-213, 70}, {-210, 70}, {-210, 98}, {-204, 98}}, color = {0, 0, 127}));
  81. connect(realOpen.y, divisionOpen.u1) annotation(
  82. Line(points = {{-81, 184}, {-64, 184}}, color = {0, 0, 127}));
  83. connect(totalOpeningTime.y, divisionOpen.u2) annotation(
  84. Line(points = {{-81, 172}, {-64, 172}}, color = {0, 0, 127}));
  85. connect(realClose.y, divisionClose.u1) annotation(
  86. Line(points = {{-81, 36}, {-64, 36}}, color = {0, 0, 127}));
  87. connect(totalClosingTime.y, divisionClose.u2) annotation(
  88. Line(points = {{-82, 24}, {-64, 24}}, color = {0, 0, 127}));
  89. connect(uppHys.y, uppSwi.u2) annotation(
  90. Line(points = {{-40, 133}, {-3, 133}}, color = {255, 0, 255}));
  91. connect(lowHys.y, lowSwi.u2) annotation(
  92. Line(points = {{-40, 71}, {-3, 71}}, color = {255, 0, 255}));
  93. connect(zer.y, uppSwi.u3) annotation(
  94. Line(points = {{-40, 103}, {-20, 103}, {-20, 124}, {-3, 124}}, color = {0, 0, 127}));
  95. connect(zer.y, lowSwi.u1) annotation(
  96. Line(points = {{-40, 103}, {-20, 103}, {-20, 78}, {-3, 78}}, color = {0, 0, 127}));
  97. connect(lowSwi.y, add.u2) annotation(
  98. Line(points = {{20, 71}, {28, 71}, {28, 97}, {37, 97}}, color = {0, 0, 127}));
  99. connect(uppSwi.y, add.u1) annotation(
  100. Line(points = {{20, 133}, {28, 133}, {28, 109}, {37, 109}}, color = {0, 0, 127}));
  101. connect(add.y, int.u) annotation(
  102. Line(points = {{60, 103}, {77, 103}}, color = {0, 0, 127}));
  103. connect(divisionOpen.y, uppSwi.u1) annotation(
  104. Line(points = {{-41, 178}, {-23, 178}, {-23, 142}, {-3, 142}}, color = {0, 0, 127}));
  105. connect(divisionClose.y, lowSwi.u3) annotation(
  106. Line(points = {{-41, 30}, {-23, 30}, {-23, 64}, {-3, 64}}, color = {0, 0, 127}));
  107. connect(feedback.y, uppHys.u) annotation(
  108. Line(points = {{-123, 104}, {-93, 104}, {-93, 133}, {-64, 133}}, color = {0, 0, 127}));
  109. connect(feedback.y, lowHys.u) annotation(
  110. Line(points = {{-123, 104}, {-93, 104}, {-93, 71}, {-64, 71}}, color = {0, 0, 127}));
  111. connect(setpointNorm.y, feedback.u1) annotation(
  112. Line(points = {{-181, 104}, {-140, 104}}, color = {0, 0, 127}));
  113. connect(int.y, max.u1) annotation(
  114. Line(points = {{100, 104}, {112, 104}, {112, 102}, {130, 102}}, color = {0, 0, 127}));
  115. connect(clamp_zero.y, max.u2) annotation(
  116. Line(points = {{112, 68}, {118, 68}, {118, 90}, {130, 90}}, color = {0, 0, 127}));
  117. connect(clamp_one.y, min.u1) annotation(
  118. Line(points = {{146, 130}, {162, 130}, {162, 110}, {178, 110}}, color = {0, 0, 127}));
  119. connect(max.y, min.u2) annotation(
  120. Line(points = {{154, 96}, {164, 96}, {164, 98}, {178, 98}}, color = {0, 0, 127}));
  121. connect(min.y, norm_motor_position) annotation(
  122. Line(points = {{202, 104}, {252, 104}}, color = {0, 0, 127}));
  123. connect(min.y, feedback.u2) annotation(
  124. Line(points = {{202, 104}, {210, 104}, {210, 0}, {-132, 0}, {-132, 96}}, color = {0, 0, 127}));
  125. connect(min.y, product.u1) annotation(
  126. Line(points = {{202, 104}, {210, 104}, {210, 0}, {58, 0}, {58, -10}, {104, -10}}, color = {0, 0, 127}));
  127. connect(motorRange.y, product.u2) annotation(
  128. Line(points = {{-212, 70}, {-174, 70}, {-174, -22}, {104, -22}}, color = {0, 0, 127}));
  129. connect(product.y, add1.u1) annotation(
  130. Line(points = {{128, -16}, {144, -16}, {144, -24}, {178, -24}}, color = {0, 0, 127}));
  131. connect(minMotorPosition.y, add1.u2) annotation(
  132. Line(points = {{-280, 86}, {-272, 86}, {-272, -36}, {178, -36}}, color = {0, 0, 127}));
  133. connect(add1.y, motor_position) annotation(
  134. Line(points = {{202, -30}, {226, -30}, {226, 52}, {248, 52}}, color = {0, 0, 127}));
  135. annotation(
  136. Diagram(coordinateSystem(extent = {{-360, 200}, {260, -60}}), graphics),
  137. Icon(graphics = {Polygon(origin = {-10, 10}, fillColor = {119, 118, 123}, fillPattern = FillPattern.Sphere, points = {{-110, 70}, {30, 70}, {50, 30}, {70, 30}, {70, 60}, {90, 60}, {90, -42}, {70, -42}, {70, -10}, {50, -10}, {30, -70}, {-80, -70}, {-110, -10}, {-110, -10}, {-110, 70}}), Polygon(origin = {-37, 100}, fillColor = {119, 118, 123}, fillPattern = FillPattern.HorizontalCylinder, points = {{17, 0}, {-13, 0}, {-43, 0}, {-43, 20}, {37, 20}, {37, 0}, {17, 0}}), Rectangle(origin = {-40, 90}, fillColor = {119, 118, 123}, fillPattern = FillPattern.VerticalCylinder, extent = {{-10, 10}, {10, -10}}), Polygon(origin = {-36, 8}, lineColor = {255, 255, 255}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, points = {{30, 10}, {10, 10}, {20, 50}, {-30, -10}, {-10, -10}, {-30, -50}, {-30, -50}, {30, 10}}), Text(origin = {-42, 56}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name")}, coordinateSystem(extent = {{-120, 160}, {120, -60}})),
  138. Documentation(info = "<html>
  139. <p>The Actuator model represents a standard linear actuator. In addition to the config-
  140. urable parameters of the Confgiration model from the Configuration package, the actuator features one input and
  141. two outputs:
  142. <ul>
  143. <li>input: setpoint_motor</li>
  144. <li>output: norm_motor_position</li>
  145. <li>output: motor_position</li>
  146. </ul>
  147. </p>
  148. <p>
  149. Given a motor setpoint, the actuator adjusts its position over time
  150. to reach the desired value. This motion is governed by two timing parameters: mo-
  151. tor_opening_time and motor_closing_time. When the actuator is at a given position and
  152. receives a new setpoint, it transitions to the new position at a rate proportional to these
  153. timing parameters. Since the valve models expect the motor position to be normalized between 0 and 1,
  154. the input setpoint must be normalized using:
  155. </p>
  156. <p>setpoint_norm = (setpoint_motor - min_motor_position)/(max_motor_position - min_motor_position)</p>
  157. <p>
  158. From this normalized value, the actuator computes a new normalized motor position, norm_motor_position,
  159. which serves as the input to the valve models. To recover the denormalized motor position, motor_position,
  160. the following denormalization is applied:
  161. </p>
  162. <p>motor_position = norm_motor_position·(max_motor_position − min_motor_position) + min_motor_position</p>
  163. </html>"));
  164. end Actuator;
  165. end Actuators;
  166. package Valves "Package with all the valves."
  167. extends Modelica.Icons.Package;
  168. model LinearValve "Valve with a linear characteristic"
  169. extends Components.BaseComponents.FluidBase;
  170. // Import Configuration
  171. outer Configurations.Configuration config;
  172. Modelica.Blocks.Interfaces.RealInput motor_position annotation(
  173. Placement(transformation(origin = {-100, 49}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {0, 59}, extent = {{-20, -20}, {20, 20}}, rotation = -90)));
  174. Pipes.Pipe pipe(length = 50, diameter = config.valve_diameter, redeclare package Medium = Medium) annotation(
  175. Placement(transformation(origin = {-30, 0}, extent = {{-10, -10}, {10, 10}})));
  176. Modelica.Fluid.Valves.ValveIncompressible valveIncompressible(redeclare package Medium = Medium, dp(start = config.pump_pressure), dp_nominal = config.pump_pressure, filteredOpening = false, m_flow(start = config.max_valve_flow_rate), m_flow_nominal = config.max_valve_flow_rate, m_flow_small = system.m_flow_small, m_flow_start = system.m_flow_start, show_T = false, redeclare function valveCharacteristic = Modelica.Fluid.Valves.BaseClasses.ValveCharacteristics.linear) annotation(
  177. Placement(transformation(origin = {36, 1}, extent = {{-10, -10}, {10, 10}})));
  178. equation
  179. connect(port_a, pipe.port_a) annotation(
  180. Line(points = {{-100, 0}, {-40, 0}}));
  181. connect(pipe.port_b, valveIncompressible.port_a) annotation(
  182. Line(points = {{-20, 0}, {1, 0}, {1, 1}, {26, 1}}, color = {0, 127, 255}));
  183. connect(valveIncompressible.port_b, port_b) annotation(
  184. Line(points = {{46, 1}, {100, 1}, {100, 0}}, color = {0, 127, 255}));
  185. connect(motor_position, valveIncompressible.opening) annotation(
  186. Line(points = {{-100, 50}, {36, 50}, {36, 10}}, color = {0, 0, 127}));
  187. annotation(
  188. Icon(graphics = {Polygon(origin = {-50, 0}, lineThickness = 0.5, points = {{50, 0}, {-50, 60}, {-50, -60}, {50, 0}, {50, 0}}), Polygon(origin = {50, 0}, rotation = 180, lineThickness = 0.5, points = {{50, 0}, {-50, 60}, {-50, -60}, {50, 0}, {50, 0}}), Line(origin = {0, 25.5}, points = {{0, -25.5}, {0, 26.5}, {0, 24.5}}, thickness = 0.5), Polygon(origin = {40, -70}, lineColor = {53, 132, 228}, fillColor = {53, 132, 228}, fillPattern = FillPattern.Solid, points = {{20, 0}, {-20, 10}, {-20, -10}, {-20, -10}, {20, 0}}), Line(origin = {-20, -70}, points = {{40, 0}, {-40, 0}, {-40, 0}}, color = {53, 132, 228}, thickness = 0.75), Text(origin = {-2, 22}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name")}),
  189. Diagram(graphics),
  190. Documentation(info = "<html>
  191. <p>The LinearValve model serves primarly as a wrapper around the TwoWayEqualPercentage
  192. model from the Buildings.Fluid.Actuators library. This abstraction simplifies integration
  193. by pre-configuring all relevant parameters, allowing the linear valve to be easily added
  194. to flow models without additional setup.</p>
  195. <p>In addition to the configurable parameters of the Confgiration model from the Configuration package, the linear valve features two inputs and one output:
  196. <ul>
  197. <li>input: motor_position</li>
  198. <li>input: port_a</li>
  199. <li>output: port_b</li>
  200. </ul>
  201. </p>
  202. <p>
  203. The motor position receives the normalized_motor_position from the actuator, port_a
  204. and port_b are the ends of the fluid connection constructing the flow path.
  205. </p>
  206. </html>"));
  207. end LinearValve;
  208. model EqualpercentageValve "Valve with a equal percentage characteristic"
  209. extends Components.BaseComponents.FluidBase;
  210. // Import Configuration
  211. outer Configurations.Configuration config;
  212. BaseComponents.TwoWayEqualPercentageBase.TwoWayEqualPercentage twoWayEqualPercentage(redeclare package Medium = Medium, m_flow_nominal = config.max_valve_flow_rate, m_flow(start = system.m_flow_start), dpValve_nominal = config.pump_pressure, CvData = Buildings.Fluid.Types.CvTypes.OpPoint, allowFlowReversal = system.allowFlowReversal, deltaM = config.deltaM, l = config.leakage, R = config.R, delta0 = config.delta0) annotation(
  213. Placement(transformation(origin = {30, 0}, extent = {{-10, -10}, {10, 10}})));
  214. Modelica.Blocks.Interfaces.RealInput motor_position annotation(
  215. Placement(transformation(origin = {-99, 49}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {0, 60}, extent = {{-19, -19}, {19, 19}}, rotation = -90)));
  216. Components.Pipes.Pipe pipe(redeclare package Medium = Medium, diameter = config.valve_diameter, length = 50) annotation(
  217. Placement(transformation(origin = {-30, 0}, extent = {{-11, -11}, {11, 11}})));
  218. equation
  219. connect(motor_position, twoWayEqualPercentage.opening) annotation(
  220. Line(points = {{-98, 50}, {30, 50}, {30, 4}}, color = {0, 0, 127}));
  221. connect(pipe.port_b, twoWayEqualPercentage.port_a) annotation(
  222. Line(points = {{-19, 0}, {20, 0}}, color = {0, 127, 255}));
  223. connect(port_a, pipe.port_a) annotation(
  224. Line(points = {{-100, 0}, {-41, 0}}));
  225. connect(twoWayEqualPercentage.port_b, port_b) annotation(
  226. Line(points = {{40, 0}, {100, 0}}, color = {0, 127, 255}));
  227. annotation(
  228. Diagram(graphics),
  229. Icon(graphics = {Polygon(origin = {-50, 0}, lineThickness = 0.5, points = {{50, 0}, {-50, 60}, {-50, -60}, {50, 0}, {50, 0}}), Polygon(origin = {50, 0}, rotation = 180, lineThickness = 0.5, points = {{50, 0}, {-50, 60}, {-50, -60}, {50, 0}, {50, 0}}), Line(origin = {0, 25.5}, points = {{0, -25.5}, {0, 26.5}, {0, 24.5}}, thickness = 0.5), Polygon(origin = {40, -70}, lineColor = {53, 132, 228}, fillColor = {53, 132, 228}, fillPattern = FillPattern.Solid, points = {{20, 0}, {-20, 10}, {-20, -10}, {-20, -10}, {20, 0}}), Line(origin = {-20, -70}, points = {{40, 0}, {-40, 0}, {-40, 0}}, color = {53, 132, 228}, thickness = 0.75), Text(origin = {-2, 22}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name"), Ellipse(origin = {-68, 12}, lineThickness = 0.75, extent = {{-6, 6}, {6, -6}}), Ellipse(origin = {-48, -8}, lineThickness = 0.75, extent = {{-6, 6}, {6, -6}}), Line(origin = {-58, 2}, points = {{-14, -14}, {14, 14}, {14, 14}}, thickness = 0.75)}),
  230. Documentation(info = "<html>
  231. <p>The EqualPercentageValve model serves primarly as a wrapper around the ValveIncompressible
  232. model from the Modelica.Fluid.Valves library. This abstraction simplifies integration
  233. by pre-configuring all relevant parameters, allowing the linear valve to be easily added
  234. to flow models without additional setup.</p>
  235. <p>In addition to the configurable parameters of the Confgiration model from the Configuration package, the linear valve features two inputs and one output:
  236. <ul>
  237. <li>input: motor_position</li>
  238. <li>input: port_a</li>
  239. <li>output: port_b</li>
  240. </ul>
  241. </p>
  242. <p>
  243. The motor position receives the normalized_motor_position from the actuator, port_a
  244. and port_b are the ends of the fluid connection constructing the flow path.
  245. </p>
  246. </html>"));
  247. end EqualpercentageValve;
  248. end Valves;
  249. package Pumps "Package with all the pumps."
  250. extends Modelica.Icons.Package;
  251. model PressurePump "Pressure pump with pressure parameter"
  252. extends Components.BaseComponents.FluidBase;
  253. outer Components.Configurations.Configuration config;
  254. Buildings.Fluid.Sources.Boundary_pT source(redeclare package Medium = Medium, nPorts = 1) annotation(
  255. Placement(transformation(origin = {-91, -50}, extent = {{-10, -10}, {10, 10}})));
  256. Buildings.Fluid.Movers.FlowControlled_dp pump_dp(redeclare package Medium = Medium, addPowerToMedium = true, allowFlowReversal = system.allowFlowReversal, constantHead = config.pump_pressure, dp_nominal = config.pump_pressure, dp_start = 0, energyDynamics = Modelica.Fluid.Types.Dynamics.SteadyState, heads = {0, 0.5, 1}*130000, init = Modelica.Blocks.Types.Init.NoInit, inputType = Buildings.Fluid.Types.InputType.Constant, m_flow_nominal = config.max_valve_flow_rate, redeclare Buildings.Fluid.Movers.Data.Generic per, show_T = false, use_riseTime = false, nominalValuesDefineDefaultPressureCurve = true, m_flow_small = system.m_flow_small) annotation(
  257. Placement(transformation(origin = {1, 80}, extent = {{-10, -90}, {10, -70}})));
  258. equation
  259. connect(source.ports[1], pump_dp.port_a) annotation(
  260. Line(points = {{-80, -50}, {-40, -50}, {-40, 0}, {-9, 0}}, color = {0, 127, 255}));
  261. connect(port_a, pump_dp.port_a) annotation(
  262. Line(points = {{-100, 0}, {-8, 0}}));
  263. connect(pump_dp.port_b, port_b) annotation(
  264. Line(points = {{12, 0}, {100, 0}}, color = {0, 127, 255}));
  265. annotation(
  266. Diagram(graphics),
  267. Icon(graphics = {Rectangle(fillColor = {0, 127, 255}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-100, 16}, {100, -16}}), Ellipse(fillColor = {0, 100, 199}, fillPattern = FillPattern.Sphere, extent = {{-58, 58}, {58, -58}}), Polygon(origin = {40, -80}, lineColor = {53, 132, 228}, fillColor = {53, 132, 228}, fillPattern = FillPattern.Solid, points = {{20, 0}, {-20, 10}, {-20, -10}, {-20, -10}, {20, 0}}), Line(origin = {-20, -80}, points = {{40, 0}, {-40, 0}, {-40, 0}}, color = {53, 132, 228}, thickness = 0.75), Text(origin = {-2, 22}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name")}),
  268. Documentation(info = "<html>
  269. <p>The PressurePump model serves primarly as a wrapper around the FlowControlled_dp model from the Buildings.Fluid.Movers library. This abstraction simplifies integration by pre-configuring all relevant parameters, allowing the pressure pump to be easily added to flow models without additional setup.</p>
  270. <p>In addition to the configurable parameters of the Confgiration model from the Configuration package, the pressure pump features one input and one output:
  271. <ul>
  272. <li>input: port_a</li>
  273. <li>output: port_b</li>
  274. </ul>
  275. </p>
  276. <p>
  277. Port_a and port_b are the ends of the fluid connection constructing the flow path.
  278. </p>
  279. </html>"));
  280. end PressurePump;
  281. end Pumps;
  282. package Sensors "Package with all the sensors."
  283. extends Modelica.Icons.Package;
  284. model FlowSensor "A flow rate measurement tool in m3/h"
  285. extends Components.BaseComponents.FluidBase;
  286. extends Modelica.Icons.RoundSensor;
  287. outer Components.Configurations.Configuration config;
  288. Modelica.Fluid.Sensors.VolumeFlowRate volumeFlowRate(redeclare package Medium = Medium, allowFlowReversal = system.allowFlowReversal, m_flow_nominal = system.m_flow_nominal, m_flow_small = system.m_flow_small) annotation(
  289. Placement(transformation(extent = {{-10, -10}, {10, 10}})));
  290. Modelica.Blocks.Math.Product product annotation(
  291. Placement(transformation(origin = {30, 51}, extent = {{-10, -10}, {10, 10}})));
  292. Modelica.Blocks.Sources.RealExpression realExpression1(y = 3600) annotation(
  293. Placement(transformation(origin = {-30, 57}, extent = {{10, -10}, {-10, 10}}, rotation = -180)));
  294. Modelica.Blocks.Interfaces.RealOutput flow_rate annotation(
  295. Placement(transformation(origin = {93, 51}, extent = {{-9, -9}, {9, 9}}), iconTransformation(origin = {0, 110}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  296. equation
  297. connect(volumeFlowRate.V_flow, product.u2) annotation(
  298. Line(points = {{0, 12}, {0, 45}, {18, 45}}, color = {0, 0, 127}));
  299. connect(realExpression1.y, product.u1) annotation(
  300. Line(points = {{-19, 57}, {18, 57}}, color = {0, 0, 127}));
  301. connect(product.y, flow_rate) annotation(
  302. Line(points = {{41, 51}, {93, 51}}, color = {0, 0, 127}));
  303. connect(port_a, volumeFlowRate.port_a) annotation(
  304. Line(points = {{-100, 0}, {-10, 0}}));
  305. connect(volumeFlowRate.port_b, port_b) annotation(
  306. Line(points = {{10, 0}, {100, 0}}, color = {0, 127, 255}));
  307. annotation(
  308. Icon(graphics = {Line(origin = {-80, 0}, points = {{-10, 0}, {10, 0}}, color = {53, 132, 228}, thickness = 0.5), Line(origin = {80, 0}, points = {{-10, 0}, {10, 0}}, color = {53, 132, 228}, thickness = 0.5), Line(origin = {0, 75}, points = {{0, -5}, {0, 5}, {0, 25}}, thickness = 0.5), Polygon(origin = {40, -100}, lineColor = {53, 132, 228}, fillColor = {53, 132, 228}, fillPattern = FillPattern.Solid, points = {{20, 0}, {-20, 10}, {-20, -10}, {-20, -10}, {20, 0}}), Line(origin = {-20, -100}, points = {{40, 0}, {-40, 0}, {-40, 0}}, color = {53, 132, 228}, thickness = 0.75), Text(origin = {0, 2}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name")}),
  309. Diagram(graphics),
  310. Documentation(info = "<html>
  311. <p>The FlowSensor model serves also primarily as a wrapper around the VolumeFlowRate model from the
  312. Modelica.Fluid.Sensors library. This abstraction simplifies integration by pre-configuring all relevant pa-
  313. rameters, allowing the flow sensor to be easily added to flow models without additional setup.</p>
  314. <p>Furthermore, since the VolumeFlowRate model provides its output in cubic meters per second (m3 /s), the
  315. value is multiplied by 3600 to convert it to cubic meters per hour.</p>
  316. <p>In addition to the configurable parameters of the Confgiration model from the Configuration package, the flow sensor features one input and two outputs:
  317. <ul>
  318. <li>input: port_a</li>
  319. <li>output: flow_rate</li>
  320. <li>output: port_b</li>
  321. </ul>
  322. </p>
  323. <p>
  324. The flow_rate is the measured flow and port_a and port_b are the ends of the fluid connection
  325. constructing the flow path.</p>
  326. </html>"));
  327. end FlowSensor;
  328. end Sensors;
  329. package Pipes "Package with all the models related to pipes."
  330. extends Modelica.Icons.Package;
  331. model Pipe "Basic pipe flow model without storage of mass or energy"
  332. extends Components.BaseComponents.FluidBase;
  333. outer Components.Configurations.Configuration config;
  334. parameter Real length "Length (mm)";
  335. parameter Real diameter "Diameter of circular pipe (mm)";
  336. parameter Real height_ab = 0 "Height(port_b) - Height(port_a) (mm)";
  337. Modelica.Fluid.Pipes.StaticPipe pipe(redeclare package Medium = Medium, allowFlowReversal = system.allowFlowReversal, diameter = diameter/1000, height_ab = height_ab/1000, length = length/1000, m_flow_start = system.m_flow_start, p_a_start = start_pressure_pipe) annotation(
  338. Placement(transformation(extent = {{11, 11}, {-11, -11}}, rotation = 180)));
  339. equation
  340. connect(port_a, pipe.port_a) annotation(
  341. Line(points = {{-100, 0}, {-10, 0}}));
  342. connect(pipe.port_b, port_b) annotation(
  343. Line(points = {{12, 0}, {100, 0}}, color = {0, 127, 255}));
  344. annotation(
  345. Diagram(graphics),
  346. Icon(graphics = {Polygon(origin = {40, -70}, lineColor = {53, 132, 228}, fillColor = {53, 132, 228}, fillPattern = FillPattern.Solid, points = {{20, 0}, {-20, 10}, {-20, -10}, {-20, -10}, {20, 0}}), Line(origin = {-20, -70}, points = {{40, 0}, {-40, 0}, {-40, 0}}, color = {53, 132, 228}, thickness = 0.75), Rectangle(fillColor = {53, 132, 228}, fillPattern = FillPattern.HorizontalCylinder, lineThickness = 0.5, extent = {{-100, 40}, {100, -40}}), Text(origin = {-2, 22}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name")}),
  347. Documentation(info = "<html>
  348. <p>The Pipe model serves primarily as a wrapper around the StaticPipe model from the Modelica.Fluid.Pipes
  349. library. This abstraction simplifies integration by pre-configuring all relevant parameters, allowing the pipe
  350. to be easily added to flow models without additional setup.</p>
  351. <p>
  352. The pipe contains three parameters:
  353. <ul>
  354. <li>height - mm</li>
  355. <li>diameter - mm</li>
  356. <li>height_ab - mm</li>
  357. </ul>
  358. </p>
  359. <p>In addition to the configurable parameters of the Confgiration model from the Configuration package, the pipe features one input and one output:
  360. <ul>
  361. <li>input: port_a</li>
  362. <li>output: port_b</li>
  363. </ul>
  364. </p>
  365. <p>
  366. Port_a and port_b are the ends of the fluid connection constructing the flow path.
  367. </p>
  368. </html>"));
  369. end Pipe;
  370. model Bend "Edged bend flow model"
  371. extends Components.BaseComponents.FluidBase;
  372. outer Components.Configurations.Configuration config;
  373. parameter Real angle "Angle of the bend (degrees)";
  374. parameter Real pipe_diameter "Diameter of the pipe (mm)";
  375. protected
  376. parameter Real angle_rad = angle*(Modelica.Constants.pi/180);
  377. Modelica.Fluid.Fittings.Bends.EdgedBend bend(redeclare package Medium = Medium, geometry(d_hyd = pipe_diameter / 1000, delta = angle_rad), m_flow_small = system.m_flow_small, show_T = false, dp(start = config.pump_pressure), m_flow(start = system.m_flow_start)) annotation(
  378. Placement(transformation(origin = {1, 0}, extent = {{9, -9}, {-9, 9}}, rotation = 180)));
  379. public
  380. equation
  381. connect(port_a, bend.port_a) annotation(
  382. Line(points = {{-100, 0}, {-8, 0}}));
  383. connect(bend.port_b, port_b) annotation(
  384. Line(points = {{10, 0}, {100, 0}}, color = {0, 127, 255}));
  385. annotation(
  386. Diagram(graphics),
  387. Icon(graphics = {Polygon(origin = {40, -70}, lineColor = {53, 132, 228}, fillColor = {53, 132, 228}, fillPattern = FillPattern.Solid, points = {{20, 0}, {-20, 10}, {-20, -10}, {-20, -10}, {20, 0}}), Line(origin = {-20, -70}, points = {{40, 0}, {-40, 0}, {-40, 0}}, color = {53, 132, 228}, thickness = 0.75), Text(origin = {-2, 22}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name"), Polygon(origin = {-1, 0}, fillColor = {53, 132, 228}, fillPattern = FillPattern.HorizontalCylinder, points = {{15, 30}, {45, 30}, {45, -30}, {-45, -30}, {15, 30}, {15, 30}}), Polygon(origin = {-16, 15}, fillColor = {53, 132, 228}, fillPattern = FillPattern.VerticalCylinder, points = {{-30, -45}, {-30, 45}, {30, 45}, {30, 15}, {-30, -45}, {-30, -45}}), Ellipse(origin = {-16, 60}, fillColor = {26, 95, 180}, fillPattern = FillPattern.Sphere, extent = {{-30, 10}, {30, -10}}), Ellipse(origin = {44, 0}, rotation = -90, fillColor = {26, 95, 180}, fillPattern = FillPattern.Sphere, extent = {{-30, 10}, {30, -10}}), Line(origin = {-74, 0}, points = {{-24, 0}, {24, 0}, {24, 0}}, color = {53, 132, 228}, thickness = 0.5), Line(origin = {74, 0}, points = {{-26, 0}, {26, 0}, {26, 0}}, color = {53, 132, 228}, thickness = 0.5)}, coordinateSystem(extent = {{-160, 80}, {160, -140}})),
  388. Documentation(info = "<html>
  389. <p>The Bend model serves primarily as a wrapper around the EdgedBend model from the Modelica.Fluid.Fittings.Bends library. This abstraction simplifies integration by pre-configuring all relevant parameters, allowing the bend to be easily added to flow models without additional setup.</p>
  390. <p>
  391. The bend contains two parameters:
  392. <ul>
  393. <li>angle - degrees</li>
  394. <li>pipe_diameter - m</li>
  395. </ul>
  396. </p>
  397. <p>In addition to the configurable parameters of the Confgiration model from the Configuration package, the bend features one input and one output:
  398. <ul>
  399. <li>input: port_a</li>
  400. <li>output: port_b</li>
  401. </ul>
  402. </p>
  403. <p>
  404. Port_a and port_b are the ends of the fluid connection constructing the flow path.
  405. </p>
  406. </html>"));
  407. end Bend;
  408. end Pipes;
  409. package Configurations "Package with all the configuarations."
  410. extends Modelica.Icons.Package;
  411. model Configuration
  412. // Dynamx - Actuator settings
  413. parameter Real min_motor_position = 0 "The minimum position of the actuator" annotation(
  414. Dialog(tab = "Dynamx settings", group = "Actuator"));
  415. parameter Real max_motor_position = 10 "The maximum position of the actuator" annotation(
  416. Dialog(tab = "Dynamx settings", group = "Actuator"));
  417. parameter Real start_motor_position = 5 "Start position of the actuator" annotation(
  418. Dialog(tab = "Dynamx settings", group = "Actuator"));
  419. parameter Real total_opening_time = 120 "Time it takes to reach the maximum position of the actuator" annotation(
  420. Dialog(tab = "Dynamx settings", group = "Actuator"));
  421. parameter Real total_closing_time = 120 "Time it takes to reach the minimum position of the actuator" annotation(
  422. Dialog(tab = "Dynamx settings", group = "Actuator"));
  423. // Dynamx - Valve settings
  424. parameter Real valve_diameter = 20 "Diameter of the pipe in the valve (mm)" annotation(
  425. Dialog(tab = "Dynamx settings", group = "Valve"));
  426. parameter Real max_valve_flow_rate = 1 "Maximum flow rate of the valve at full opening (kg/s)" annotation(
  427. Dialog(tab = "Dynamx settings", group = "Valve"));
  428. parameter Boolean has_equal_percentage_characteristic = false "Use equal percentage characteristic" annotation(
  429. Dialog(tab = "Dynamx settings", group = "Valve"));
  430. // These are enabled only if the checkbox is selected
  431. parameter Real leakage = 0.00001 "Valve leakage" annotation(
  432. Dialog(tab = "Dynamx settings", group = "Valve", enable = has_equal_percentage_characteristic));
  433. parameter Real R = 50 "Rangeability, R=50...100 typically" annotation(
  434. Dialog(tab = "Dynamx settings", group = "Valve", enable = has_equal_percentage_characteristic));
  435. parameter Real delta0 = 0.01 "Range of significant deviation from equal percentage law" annotation(
  436. Dialog(tab = "Dynamx settings", group = "Valve", enable = has_equal_percentage_characteristic));
  437. parameter Real deltaM = 0.02 "Fraction of nominal flow rate where linearization starts, if y=1" annotation(
  438. Dialog(tab = "Dynamx settings", group = "Valve", enable = has_equal_percentage_characteristic));
  439. // Pump settings
  440. parameter Real pump_pressure = 130000 "The pressure of the pump" annotation(
  441. Dialog(tab = "Pump settings"));
  442. annotation(
  443. Diagram(graphics),
  444. Icon(graphics = {Text(origin = {-2, 12}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name"), Rectangle(extent = {{-100, 100}, {100, -100}})}),
  445. defaultComponentName = "config");
  446. end Configuration;
  447. end Configurations;
  448. package Dynamx
  449. extends Modelica.Icons.Package;
  450. model LinearDefaultActuator "A dynamx component that combines the functionalities of a linear actuator, linear valve, and a flow sensor."
  451. extends Components.BaseComponents.DynamxBase;
  452. Valves.LinearValve linearValve(redeclare package Medium = Medium) annotation(
  453. Placement(transformation(origin = {-30, 0}, extent = {{-10, -10}, {10, 10}})));
  454. Actuators.Actuator actuator annotation(
  455. Placement(transformation(origin = {-58, 40}, extent = {{-12, -11}, {12, 11}})));
  456. equation
  457. connect(port_a, linearValve.port_a) annotation(
  458. Line(points = {{-100, 0}, {-40, 0}}));
  459. connect(linearValve.port_b, flowSensor.port_a) annotation(
  460. Line(points = {{-20, 0}, {20, 0}}, color = {0, 127, 255}));
  461. connect(setpoint_motor, actuator.setpoint_motor) annotation(
  462. Line(points = {{0, 100}, {0, 58}, {-62, 58}, {-62, 50}}, color = {0, 0, 127}));
  463. connect(actuator.norm_motor_position, linearValve.motor_position) annotation(
  464. Line(points = {{-48, 40}, {-30, 40}, {-30, 6}}, color = {0, 0, 127}));
  465. connect(actuator.motor_position, motor_position) annotation(
  466. Line(points = {{-48, 34}, {-40, 34}, {-40, 14}, {-54, 14}, {-54, -18}, {-30, -18}, {-30, -92}, {-28, -92}}, color = {0, 0, 127}));
  467. end LinearDefaultActuator;
  468. model EqualPercentageDefaultActuator "A dynamx component that combines the functionalities of a linear actuator, equal percentage valve, and a flow sensor."
  469. extends BaseComponents.DynamxBase;
  470. Actuators.Actuator actuator annotation(
  471. Placement(transformation(origin = {-50, 50}, extent = {{-12, -11}, {12, 11}})));
  472. Valves.EqualpercentageValve equalpercentageValve(redeclare package Medium = Medium) annotation(
  473. Placement(transformation(origin = {-30, 0}, extent = {{-10, -10}, {10, 10}})));
  474. equation
  475. connect(setpoint_motor, actuator.setpoint_motor) annotation(
  476. Line(points = {{0, 100}, {0, 72}, {-54, 72}, {-54, 59}}, color = {0, 0, 127}));
  477. connect(port_a, equalpercentageValve.port_a) annotation(
  478. Line(points = {{-100, 0}, {-40, 0}}));
  479. connect(actuator.norm_motor_position, equalpercentageValve.motor_position) annotation(
  480. Line(points = {{-40, 50}, {-30, 50}, {-30, 6}}, color = {0, 0, 127}));
  481. connect(actuator.motor_position, motor_position) annotation(
  482. Line(points = {{-40, 44}, {-34, 44}, {-34, 14}, {-54, 14}, {-54, -46}, {-28, -46}, {-28, -92}}, color = {0, 0, 127}));
  483. connect(equalpercentageValve.port_b, flowSensor.port_a) annotation(
  484. Line(points = {{-20, 0}, {20, 0}}, color = {0, 127, 255}));
  485. end EqualPercentageDefaultActuator;
  486. end Dynamx;
  487. package PipeNetworks
  488. extends Modelica.Icons.Package;
  489. model SimpleNetwork "A simple pipe network"
  490. extends Components.BaseComponents.PipeNetworksBase;
  491. Pipes.Pipe pipe(length = 100, diameter = 20) annotation(
  492. Placement(transformation(origin = {0, 68}, extent = {{-10, -10}, {10, 10}})));
  493. equation
  494. connect(output_pump, input_valve) annotation(
  495. Line(points = {{-210, 150}, {60, 150}, {60, -112}, {210, -112}}));
  496. connect(output_valve, pipe.port_a) annotation(
  497. Line(points = {{-210, -112}, {-82, -112}, {-82, 68}, {-10, 68}}));
  498. connect(pipe.port_b, input_pump) annotation(
  499. Line(points = {{10, 68}, {146, 68}, {146, 148}, {210, 148}}, color = {0, 127, 255}));
  500. connect(output_valve, pipe.port_a) annotation(
  501. Line(points = {{-210, -112}, {-112, -112}, {-112, 118}, {-8, 118}}));
  502. connect(pipe.port_b, input_pump) annotation(
  503. Line(points = {{12, 118}, {210, 118}, {210, 148}}, color = {0, 127, 255}));
  504. end SimpleNetwork;
  505. model TestSetupNetwork
  506. extends Components.BaseComponents.PipeNetworksBase;
  507. Pipes.Pipe pipe(length = 900, diameter = 25, height_ab = -900) annotation(
  508. Placement(transformation(origin = {-210, -136}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  509. Components.Pipes.Pipe pipe1(length = 1780, diameter = 25, height_ab = 0) annotation(
  510. Placement(transformation(origin = {-210, -198}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  511. Components.Pipes.Pipe pipe2(length = 235, diameter = 25, height_ab = 235) annotation(
  512. Placement(transformation(origin = {-156, -213}, extent = {{-10, -10}, {10, 10}})));
  513. Components.Pipes.Pipe pipe3(length = 125, diameter = 25, height_ab = 0) annotation(
  514. Placement(transformation(origin = {-87, -213}, extent = {{-10, -10}, {10, 10}})));
  515. Components.Pipes.Pipe pipe4(length = 180, diameter = 25, height_ab = -180) annotation(
  516. Placement(transformation(origin = {-17, -213}, extent = {{-10, -10}, {10, 10}})));
  517. Components.Pipes.Pipe pipe5(length = 41, diameter = 35, height_ab = 0) annotation(
  518. Placement(transformation(origin = {48, -212}, extent = {{-10, -10}, {10, 10}})));
  519. Components.Pipes.Pipe pipe6(length = 1720, diameter = 35, height_ab = 0) annotation(
  520. Placement(transformation(origin = {114, -211}, extent = {{-10, -10}, {10, 10}})));
  521. Components.Pipes.Pipe pipe7(length = 150, diameter = 35, height_ab = 150) annotation(
  522. Placement(transformation(origin = {186, -210}, extent = {{-10, -10}, {10, 10}})));
  523. Components.Pipes.Pipe pipe8(length = 200, diameter = 35, height_ab = 0) annotation(
  524. Placement(transformation(origin = {233, -157}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  525. Components.Pipes.Pipe pipe9(length = 900, diameter = 35, height_ab = 0) annotation(
  526. Placement(transformation(origin = {234, -91}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  527. Components.Pipes.Pipe pipe10(length = 330, diameter = 35, height_ab = 330) annotation(
  528. Placement(transformation(origin = {232, -25}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  529. Components.Pipes.Pipe pipe11(length = 140, diameter = 35, height_ab = 0) annotation(
  530. Placement(transformation(origin = {232, 35}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  531. Components.Pipes.Pipe pipe21(length = 1370, diameter = 35, height_ab = 1370) annotation(
  532. Placement(transformation(origin = {232, 94}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  533. Components.Pipes.Pipe pipe31(length = 1050, diameter = 20, height_ab = 0) annotation(
  534. Placement(transformation(origin = {233, 150}, extent = {{-10, -10}, {10, 10}}, rotation = 90)));
  535. Components.Pipes.Pipe pipe41(length = 150, diameter = 20, height_ab = 150) annotation(
  536. Placement(transformation(origin = {223, 202}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
  537. Components.Pipes.Pipe pipe51(length = 440, diameter = 20, height_ab = 0) annotation(
  538. Placement(transformation(origin = {-184, 151}, extent = {{-10, -10}, {10, 10}})));
  539. Components.Pipes.Pipe pipe61(length = 1440, diameter = 35, height_ab = -1440) annotation(
  540. Placement(transformation(origin = {-126, 152}, extent = {{-10, -10}, {10, 10}})));
  541. Components.Pipes.Pipe pipe71(length = 120, diameter = 35, height_ab = 0) annotation(
  542. Placement(transformation(origin = {-62, 151}, extent = {{-10, -10}, {10, 10}})));
  543. Components.Pipes.Pipe pipe81(diameter = 35, length = 360, height_ab = 0) annotation(
  544. Placement(transformation(origin = {5, 152}, extent = {{-10, -10}, {10, 10}})));
  545. Components.Pipes.Pipe pipe91(length = 910, diameter = 35, height_ab = 0) annotation(
  546. Placement(transformation(origin = {70, 150}, extent = {{-10, -10}, {10, 10}})));
  547. Components.Pipes.Pipe pipe13(length = 1500, diameter = 35, height_ab = 0) annotation(
  548. Placement(transformation(origin = {100, 105}, extent = {{-10, 10}, {10, -10}}, rotation = -90)));
  549. Components.Pipes.Pipe pipe12(length = 130, diameter = 35, height_ab = 92) annotation(
  550. Placement(transformation(origin = {58, 87}, extent = {{10, -10}, {-10, 10}})));
  551. Components.Pipes.Pipe pipe22(length = 170, diameter = 35, height_ab = 0) annotation(
  552. Placement(transformation(origin = {-2, 88}, extent = {{10, -10}, {-10, 10}})));
  553. Components.Pipes.Pipe pipe32(length = 180, diameter = 68, height_ab = -180) annotation(
  554. Placement(transformation(origin = {-57, 88}, extent = {{10, -10}, {-10, 10}})));
  555. Components.Pipes.Pipe pipe42(length = 360, diameter = 20) annotation(
  556. Placement(transformation(origin = {-107, 78}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  557. Components.Pipes.Pipe pipe52(length = 1340, diameter = 20, height_ab = 0) annotation(
  558. Placement(transformation(origin = {-108, 21}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  559. Components.Pipes.Pipe pipe62(length = 120, diameter = 20, height_ab = 120) annotation(
  560. Placement(transformation(origin = {-108, -40}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  561. Components.Pipes.Pipe pipe72(length = 548.4, diameter = 20) annotation(
  562. Placement(transformation(origin = {-94, -105}, extent = {{-10, -10}, {10, 10}})));
  563. Components.Pipes.Pipe pipe82(diameter = 20, height_ab = 70.7, length = 100) annotation(
  564. Placement(transformation(origin = {-29, -106}, extent = {{-10, -10}, {10, 10}})));
  565. Components.Pipes.Pipe pipe92(length = 1200, diameter = 25, height_ab = 1200) annotation(
  566. Placement(transformation(origin = {28, -106}, extent = {{-10, -10}, {10, 10}})));
  567. Pipes.Bend bend(angle = 90, pipe_diameter = 25) annotation(
  568. Placement(transformation(origin = {-213, -165.455}, extent = {{-17.4545, -12}, {17.4545, 12}}, rotation = -90)));
  569. Components.Pipes.Bend bend1(angle = 90, pipe_diameter = 25) annotation(
  570. Placement(transformation(origin = {-187, -216.312}, extent = {{-17, -11.6875}, {17, 11.6875}})));
  571. Components.Pipes.Bend bend2(angle = 90, pipe_diameter = 25) annotation(
  572. Placement(transformation(origin = {-125.545, -215}, extent = {{-16.5455, -11.375}, {16.5455, 11.375}})));
  573. Components.Pipes.Bend bend3(angle = 90, pipe_diameter = 25) annotation(
  574. Placement(transformation(origin = {-50, -216}, extent = {{-16, -11}, {16, 11}})));
  575. Components.Pipes.Bend bend4(angle = 90, pipe_diameter = 25) annotation(
  576. Placement(transformation(origin = {15, -216}, extent = {{-16, -11}, {16, 11}})));
  577. Components.Pipes.Bend bend5(angle = 90, pipe_diameter = 35) annotation(
  578. Placement(transformation(origin = {80, -215}, extent = {{-16, -11}, {16, 11}})));
  579. Components.Pipes.Bend bend11(angle = 35, pipe_diameter = 90) annotation(
  580. Placement(transformation(origin = {148, -214}, extent = {{-16, -11}, {16, 11}})));
  581. Components.Pipes.Bend bend21(angle = 90, pipe_diameter = 35) annotation(
  582. Placement(transformation(origin = {237, -123}, extent = {{-16, -11}, {16, 11}}, rotation = 90)));
  583. Components.Pipes.Bend bend31(angle = 90, pipe_diameter = 35) annotation(
  584. Placement(transformation(origin = {236, -57}, extent = {{-16, -11}, {16, 11}}, rotation = 90)));
  585. Components.Pipes.Bend bend41(angle = 90, pipe_diameter = 35) annotation(
  586. Placement(transformation(origin = {235, 5}, extent = {{-16, -11}, {16, 11}}, rotation = 90)));
  587. Components.Pipes.Bend bend6(angle = 90, pipe_diameter = 35) annotation(
  588. Placement(transformation(origin = {236, -192}, extent = {{-16, -11}, {16, 11}}, rotation = 90)));
  589. Components.Pipes.Bend bend12(angle = 90, pipe_diameter = 35) annotation(
  590. Placement(transformation(origin = {236, 63}, extent = {{-16, -11}, {16, 11}}, rotation = 90)));
  591. Components.Pipes.Bend bend22(angle = 90, pipe_diameter = 35) annotation(
  592. Placement(transformation(origin = {235, 120}, extent = {{-16, -11}, {16, 11}}, rotation = 90)));
  593. Components.Pipes.Bend bend32(angle = 90, pipe_diameter = 20) annotation(
  594. Placement(transformation(origin = {236, 178}, extent = {{-16, -11}, {16, 11}}, rotation = 90)));
  595. Components.Pipes.Bend bend42(angle = 90, pipe_diameter = 20) annotation(
  596. Placement(transformation(origin = {213, 176}, extent = {{-16, 11}, {16, -11}}, rotation = -90)));
  597. Components.Pipes.Bend bend51(angle = 90, pipe_diameter = 35) annotation(
  598. Placement(transformation(origin = {-156, 149}, extent = {{-16, -11}, {16, 11}})));
  599. Components.Pipes.Bend bend111(angle = 90, pipe_diameter = 35) annotation(
  600. Placement(transformation(origin = {-94, 148}, extent = {{-16, -11}, {16, 11}})));
  601. Components.Pipes.Bend bend211(angle = 90, pipe_diameter = 35) annotation(
  602. Placement(transformation(origin = {-29, 149}, extent = {{-16, -11}, {16, 11}})));
  603. Components.Pipes.Bend bend311(angle = 90, pipe_diameter = 35) annotation(
  604. Placement(transformation(origin = {36, 149}, extent = {{-16, -11}, {16, 11}})));
  605. Components.Pipes.Bend bend411(angle = 90, pipe_diameter = 35) annotation(
  606. Placement(transformation(origin = {103, 133}, extent = {{-16, 11}, {16, -11}}, rotation = -90)));
  607. Components.Pipes.Bend bend7(angle = 90, pipe_diameter = 35) annotation(
  608. Placement(transformation(origin = {85, 84}, extent = {{16, -11}, {-16, 11}})));
  609. Components.Pipes.Bend bend13(angle = 90, pipe_diameter = 35) annotation(
  610. Placement(transformation(origin = {31, 85}, extent = {{16, -11}, {-16, 11}})));
  611. Components.Pipes.Bend bend23(angle = 90, pipe_diameter = 35) annotation(
  612. Placement(transformation(origin = {-30, 88}, extent = {{16, -11}, {-16, 11}})));
  613. Components.Pipes.Bend bend33(angle = 90, pipe_diameter = 20) annotation(
  614. Placement(transformation(origin = {-83, 86}, extent = {{16, -11}, {-16, 11}})));
  615. Components.Pipes.Bend bend43(angle = 90, pipe_diameter = 25) annotation(
  616. Placement(transformation(origin = {-112, -8}, extent = {{-16, -11}, {16, 11}}, rotation = -90)));
  617. Components.Pipes.Bend bend52(angle = 90, pipe_diameter = 20) annotation(
  618. Placement(transformation(origin = {-111, 51}, extent = {{-16, -11}, {16, 11}}, rotation = -90)));
  619. Components.Pipes.Bend bend112(angle = 90, pipe_diameter = 20) annotation(
  620. Placement(transformation(origin = {-111, -72}, extent = {{-16, -11}, {16, 11}}, rotation = -90)));
  621. Components.Pipes.Bend bend212(angle = 90, pipe_diameter = 20) annotation(
  622. Placement(transformation(origin = {-60, -109}, extent = {{-16, -11}, {16, 11}})));
  623. Components.Pipes.Bend bend312(angle = 45, pipe_diameter = 25) annotation(
  624. Placement(transformation(origin = {-1, -109}, extent = {{-16, -11}, {16, 11}})));
  625. Components.Pipes.Bend bend412(angle = 90, pipe_diameter = 25) annotation(
  626. Placement(transformation(origin = {58, -109}, extent = {{-16, -11}, {16, 11}})));
  627. Components.Pipes.Pipe pipe521(length = 231, diameter = 25, height_ab = 0) annotation(
  628. Placement(transformation(origin = {88, -107}, extent = {{-10, -10}, {10, 10}})));
  629. Components.Pipes.Pipe pipe621(length = 455, diameter = 20, height_ab = -455) annotation(
  630. Placement(transformation(origin = {154, -110}, extent = {{-10, -10}, {10, 10}})));
  631. Components.Pipes.Bend bend4121(angle = 90, pipe_diameter = 25) annotation(
  632. Placement(transformation(origin = {122, -111}, extent = {{-16, -11}, {16, 11}})));
  633. Actuators.Actuator actuator annotation(
  634. Placement(transformation(origin = {-402, 76}, extent = {{-12, -11}, {12, 11}})));
  635. equation
  636. connect(output_valve, pipe.port_a) annotation(
  637. Line(points = {{-210, -112}, {-210, -126}}));
  638. connect(pipe.port_b, bend.port_a) annotation(
  639. Line(points = {{-210, -146}, {-210, -155}}, color = {0, 127, 255}));
  640. connect(bend.port_b, pipe1.port_a) annotation(
  641. Line(points = {{-210, -176}, {-210, -188}}, color = {0, 127, 255}));
  642. connect(pipe1.port_b, bend1.port_a) annotation(
  643. Line(points = {{-210, -208}, {-210, -213}, {-198, -213}}, color = {0, 127, 255}));
  644. connect(bend1.port_b, pipe2.port_a) annotation(
  645. Line(points = {{-176, -213}, {-166, -213}}, color = {0, 127, 255}));
  646. connect(pipe2.port_b, bend2.port_a) annotation(
  647. Line(points = {{-146, -213}, {-136, -213}, {-136, -212}}, color = {0, 127, 255}));
  648. connect(bend2.port_b, pipe3.port_a) annotation(
  649. Line(points = {{-115, -212}, {-104.5, -212}, {-104.5, -213}, {-97, -213}}, color = {0, 127, 255}));
  650. connect(pipe3.port_b, bend3.port_a) annotation(
  651. Line(points = {{-77, -213}, {-60, -213}}, color = {0, 127, 255}));
  652. connect(bend3.port_b, pipe4.port_a) annotation(
  653. Line(points = {{-40, -213}, {-27, -213}}, color = {0, 127, 255}));
  654. connect(pipe4.port_b, bend4.port_a) annotation(
  655. Line(points = {{-7, -213}, {5, -213}}, color = {0, 127, 255}));
  656. connect(pipe5.port_b, bend5.port_a) annotation(
  657. Line(points = {{58, -212}, {70, -212}}, color = {0, 127, 255}));
  658. connect(pipe6.port_b, bend11.port_a) annotation(
  659. Line(points = {{124, -211}, {138, -211}}, color = {0, 127, 255}));
  660. connect(pipe7.port_b, bend6.port_a) annotation(
  661. Line(points = {{196, -210}, {233, -210}, {233, -202}}, color = {0, 127, 255}));
  662. connect(bend6.port_b, pipe8.port_a) annotation(
  663. Line(points = {{233, -182}, {233, -167}}, color = {0, 127, 255}));
  664. connect(pipe8.port_b, bend21.port_a) annotation(
  665. Line(points = {{233, -147}, {234, -147}, {234, -133}}, color = {0, 127, 255}));
  666. connect(bend21.port_b, pipe9.port_a) annotation(
  667. Line(points = {{234, -113}, {234, -101}}, color = {0, 127, 255}));
  668. connect(pipe10.port_b, bend41.port_a) annotation(
  669. Line(points = {{232, -15}, {232, -5}}, color = {0, 127, 255}));
  670. connect(bend41.port_b, pipe11.port_a) annotation(
  671. Line(points = {{232, 15}, {232, 24}}, color = {0, 127, 255}));
  672. connect(bend12.port_b, pipe21.port_a) annotation(
  673. Line(points = {{233, 73}, {232, 73}, {232, 84}}, color = {0, 127, 255}));
  674. connect(pipe21.port_b, bend22.port_a) annotation(
  675. Line(points = {{232, 104}, {232, 110}}, color = {0, 127, 255}));
  676. connect(bend22.port_b, pipe31.port_a) annotation(
  677. Line(points = {{232, 130}, {233, 130}, {233, 140}}, color = {0, 127, 255}));
  678. connect(pipe31.port_b, bend32.port_a) annotation(
  679. Line(points = {{233, 160}, {233, 168}}, color = {0, 127, 255}));
  680. connect(bend32.port_b, pipe41.port_a) annotation(
  681. Line(points = {{233, 188}, {233, 202}}, color = {0, 127, 255}));
  682. connect(pipe41.port_b, bend42.port_a) annotation(
  683. Line(points = {{213, 202}, {210, 202}, {210, 186}}, color = {0, 127, 255}));
  684. connect(bend42.port_b, input_pump) annotation(
  685. Line(points = {{210, 166}, {210, 148}}, color = {0, 127, 255}));
  686. connect(bend4.port_b, pipe5.port_a) annotation(
  687. Line(points = {{26, -212}, {38, -212}}, color = {0, 127, 255}));
  688. connect(bend5.port_b, pipe6.port_a) annotation(
  689. Line(points = {{90, -212}, {100, -212}, {100, -211}, {104, -211}}, color = {0, 127, 255}));
  690. connect(bend11.port_b, pipe7.port_a) annotation(
  691. Line(points = {{158, -210}, {176, -210}}, color = {0, 127, 255}));
  692. connect(pipe9.port_b, bend31.port_a) annotation(
  693. Line(points = {{234, -80}, {234, -66}}, color = {0, 127, 255}));
  694. connect(bend31.port_b, pipe10.port_a) annotation(
  695. Line(points = {{234, -46}, {232, -46}, {232, -34}}, color = {0, 127, 255}));
  696. connect(pipe11.port_b, bend12.port_a) annotation(
  697. Line(points = {{232, 46}, {233, 46}, {233, 53}}, color = {0, 127, 255}));
  698. connect(output_pump, pipe51.port_a) annotation(
  699. Line(points = {{-210, 150}, {-194, 150}, {-194, 152}}));
  700. connect(pipe51.port_b, bend51.port_a) annotation(
  701. Line(points = {{-174, 151}, {-167, 151}, {-167, 152}, {-166, 152}}, color = {0, 127, 255}));
  702. connect(bend51.port_b, pipe61.port_a) annotation(
  703. Line(points = {{-146, 152}, {-136, 152}}, color = {0, 127, 255}));
  704. connect(pipe61.port_b, bend111.port_a) annotation(
  705. Line(points = {{-116, 152}, {-104, 152}, {-104, 151}}, color = {0, 127, 255}));
  706. connect(bend111.port_b, pipe71.port_a) annotation(
  707. Line(points = {{-84, 151}, {-72, 151}}, color = {0, 127, 255}));
  708. connect(pipe71.port_b, bend211.port_a) annotation(
  709. Line(points = {{-52, 151}, {-39, 151}, {-39, 152}}, color = {0, 127, 255}));
  710. connect(bend211.port_b, pipe81.port_a) annotation(
  711. Line(points = {{-19, 152}, {-5, 152}}, color = {0, 127, 255}));
  712. connect(pipe81.port_b, bend311.port_a) annotation(
  713. Line(points = {{15, 152}, {26, 152}}, color = {0, 127, 255}));
  714. connect(bend311.port_b, pipe91.port_a) annotation(
  715. Line(points = {{46, 152}, {60, 152}, {60, 150}}, color = {0, 127, 255}));
  716. connect(bend411.port_b, pipe13.port_a) annotation(
  717. Line(points = {{100, 123}, {100, 115}}, color = {0, 127, 255}));
  718. connect(bend7.port_b, pipe12.port_a) annotation(
  719. Line(points = {{75, 87}, {68, 87}}, color = {0, 127, 255}));
  720. connect(pipe12.port_b, bend13.port_a) annotation(
  721. Line(points = {{48, 87}, {41, 87}, {41, 88}}, color = {0, 127, 255}));
  722. connect(bend13.port_b, pipe22.port_a) annotation(
  723. Line(points = {{21, 88}, {8, 88}}, color = {0, 127, 255}));
  724. connect(pipe22.port_b, bend23.port_a) annotation(
  725. Line(points = {{-12, 88}, {-20, 88}, {-20, 91}}, color = {0, 127, 255}));
  726. connect(pipe32.port_b, bend33.port_a) annotation(
  727. Line(points = {{-67, 88}, {-67, 89}, {-73, 89}}, color = {0, 127, 255}));
  728. connect(bend33.port_b, pipe42.port_a) annotation(
  729. Line(points = {{-93, 89}, {-106, 89}, {-106, 88}}, color = {0, 127, 255}));
  730. connect(pipe42.port_b, bend52.port_a) annotation(
  731. Line(points = {{-106, 68}, {-108, 68}, {-108, 62}}, color = {0, 127, 255}));
  732. connect(bend52.port_b, pipe52.port_a) annotation(
  733. Line(points = {{-108, 42}, {-108, 32}}, color = {0, 127, 255}));
  734. connect(pipe52.port_b, bend43.port_a) annotation(
  735. Line(points = {{-108, 12}, {-108, 6}, {-109, 6}, {-109, 2}}, color = {0, 127, 255}));
  736. connect(bend43.port_b, pipe62.port_a) annotation(
  737. Line(points = {{-109, -18}, {-109, -26}, {-108, -26}, {-108, -30}}, color = {0, 127, 255}));
  738. connect(pipe62.port_b, bend112.port_a) annotation(
  739. Line(points = {{-108, -50}, {-108, -62}}, color = {0, 127, 255}));
  740. connect(bend112.port_b, pipe72.port_a) annotation(
  741. Line(points = {{-108, -82}, {-108, -105}, {-104, -105}}, color = {0, 127, 255}));
  742. connect(pipe72.port_b, bend212.port_a) annotation(
  743. Line(points = {{-84, -105}, {-75, -105}, {-75, -106}, {-70, -106}}, color = {0, 127, 255}));
  744. connect(bend212.port_b, pipe82.port_a) annotation(
  745. Line(points = {{-50, -106}, {-39, -106}}, color = {0, 127, 255}));
  746. connect(pipe82.port_b, bend312.port_a) annotation(
  747. Line(points = {{-19, -106}, {-11, -106}}, color = {0, 127, 255}));
  748. connect(bend312.port_b, pipe92.port_a) annotation(
  749. Line(points = {{9, -106}, {18, -106}}, color = {0, 127, 255}));
  750. connect(pipe92.port_b, bend412.port_a) annotation(
  751. Line(points = {{38, -106}, {48, -106}}, color = {0, 127, 255}));
  752. connect(pipe521.port_b, bend4121.port_a) annotation(
  753. Line(points = {{98, -107}, {112, -107}, {112, -108}}, color = {0, 127, 255}));
  754. connect(bend4121.port_b, pipe621.port_a) annotation(
  755. Line(points = {{132, -108}, {144, -108}, {144, -110}}, color = {0, 127, 255}));
  756. connect(pipe621.port_b, input_valve) annotation(
  757. Line(points = {{164, -110}, {210, -110}, {210, -112}}, color = {0, 127, 255}));
  758. connect(pipe91.port_b, bend411.port_a) annotation(
  759. Line(points = {{80, 150}, {100, 150}, {100, 144}}, color = {0, 127, 255}));
  760. connect(pipe32.port_a, bend23.port_b) annotation(
  761. Line(points = {{-46, 88}, {-43, 88}, {-43, 91}, {-40, 91}}, color = {0, 127, 255}));
  762. connect(pipe13.port_b, bend7.port_a) annotation(
  763. Line(points = {{100, 96}, {100, 88}, {96, 88}}, color = {0, 127, 255}));
  764. connect(bend412.port_b, pipe521.port_a) annotation(
  765. Line(points = {{68, -106}, {73, -106}, {73, -107}, {78, -107}}, color = {0, 127, 255}));
  766. annotation(
  767. Diagram(coordinateSystem(extent = {{-420, 220}, {260, -240}})));
  768. end TestSetupNetwork;
  769. end PipeNetworks;
  770. package BaseComponents
  771. extends Modelica.Icons.Package;
  772. partial model FluidBase
  773. extends Components.BaseComponents.MediumBase;
  774. outer Modelica.Fluid.System system;
  775. // Define flow values -- will be constant
  776. constant Medium.AbsolutePressure start_pressure_pipe = 1 "Start value of pressure at a port";
  777. Modelica.Fluid.Interfaces.FluidPort_a port_a(redeclare package Medium = Medium) annotation(
  778. Placement(transformation(origin = {-100, 0}, extent = {{-11, -11}, {11, 11}}), iconTransformation(origin = {-100, 0}, extent = {{-9, -9}, {9, 9}})));
  779. Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Medium) annotation(
  780. Placement(transformation(origin = {100, 0}, extent = {{-11, -11}, {11, 11}}), iconTransformation(origin = {100, 0}, extent = {{-9, -9}, {9, 9}})));
  781. end FluidBase;
  782. package TwoWayEqualPercentageBase
  783. partial model PartialTwoWayValve "Partial model for a two way valve"
  784. extends Buildings.Fluid.BaseClasses.PartialResistance(final dp_nominal = dpValve_nominal + dpFixed_nominal, dp(nominal = 6000), final m_flow_turbulent = deltaM*abs(m_flow_nominal));
  785. extends Buildings.Fluid.Actuators.BaseClasses.ValveParameters(rhoStd = Medium.density_pTX(101325, 273.15 + 4, Medium.X_default));
  786. parameter Modelica.Units.SI.PressureDifference dpFixed_nominal(displayUnit = "Pa", min = 0) = 0 "Pressure drop of pipe and other resistances that are in series" annotation(
  787. Dialog(group = "Nominal condition"));
  788. parameter Real l(min = 1e-10, max = 1) = 0.0001 "Valve leakage, l=Kv(y=0)/Kv(y=1)";
  789. input Real phi "Ratio actual to nominal mass flow rate of valve, phi=Kv(y)/Kv(y=1)";
  790. parameter Real kFixed(unit = "", min = 0) = if dpFixed_nominal > Modelica.Constants.eps then m_flow_nominal/sqrt(dpFixed_nominal) else 0 "Flow coefficient of fixed resistance that may be in series with valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).";
  791. Real kVal(unit = "", min = Modelica.Constants.small) "Flow coefficient of valve, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).";
  792. Real k(unit = "", min = Modelica.Constants.small) "Flow coefficient of valve and pipe in series, k=m_flow/sqrt(dp), with unit=(kg.m)^(1/2).";
  793. initial equation
  794. assert(dpFixed_nominal > -Modelica.Constants.eps, "In " + getInstanceName() + ": Model requires dpFixed_nominal >= 0 but received dpFixed_nominal = " + String(dpFixed_nominal) + " Pa.");
  795. annotation();
  796. end PartialTwoWayValve;
  797. partial model PartialTwoWayValveKv "Partial model for a two way valve using a Kv characteristic"
  798. extends Components.BaseComponents.TwoWayEqualPercentageBase.PartialTwoWayValve;
  799. equation
  800. kVal = phi*Kv_SI;
  801. if (dpFixed_nominal > Modelica.Constants.eps) then
  802. k = sqrt(1/(1/kFixed^2 + 1/kVal^2));
  803. else
  804. k = kVal;
  805. end if;
  806. if linearized then
  807. // This implementation yields m_flow_nominal = phi*kv_SI * sqrt(dp_nominal)
  808. // if m_flow = m_flow_nominal and dp = dp_nominal
  809. m_flow*m_flow_nominal_pos = k^2*dp;
  810. else
  811. if homotopyInitialization then
  812. if from_dp then
  813. m_flow = homotopy(actual = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp = dp, k = k, m_flow_turbulent = m_flow_turbulent), simplified = m_flow_nominal_pos*dp/dp_nominal_pos);
  814. else
  815. dp = homotopy(actual = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow = m_flow, k = k, m_flow_turbulent = m_flow_turbulent), simplified = dp_nominal_pos*m_flow/m_flow_nominal_pos);
  816. end if;
  817. else
  818. // do not use homotopy
  819. if from_dp then
  820. m_flow = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_dp(dp = dp, k = k, m_flow_turbulent = m_flow_turbulent);
  821. else
  822. dp = Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow(m_flow = m_flow, k = k, m_flow_turbulent = m_flow_turbulent);
  823. end if;
  824. end if;
  825. // homotopyInitialization
  826. end if;
  827. // linearized
  828. annotation(
  829. Documentation(info = "<html>
  830. <p>
  831. Partial model for valves with different opening characteristics,
  832. such as linear, equal percentage or quick opening. This partial extends from
  833. <a href=\"modelica://Buildings.Fluid.Actuators.BaseClasses.PartialTwoWayValve\">
  834. Buildings.Fluid.Actuators.BaseClasses.PartialTwoWayValve</a>
  835. and also contains the governing equations for these three two way valve models.
  836. </p>
  837. <h4>Implementation</h4>
  838. <p>
  839. Models that extend this model need to provide a binding equation
  840. for the flow function <code>phi</code>.
  841. An example of such a code can be found in
  842. <a href=\"modelica://Buildings.Fluid.Actuators.Valves.TwoWayLinear\">
  843. Buildings.Fluid.Actuators.Valves.TwoWayLinear</a>.
  844. </p>
  845. </html>", revisions = "<html>
  846. <ul>
  847. <li>
  848. October 25, 2019, by Jianjun Hu:<br/>
  849. Removed icon graphics annotation. This is for
  850. <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1225\">#1225</a>.
  851. </li>
  852. <li>
  853. March 24, 2017, by Michael Wetter:<br/>
  854. Renamed <code>filteredInput</code> to <code>use_inputFilter</code>.<br/>
  855. This is for
  856. <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/665\">#665</a>.
  857. </li>
  858. <li>
  859. January 29, 2015 by Filip Jorissen:<br/>
  860. First implementation.
  861. </li>
  862. </ul>
  863. </html>"));
  864. end PartialTwoWayValveKv;
  865. model TwoWayEqualPercentage "Two way valve with equal percentage flow characteristics"
  866. extends Components.BaseComponents.TwoWayEqualPercentageBase.PartialTwoWayValveKv(phi = max(0.1*l, if homotopyInitialization then homotopy(actual = Buildings.Fluid.Actuators.BaseClasses.equalPercentage(opening, R, l, delta0), simplified = l + opening*(1 - l)) else Buildings.Fluid.Actuators.BaseClasses.equalPercentage(opening, R, l, delta0)));
  867. parameter Real R = 50 "Rangeability, R=50...100 typically";
  868. parameter Real delta0 = 0.01 "Range of significant deviation from equal percentage law";
  869. Modelica.Blocks.Interfaces.RealInput opening annotation(
  870. Placement(transformation(origin = {0, 100}, extent = {{-20, -20}, {20, 20}}, rotation = -90), iconTransformation(origin = {0, 42}, extent = {{-20, -20}, {20, 20}}, rotation = -90)));
  871. initial equation
  872. // Since the flow model Buildings.Fluid.BaseClasses.FlowModels.basicFlowFunction_m_flow computes
  873. // 1/k^2, the parameter l must not be zero.
  874. assert(l > 0, "Valve leakage parameter l must be bigger than zero.");
  875. assert(l < 1/R, "Wrong parameters in valve model.\n" + " Rangeability R = " + String(R) + "\n" + " Leakage flow l = " + String(l) + "\n" + " Must have l < 1/R = " + String(1/R));
  876. annotation(
  877. Diagram(graphics),
  878. Icon(graphics = {Polygon(origin = {-50, 0}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, lineThickness = 0.5, points = {{50, 0}, {-50, 60}, {-50, -60}, {50, 0}, {50, 0}}), Polygon(origin = {50, 0}, rotation = 180, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, lineThickness = 0.5, points = {{50, 0}, {-50, 60}, {-50, -60}, {50, 0}, {50, 0}}), Polygon(origin = {0, 11}, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, points = {{-36, 11}, {36, 11}, {0, -11}, {0, -11}, {-36, 11}}), Polygon(origin = {0, -11}, rotation = 180, fillColor = {255, 255, 255}, fillPattern = FillPattern.Solid, points = {{-40, 13}, {40, 13}, {0, -11}, {0, -11}, {-40, 13}})}));
  879. end TwoWayEqualPercentage;
  880. end TwoWayEqualPercentageBase;
  881. partial model FlowModelBase
  882. inner Components.Configurations.Configuration config(max_motor_position = 100, start_motor_position = 50) annotation(
  883. Placement(transformation(origin = {-90, 89}, extent = {{-10, -10}, {10, 10}})));
  884. inner Modelica.Fluid.System system(m_flow_start = system.m_flow_small) annotation(
  885. Placement(transformation(origin = {-50, 90}, extent = {{-10, -10}, {10, 10}})));
  886. Modelica.Blocks.Interfaces.RealInput motor_setpoint annotation(
  887. Placement(transformation(origin = {-100, -1}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {-281, 140}, extent = {{-19, -19}, {19, 19}})));
  888. Modelica.Blocks.Interfaces.RealOutput current_motor_pos annotation(
  889. Placement(transformation(origin = {110, 16}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {130, 160}, extent = {{-10, -10}, {10, 10}})));
  890. Modelica.Blocks.Interfaces.RealOutput current_flow annotation(
  891. Placement(transformation(origin = {110, -8}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {130, 120}, extent = {{-10, -10}, {10, 10}})));
  892. annotation(
  893. Diagram(graphics),
  894. Icon(graphics = {Rectangle(origin = {22, 52}, fillColor = {0, 127, 255}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-122, 20}, {122, -20}}), Ellipse(origin = {22, 52}, fillColor = {0, 100, 199}, fillPattern = FillPattern.Sphere, extent = {{-58, 58}, {58, -58}}), Rectangle(origin = {-199, 52}, lineColor = {99, 69, 44}, fillColor = {255, 190, 111}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-101, 20}, {101, -20}}), Ellipse(origin = {-148, 54}, fillPattern = FillPattern.Solid, extent = {{-30, 30}, {30, -30}}), Rectangle(origin = {-238, 52}, fillColor = {28, 113, 216}, fillPattern = FillPattern.Solid, lineThickness = 0.5, extent = {{-40, 40}, {40, -40}}, radius = 5), Line(origin = {-253, 116}, points = {{-13, 24}, {13, 24}, {13, -24}, {13, -24}}, thickness = 0.5), Line(origin = {-14, 86}, points = {{-134, -34}, {-134, 34}, {134, 34}, {134, 34}}, thickness = 0.5), Line(origin = {-50, 126}, points = {{-170, -34}, {-170, 34}, {170, 34}, {170, 34}}, thickness = 0.5)}, coordinateSystem(extent = {{-300, 180}, {140, -20}})),
  895. Documentation(info = "<html>
  896. <p>When creating a new flow model, it is recommended to extend it from FlowModel-
  897. Base. This base model automatically provides all required inputs, outputs, and the
  898. configuration model with the correct predefined names.</p>
  899. <p>
  900. A flow model contains one input and two outputs:
  901. <ul>
  902. <li>input: motor_setpoint</li>
  903. <li>output: current_motor_pos</li>
  904. <li>output: current_flow</li>
  905. </ul>
  906. </p>
  907. </html>"));
  908. end FlowModelBase;
  909. partial model DynamxBase
  910. extends Components.BaseComponents.FluidBase;
  911. outer Components.Configurations.Configuration config;
  912. Modelica.Blocks.Interfaces.RealInput setpoint_motor annotation(
  913. Placement(transformation(origin = {0, 100}, extent = {{-21, -21}, {21, 21}}, rotation = -90), iconTransformation(origin = {-40, 76}, extent = {{-19, -19}, {19, 19}}, rotation = -90)));
  914. Modelica.Blocks.Interfaces.RealOutput motor_position annotation(
  915. Placement(transformation(origin = {-29, -92}, extent = {{-11, -11}, {11, 11}}, rotation = -90), iconTransformation(origin = {-40, -77}, extent = {{-18, -18}, {18, 18}}, rotation = -90)));
  916. Modelica.Blocks.Interfaces.RealOutput flow_rate annotation(
  917. Placement(transformation(origin = {30, -90}, extent = {{-10, -10}, {10, 10}}, rotation = -90), iconTransformation(origin = {82, 80}, extent = {{-18, -18}, {18, 18}})));
  918. Modelica.Fluid.Interfaces.FluidPort_a port_a(redeclare package Medium = Medium) annotation(
  919. Placement(transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}})));
  920. Modelica.Fluid.Interfaces.FluidPort_b port_b(redeclare package Medium = Medium) annotation(
  921. Placement(transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {100, -2}, extent = {{-10, -10}, {10, 10}})));
  922. Sensors.FlowSensor flowSensor annotation(
  923. Placement(transformation(origin = {30, 0}, extent = {{-10, 10}, {10, -10}}, rotation = -0)));
  924. equation
  925. connect(flowSensor.port_b, port_b) annotation(
  926. Line(points = {{40, 0}, {100, 0}}, color = {0, 127, 255}));
  927. connect(flowSensor.flow_rate, flow_rate) annotation(
  928. Line(points = {{30, -10}, {30, -90}}, color = {0, 0, 127}));
  929. annotation(
  930. Icon(graphics = {Rectangle(origin = {-1, 0}, lineColor = {99, 69, 44}, fillColor = {255, 190, 111}, fillPattern = FillPattern.HorizontalCylinder, extent = {{-101, 20}, {101, -20}}), Ellipse(origin = {50, 2}, fillPattern = FillPattern.Solid, extent = {{-30, 30}, {30, -30}}), Line(origin = {50, 40}, points = {{0, 40}, {0, -40}, {0, -40}, {0, -40}}, thickness = 0.5), Line(origin = {90, 80}, rotation = -90, points = {{0, -14}, {0, -40}, {0, -40}, {0, -40}}, thickness = 0.5), Line(origin = {-40, 0}, points = {{0, 58}, {0, -40}, {0, -40}, {0, -60}}, thickness = 0.5), Rectangle(origin = {-40, 0}, fillColor = {28, 113, 216}, fillPattern = FillPattern.Solid, lineThickness = 0.5, extent = {{-40, 40}, {40, -40}}, radius = 5), Polygon(origin = {40, -46}, lineColor = {53, 132, 228}, fillColor = {53, 132, 228}, fillPattern = FillPattern.Solid, points = {{20, 0}, {-20, 10}, {-20, -10}, {-20, -10}, {20, 0}}), Line(origin = {-20, -46}, points = {{40, 0}, {-40, 0}, {-40, 0}}, color = {53, 132, 228}, thickness = 0.75), Text(origin = {-118, 194}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name")}),
  931. Diagram(graphics),
  932. Documentation(info = "<html>
  933. A Dynamx model combines the functionalities of the actuator, valve, and flowsensor into one component.
  934. <p>
  935. A Dynamx model contains one input and two outputs:
  936. <ul>
  937. <li>input: motor_setpoint</li>
  938. <li>output: current_motor_pos</li>
  939. <li>output: current_flow</li>
  940. </ul>
  941. </p>
  942. </html>"));
  943. end DynamxBase;
  944. partial model PipeNetworksBase
  945. extends Components.BaseComponents.MediumBase;
  946. Modelica.Fluid.Interfaces.FluidPort_a input_pump(redeclare package Medium = Medium) annotation(
  947. Placement(transformation(origin = {210, 148}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {100, 70}, extent = {{-10, -10}, {10, 10}})));
  948. Modelica.Fluid.Interfaces.FluidPort_a input_valve(redeclare package Medium = Medium) annotation(
  949. Placement(transformation(origin = {210, -112}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {100, -70}, extent = {{-10, -10}, {10, 10}})));
  950. Modelica.Fluid.Interfaces.FluidPort_b output_pump(redeclare package Medium = Medium) annotation(
  951. Placement(transformation(origin = {-210, 150}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-100, 70}, extent = {{-10, -10}, {10, 10}})));
  952. Modelica.Fluid.Interfaces.FluidPort_b output_valve(redeclare package Medium = Medium) annotation(
  953. Placement(transformation(origin = {-210, -112}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-100, -70}, extent = {{-10, -10}, {10, 10}})));
  954. annotation(
  955. Diagram(coordinateSystem(extent = {{-220, 160}, {220, -120}}), graphics),
  956. Icon(graphics = {Line(origin = {1.17, -1.17}, points = {{-101.174, 71.1738}, {-43.1738, 71.1738}, {-21.1738, 41.1738}, {-21.1738, 1.17382}, {-49.1738, -24.8262}, {-49.1738, -38.8262}, {18.8262, -38.8262}, {46.8262, -12.8262}, {70.8262, -12.8262}, {100.826, -70.8262}, {100.826, -70.8262}}, color = {26, 95, 180}, thickness = 1.5), Line(origin = {0, -1}, points = {{-100, -71}, {-48, -71}, {-48, -59}, {-80, -13}, {-80, 11}, {60, 11}, {60, 21}, {40, 41}, {10, 41}, {10, 71}, {100, 71}, {100, 71}}, color = {26, 95, 180}, thickness = 1.5), Text(origin = {-2, 22}, textColor = {0, 0, 255}, extent = {{-149, -114}, {151, -154}}, textString = "%name")}),
  957. Documentation(info = "<html>
  958. A pipe network is a model that encapsulates the whole network of pipes and bends.
  959. <p>
  960. A pipe network model contains two inputs and two outputs:
  961. <ul>
  962. <li>input: input_pump</li>
  963. <li>input: input_valve</li>
  964. <li>output: output_pump</li>
  965. <li>output: output_valve</li>
  966. </ul>
  967. </p>
  968. <p>
  969. These connections are defined such that input pump links to port a of the pump and
  970. output pump to port b of the pump, with analogous connections for the valve. This
  971. design ensures that the overall flow model consists of only three main components: a pipe network, a pressure pump, and a Dynamx component.
  972. </p>
  973. </html>"));
  974. end PipeNetworksBase;
  975. model MediumBase
  976. // Define the medium
  977. replaceable package Medium = Buildings.Media.Water annotation(
  978. choicesAllMatching = true);
  979. equation
  980. end MediumBase;
  981. end BaseComponents;
  982. package Examples "Library of examples to demonstrate the usage of package Components"
  983. extends Modelica.Icons.ExamplesPackage;
  984. model FlowModelLinear
  985. extends BaseComponents.FlowModelBase;
  986. Pumps.PressurePump pressurePump annotation(
  987. Placement(transformation(origin = {-16, 48}, extent = {{10, -10}, {-10, 10}}, rotation = -0)));
  988. Dynamx.LinearDefaultActuator linearDefaultActuator annotation(
  989. Placement(transformation(origin = {34, -16}, extent = {{-10, -10}, {10, 10}})));
  990. PipeNetworks.SimpleNetwork simpleNetwork annotation(
  991. Placement(transformation(origin = {-16, 18}, extent = {{-10, -10}, {10, 10}})));
  992. equation
  993. connect(linearDefaultActuator.flow_rate, current_flow) annotation(
  994. Line(points = {{42, -8}, {110, -8}}, color = {0, 0, 127}));
  995. connect(motor_setpoint, linearDefaultActuator.setpoint_motor) annotation(
  996. Line(points = {{-100, 0}, {30, 0}, {30, -8}}, color = {0, 0, 127}));
  997. connect(linearDefaultActuator.motor_position, current_motor_pos) annotation(
  998. Line(points = {{30, -24}, {30, -30}, {64, -30}, {64, 16}, {110, 16}}, color = {0, 0, 127}));
  999. connect(simpleNetwork.input_pump, pressurePump.port_a) annotation(
  1000. Line(points = {{-6, 26}, {26, 26}, {26, 48}, {-6, 48}}, color = {0, 127, 255}));
  1001. connect(simpleNetwork.output_pump, pressurePump.port_b) annotation(
  1002. Line(points = {{-26, 26}, {-56, 26}, {-56, 48}, {-26, 48}}, color = {0, 127, 255}));
  1003. connect(simpleNetwork.input_valve, linearDefaultActuator.port_a) annotation(
  1004. Line(points = {{-6, 12}, {2, 12}, {2, -16}, {24, -16}}, color = {0, 127, 255}));
  1005. connect(linearDefaultActuator.port_b, simpleNetwork.output_valve) annotation(
  1006. Line(points = {{44, -16}, {52, -16}, {52, -34}, {-56, -34}, {-56, 12}, {-26, 12}}, color = {0, 127, 255}));
  1007. annotation(
  1008. uses(Modelica(version = "4.0.0")),
  1009. Diagram(coordinateSystem(extent = {{-120, 100}, {120, -60}})),
  1010. version = "");
  1011. end FlowModelLinear;
  1012. model FlowModelEqualPer
  1013. extends BaseComponents.FlowModelBase(system(allowFlowReversal = true));
  1014. Pumps.PressurePump pressurePump annotation(
  1015. Placement(transformation(origin = {-10, 42}, extent = {{10, -10}, {-10, 10}}, rotation = -0)));
  1016. Dynamx.EqualPercentageDefaultActuator equalPercentageDefaultActuator annotation(
  1017. Placement(transformation(origin = {44, -16}, extent = {{-10, -10}, {10, 10}})));
  1018. PipeNetworks.SimpleNetwork simpleNetwork annotation(
  1019. Placement(transformation(origin = {-10, 14}, extent = {{-10, -10}, {10, 10}})));
  1020. equation
  1021. connect(equalPercentageDefaultActuator.flow_rate, current_flow) annotation(
  1022. Line(points = {{52, -8}, {110, -8}}, color = {0, 0, 127}));
  1023. connect(motor_setpoint, equalPercentageDefaultActuator.setpoint_motor) annotation(
  1024. Line(points = {{-100, 0}, {40, 0}, {40, -8}}, color = {0, 0, 127}));
  1025. connect(equalPercentageDefaultActuator.motor_position, current_motor_pos) annotation(
  1026. Line(points = {{40, -24}, {40, -26}, {68, -26}, {68, 16}, {110, 16}}, color = {0, 0, 127}));
  1027. connect(pressurePump.port_a, simpleNetwork.input_pump) annotation(
  1028. Line(points = {{0, 42}, {22, 42}, {22, 22}, {0, 22}}, color = {0, 127, 255}));
  1029. connect(pressurePump.port_b, simpleNetwork.output_pump) annotation(
  1030. Line(points = {{-20, 42}, {-50, 42}, {-50, 22}, {-20, 22}}, color = {0, 127, 255}));
  1031. connect(simpleNetwork.input_valve, equalPercentageDefaultActuator.port_a) annotation(
  1032. Line(points = {{0, 8}, {14, 8}, {14, -16}, {34, -16}}, color = {0, 127, 255}));
  1033. connect(equalPercentageDefaultActuator.port_b, simpleNetwork.output_valve) annotation(
  1034. Line(points = {{54, -16}, {62, -16}, {62, -32}, {-50, -32}, {-50, 8}, {-20, 8}}, color = {0, 127, 255}));
  1035. annotation(
  1036. uses(Modelica(version = "4.0.0")),
  1037. Diagram(coordinateSystem(extent = {{-120, 100}, {120, -60}})),
  1038. version = "");
  1039. end FlowModelEqualPer;
  1040. end Examples;
  1041. annotation(
  1042. uses(Modelica(version = "4.0.0"), Buildings(version = "12.0.0")));
  1043. end Components;