fastsmoothbuildings 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. fastsmoothbuildings/__init__.py +16 -0
  2. fastsmoothbuildings/_paths.py +32 -0
  3. fastsmoothbuildings/bundle.py +150 -0
  4. fastsmoothbuildings/modelica/FastSmoothBuildings/BoundaryConditions/TiltedSurface.mo +29 -0
  5. fastsmoothbuildings/modelica/FastSmoothBuildings/BoundaryConditions/Weather.mo +99 -0
  6. fastsmoothbuildings/modelica/FastSmoothBuildings/BoundaryConditions/package.mo +8 -0
  7. fastsmoothbuildings/modelica/FastSmoothBuildings/BoundaryConditions/package.order +2 -0
  8. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/BoilerDemand.mo +19 -0
  9. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/BoilerTemperatureControl.mo +21 -0
  10. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/CollectorControl.mo +26 -0
  11. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/EmissionMonitored.mo +20 -0
  12. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/EmissionOnOff.mo +10 -0
  13. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/EmissionP.mo +8 -0
  14. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/EmissionPI.mo +11 -0
  15. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/HeatPumpControl.mo +45 -0
  16. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/Hysteresis.mo +35 -0
  17. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/PI.mo +39 -0
  18. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/PartialEmissionControl.mo +22 -0
  19. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/ThreeWayValveControl.mo +22 -0
  20. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/Validation/Hysteresis.mo +15 -0
  21. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/Validation/PIControl.mo +18 -0
  22. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/Validation/package.mo +10 -0
  23. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/Validation/package.order +2 -0
  24. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/package.mo +13 -0
  25. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/package.order +14 -0
  26. fastsmoothbuildings/modelica/FastSmoothBuildings/Controls/smoothMaxN.mo +11 -0
  27. fastsmoothbuildings/modelica/FastSmoothBuildings/Data/Construction.mo +23 -0
  28. fastsmoothbuildings/modelica/FastSmoothBuildings/Data/Glazing.mo +23 -0
  29. fastsmoothbuildings/modelica/FastSmoothBuildings/Data/package.mo +8 -0
  30. fastsmoothbuildings/modelica/FastSmoothBuildings/Data/package.order +2 -0
  31. fastsmoothbuildings/modelica/FastSmoothBuildings/Electrical/Photovoltaic.mo +40 -0
  32. fastsmoothbuildings/modelica/FastSmoothBuildings/Electrical/package.mo +8 -0
  33. fastsmoothbuildings/modelica/FastSmoothBuildings/Electrical/package.order +1 -0
  34. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/AdiabaticWall.mo +26 -0
  35. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/BoundaryWall.mo +31 -0
  36. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/exteriorExchange.mo +29 -0
  37. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/gapConductance.mo +115 -0
  38. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/interiorConvection.mo +11 -0
  39. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/overhangSunlitFraction.mo +48 -0
  40. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/package.mo +8 -0
  41. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/package.order +6 -0
  42. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/sideFinsSunlitFraction.mo +45 -0
  43. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Functions/skyExchange.mo +18 -0
  44. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/InternalWall.mo +43 -0
  45. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/OuterWall.mo +38 -0
  46. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/PartialOpaque.mo +56 -0
  47. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/PartialSurface.mo +13 -0
  48. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Validation/GapConductance.mo +21 -0
  49. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Validation/ShadingFractions.mo +21 -0
  50. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Validation/package.mo +10 -0
  51. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Validation/package.order +2 -0
  52. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/Window.mo +129 -0
  53. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/package.mo +8 -0
  54. fastsmoothbuildings/modelica/FastSmoothBuildings/Envelope/package.order +9 -0
  55. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/BaseClasses/PartialHydronicRoom.mo +40 -0
  56. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/BaseClasses/SyntheticWeather.mo +40 -0
  57. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/BaseClasses/package.mo +9 -0
  58. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/BaseClasses/package.order +2 -0
  59. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/BoilerCircuit.mo +83 -0
  60. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/BoilerCircuitSetFlows.mo +14 -0
  61. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/CavityWall.mo +16 -0
  62. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/ConcreteSlab.mo +16 -0
  63. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/DoubleClear.mo +23 -0
  64. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/LightFloor.mo +16 -0
  65. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/LightRoof.mo +16 -0
  66. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/LightWall.mo +16 -0
  67. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/TripleArgon.mo +25 -0
  68. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/package.mo +11 -0
  69. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Constructions/package.order +7 -0
  70. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/FreeFloatingRoom.mo +88 -0
  71. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/HeatPumpCircuit.mo +114 -0
  72. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/IdealHeatingRoom.mo +20 -0
  73. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/Photovoltaics.mo +19 -0
  74. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/TwoZones.mo +86 -0
  75. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/VentilatedRoom.mo +61 -0
  76. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/package.mo +12 -0
  77. fastsmoothbuildings/modelica/FastSmoothBuildings/Examples/package.order +10 -0
  78. fastsmoothbuildings/modelica/FastSmoothBuildings/HVAC/IdealHeater.mo +31 -0
  79. fastsmoothbuildings/modelica/FastSmoothBuildings/HVAC/IdealHeatingCooling.mo +25 -0
  80. fastsmoothbuildings/modelica/FastSmoothBuildings/HVAC/IdealHeatingCoolingPI.mo +44 -0
  81. fastsmoothbuildings/modelica/FastSmoothBuildings/HVAC/package.mo +8 -0
  82. fastsmoothbuildings/modelica/FastSmoothBuildings/HVAC/package.order +3 -0
  83. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/Boiler.mo +58 -0
  84. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/HeatPump.mo +86 -0
  85. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/HeatPumps/Vitocal251A08/interpolate.mo +28 -0
  86. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/HeatPumps/Vitocal251A08/package.mo +20 -0
  87. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/HeatPumps/Vitocal251A08/package.order +7 -0
  88. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/HeatPumps/Vitocal251A08/smoothTable.mo +26 -0
  89. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/HeatPumps/package.mo +8 -0
  90. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/HeatPumps/package.order +1 -0
  91. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/Junction.mo +60 -0
  92. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/Junction2.mo +47 -0
  93. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/PartialConserving.mo +8 -0
  94. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/PartialFlow.mo +46 -0
  95. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/PartialLink.mo +17 -0
  96. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/Pipe.mo +12 -0
  97. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/Pump.mo +45 -0
  98. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/Radiator.mo +69 -0
  99. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/TemperatureSensor.mo +25 -0
  100. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/ThreeWayValve.mo +108 -0
  101. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/Valve.mo +43 -0
  102. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/package.mo +12 -0
  103. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/package.order +15 -0
  104. fastsmoothbuildings/modelica/FastSmoothBuildings/Hydronics/radiatorConductance.mo +56 -0
  105. fastsmoothbuildings/modelica/FastSmoothBuildings/Icons.mo +39 -0
  106. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/ControlInput.mo +7 -0
  107. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/ControlSignal.mo +7 -0
  108. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/GainInputs.mo +15 -0
  109. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/GainOutputs.mo +7 -0
  110. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/Gains.mo +15 -0
  111. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/HeatFlowInput.mo +7 -0
  112. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/HeatPort.mo +8 -0
  113. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/OccupancyInputs.mo +14 -0
  114. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/SurfaceBus.mo +25 -0
  115. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/WaterInlet.mo +9 -0
  116. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/WaterOutlet.mo +11 -0
  117. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/WeatherBus.mo +27 -0
  118. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/WeatherBusIn.mo +27 -0
  119. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/WeatherInputs.mo +20 -0
  120. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/ZoneSurfaceBus.mo +25 -0
  121. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/package.mo +16 -0
  122. fastsmoothbuildings/modelica/FastSmoothBuildings/Interfaces/package.order +17 -0
  123. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Controls.Validation.Hysteresis.csv +603 -0
  124. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Controls.Validation.PIControl.csv +903 -0
  125. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Envelope.Validation.GapConductance.csv +103 -0
  126. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Envelope.Validation.ShadingFractions.csv +103 -0
  127. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.BoilerCircuit.csv +291 -0
  128. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.BoilerCircuitSetFlows.csv +291 -0
  129. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.FreeFloatingRoom.csv +291 -0
  130. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.HeatPumpCircuit.csv +291 -0
  131. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.IdealHeatingRoom.csv +291 -0
  132. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.Photovoltaics.csv +291 -0
  133. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.TwoZones.csv +291 -0
  134. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Examples.VentilatedRoom.csv +291 -0
  135. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Utilities.Validation.Schedules.csv +579 -0
  136. fastsmoothbuildings/modelica/FastSmoothBuildings/Resources/ReferenceResults/OpenModelica/FastSmoothBuildings.Utilities.Validation.SmoothFunctions.csv +103 -0
  137. fastsmoothbuildings/modelica/FastSmoothBuildings/Types.mo +20 -0
  138. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/Contact.mo +10 -0
  139. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/Conventions.mo +51 -0
  140. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/License.mo +18 -0
  141. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/ReleaseNotes.mo +12 -0
  142. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/Smoothing.mo +35 -0
  143. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/Translation.mo +37 -0
  144. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/package.mo +32 -0
  145. fastsmoothbuildings/modelica/FastSmoothBuildings/UsersGuide/package.order +6 -0
  146. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/Validation/Schedules.mo +26 -0
  147. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/Validation/SmoothFunctions.mo +26 -0
  148. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/Validation/package.mo +10 -0
  149. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/Validation/package.order +2 -0
  150. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/convectionCoefficient.mo +15 -0
  151. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/dayTable.mo +20 -0
  152. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/equalPercentage.mo +29 -0
  153. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/naturalConvection.mo +12 -0
  154. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/occupancy.mo +14 -0
  155. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/package.mo +8 -0
  156. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/package.order +17 -0
  157. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/polynomial.mo +8 -0
  158. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/polynomialFit.mo +34 -0
  159. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/positivePart.mo +8 -0
  160. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/quadraticFlow.mo +11 -0
  161. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/regStep.mo +51 -0
  162. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/smoothLimit.mo +15 -0
  163. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/smoothLimitInside.mo +12 -0
  164. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/smoothMax.mo +9 -0
  165. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/smoothMin.mo +9 -0
  166. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/timeOfDay.mo +7 -0
  167. fastsmoothbuildings/modelica/FastSmoothBuildings/Utilities/valveConductance.mo +12 -0
  168. fastsmoothbuildings/modelica/FastSmoothBuildings/Ventilation/AirInlet.mo +9 -0
  169. fastsmoothbuildings/modelica/FastSmoothBuildings/Ventilation/AirOutlet.mo +11 -0
  170. fastsmoothbuildings/modelica/FastSmoothBuildings/Ventilation/Duct.mo +25 -0
  171. fastsmoothbuildings/modelica/FastSmoothBuildings/Ventilation/HeatRecoveryUnit.mo +48 -0
  172. fastsmoothbuildings/modelica/FastSmoothBuildings/Ventilation/package.mo +8 -0
  173. fastsmoothbuildings/modelica/FastSmoothBuildings/Ventilation/package.order +4 -0
  174. fastsmoothbuildings/modelica/FastSmoothBuildings/Zones/AirTemperatureSensor.mo +14 -0
  175. fastsmoothbuildings/modelica/FastSmoothBuildings/Zones/InternalGains.mo +16 -0
  176. fastsmoothbuildings/modelica/FastSmoothBuildings/Zones/PartialZone.mo +93 -0
  177. fastsmoothbuildings/modelica/FastSmoothBuildings/Zones/VentilatedZone.mo +17 -0
  178. fastsmoothbuildings/modelica/FastSmoothBuildings/Zones/Zone.mo +6 -0
  179. fastsmoothbuildings/modelica/FastSmoothBuildings/Zones/package.mo +8 -0
  180. fastsmoothbuildings/modelica/FastSmoothBuildings/Zones/package.order +5 -0
  181. fastsmoothbuildings/modelica/FastSmoothBuildings/package.mo +30 -0
  182. fastsmoothbuildings/modelica/FastSmoothBuildings/package.order +22 -0
  183. fastsmoothbuildings/py.typed +0 -0
  184. fastsmoothbuildings-0.1.0.dist-info/METADATA +141 -0
  185. fastsmoothbuildings-0.1.0.dist-info/RECORD +187 -0
  186. fastsmoothbuildings-0.1.0.dist-info/WHEEL +4 -0
  187. fastsmoothbuildings-0.1.0.dist-info/licenses/LICENSE +88 -0
@@ -0,0 +1,16 @@
1
+ """FastSmoothBuildings: the Modelica library, and where tools find it.
2
+
3
+ ``LIBRARY`` is the folder of the library, to pass to rumoca (``rumoca.Session(roots=[str(LIBRARY)])``: rumoca reads
4
+ every Modelica file below a root); ``ROOT`` the folder that holds it, to put on ``MODELICAPATH``; ``bundle()`` the
5
+ library as the text of one file, to embed it in a generated model.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Final
11
+
12
+ from fastsmoothbuildings._paths import LIBRARY, NAME, ROOT, modelica_version
13
+ from fastsmoothbuildings.bundle import bundle, strip_documentation
14
+
15
+ __version__: Final = modelica_version(LIBRARY / "package.mo")
16
+ __all__ = ["LIBRARY", "NAME", "ROOT", "__version__", "bundle", "strip_documentation"]
@@ -0,0 +1,32 @@
1
+ """Where the Modelica library is: inside the installed package, or at the root of a checkout (editable install)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from pathlib import Path
7
+ from typing import Final
8
+
9
+ NAME: Final = "FastSmoothBuildings"
10
+ VERSION = re.compile(r'^\s*version\s*=\s*"(?P<version>[^"]+)"', re.MULTILINE)
11
+
12
+
13
+ def _root() -> Path:
14
+ package = Path(__file__).resolve().parent
15
+ for root in (package / "modelica", package.parents[1]):
16
+ if (root / NAME / "package.mo").is_file():
17
+ return root
18
+ message = f"the Modelica library {NAME} is neither in {package / 'modelica'} nor at the root of a checkout"
19
+ raise FileNotFoundError(message)
20
+
21
+
22
+ def modelica_version(package: Path) -> str:
23
+ """The ``version`` annotation of the ``package.mo`` of a library."""
24
+ match = VERSION.search(package.read_text(encoding="utf-8"))
25
+ if match is None:
26
+ message = f"{package} has no version annotation"
27
+ raise ValueError(message)
28
+ return match["version"]
29
+
30
+
31
+ ROOT: Final = _root()
32
+ LIBRARY: Final = ROOT / NAME
@@ -0,0 +1,150 @@
1
+ """Single-file text of a Modelica library stored in the directory layout of the Modelica specification (13.4)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from collections.abc import Sequence
7
+ from pathlib import Path
8
+
9
+ from fastsmoothbuildings._paths import LIBRARY
10
+
11
+ INDENT = " "
12
+ WITHIN = re.compile(r"\A\s*within\b[^;]*;[ \t]*\n")
13
+ DOCUMENTATION = re.compile(r"\bDocumentation\s*\(")
14
+ CLASS_ANNOTATION = re.compile(rf"^{INDENT}annotation\b")
15
+
16
+
17
+ def read_class(path: Path) -> list[str]:
18
+ """Lines of a class file without its ``within`` clause."""
19
+ return WITHIN.sub("", path.read_text(encoding="utf-8"), count=1).rstrip("\n").split("\n")
20
+
21
+
22
+ def package_order(package: Path) -> list[str]:
23
+ """Names listed in ``package.order``, in their order."""
24
+ order = package / "package.order"
25
+ return order.read_text(encoding="utf-8").split() if order.is_file() else []
26
+
27
+
28
+ def _scan(line: str, in_string: bool, in_comment: bool) -> tuple[bool, bool]:
29
+ """Whether the end of ``line`` is inside a string and inside a block comment."""
30
+ index = 0
31
+ while index < len(line):
32
+ if in_string:
33
+ if line[index] == "\\":
34
+ index += 2
35
+ continue
36
+ in_string = line[index] != '"'
37
+ elif in_comment:
38
+ in_comment = not line.startswith("*/", index)
39
+ index += 0 if in_comment else 1
40
+ elif line.startswith("//", index):
41
+ break
42
+ else:
43
+ in_string = line[index] == '"'
44
+ in_comment = line.startswith("/*", index)
45
+ index += 1 if in_comment else 0
46
+ index += 1
47
+ return in_string, in_comment
48
+
49
+
50
+ def code_starts(lines: Sequence[str]) -> list[bool]:
51
+ """Whether each line starts outside a string and outside a block comment."""
52
+ starts: list[bool] = []
53
+ in_string = in_comment = False
54
+ for line in lines:
55
+ starts.append(not (in_string or in_comment))
56
+ in_string, in_comment = _scan(line, in_string, in_comment)
57
+ return starts
58
+
59
+
60
+ def code_mask(text: str) -> list[bool]:
61
+ """Whether each character of ``text`` is code: outside strings and comments."""
62
+ mask = [True] * len(text)
63
+ index, in_string = 0, False
64
+ while index < len(text):
65
+ if in_string:
66
+ mask[index] = False
67
+ if text[index] == "\\":
68
+ mask[index + 1 : index + 2] = [False] * len(mask[index + 1 : index + 2])
69
+ index += 2
70
+ continue
71
+ in_string = text[index] != '"'
72
+ elif text[index] == '"':
73
+ mask[index], in_string = False, True
74
+ elif text.startswith("//", index) or text.startswith("/*", index):
75
+ end = text.find("\n" if text[index + 1] == "/" else "*/", index + 2)
76
+ end = len(text) if end < 0 else end + (0 if text[index + 1] == "/" else 2)
77
+ mask[index:end] = [False] * (end - index)
78
+ index = end
79
+ continue
80
+ index += 1
81
+ return mask
82
+
83
+
84
+ def _class_annotation(body: Sequence[str]) -> int:
85
+ """Index of the line that opens the annotation of the class in ``body`` (its declaration and elements),
86
+ ``len(body)`` without one: the classes stored in files go before it, an annotation ends a class."""
87
+ starts = code_starts(body)
88
+ found = [number for number, line in enumerate(body) if starts[number] and CLASS_ANNOTATION.match(line)]
89
+ return found[-1] if found else len(body)
90
+
91
+
92
+ def _indented(lines: Sequence[str], depth: int) -> list[str]:
93
+ return [INDENT * depth + line if line else line for line in lines]
94
+
95
+
96
+ def _package_lines(package: Path, depth: int) -> list[str]:
97
+ *body, end = read_class(package / "package.mo")
98
+ annotation = _class_annotation(body)
99
+ lines = _indented(body[:annotation], depth)
100
+ # a blank line separates the classes, except the first one from a declaration without elements
101
+ separator = [""] if any(line.rstrip().endswith(";") for line in body[:annotation]) else []
102
+ for name in package_order(package):
103
+ if (package / name / "package.mo").is_file():
104
+ child = _package_lines(package / name, depth + 1)
105
+ elif (package / f"{name}.mo").is_file():
106
+ child = _indented(read_class(package / f"{name}.mo"), depth + 1)
107
+ else:
108
+ continue # a constant or a short class of package.mo
109
+ lines += [*separator, *child]
110
+ separator = [""]
111
+ return [*lines, *_indented([*body[annotation:], end], depth)]
112
+
113
+
114
+ def bundle(library: Path | None = None, *, documentation: bool = True) -> str:
115
+ """The library at ``library`` (the folder holding its ``package.mo``, FastSmoothBuildings by default) as the
116
+ text of one file; ``documentation=False`` leaves out the ``Documentation`` annotations."""
117
+ text = "\n".join(_package_lines(library or LIBRARY, 0)) + "\n"
118
+ return text if documentation else strip_documentation(text)
119
+
120
+
121
+ def strip_documentation(text: str) -> str:
122
+ """``text`` without its ``Documentation(...)`` annotations (with the comma that joins one to the other
123
+ elements of its ``annotation``)."""
124
+ mask = code_mask(text)
125
+ pieces: list[str] = []
126
+ position = 0
127
+ for match in DOCUMENTATION.finditer(text):
128
+ if match.start() < position or not mask[match.start()]:
129
+ continue
130
+ start, end = match.start(), _closing_parenthesis(text, match.end(), mask)
131
+ before = text[position:start].rstrip()
132
+ after = text[end:].lstrip()
133
+ if before.endswith(","):
134
+ before = before[:-1]
135
+ elif after.startswith(","):
136
+ end = len(text) - len(after[1:].lstrip())
137
+ pieces.append(before)
138
+ position = end
139
+ pieces.append(text[position:])
140
+ return "".join(pieces)
141
+
142
+
143
+ def _closing_parenthesis(text: str, start: int, mask: Sequence[bool]) -> int:
144
+ """Index just after the parenthesis that closes the one opened before ``start``, strings skipped."""
145
+ depth, index = 1, start
146
+ while depth:
147
+ if mask[index]:
148
+ depth += {"(": 1, ")": -1}.get(text[index], 0)
149
+ index += 1
150
+ return index
@@ -0,0 +1,29 @@
1
+ within FastSmoothBuildings.BoundaryConditions;
2
+ model TiltedSurface "Solar irradiance on a tilted surface: direct, Perez diffuse (sky and ground), incidence"
3
+ parameter Real azi(unit="rad") "Surface azimuth: 0 south, pi/2 west";
4
+ parameter Real til(unit="rad") "Surface tilt: 0 roof, pi/2 wall";
5
+ parameter Real rho = 0.2 "Ground reflectance";
6
+ Interfaces.WeatherBusIn weaBus
7
+ annotation (Placement(transformation(extent={{-110,-10},{-90,10}})));
8
+ Real cosInc "Cosine of the incidence angle";
9
+ Real HDir(unit="W/m2") "Direct irradiance on the surface";
10
+ Real HDif(unit="W/m2") "Diffuse irradiance on the surface (sky and ground)";
11
+ protected
12
+ constant Real bMin = cos(85*pi/180);
13
+ equation
14
+ cosInc = cos(til)*(cos(weaBus.decAng)*cos(weaBus.solHouAng)*cos(weaBus.lat) + sin(weaBus.decAng)*sin(weaBus.lat))
15
+ + sin(til)*(sin(azi)*cos(weaBus.decAng)*sin(weaBus.solHouAng) + cos(azi)*(cos(weaBus.decAng)
16
+ *cos(weaBus.solHouAng)*sin(weaBus.lat) - sin(weaBus.decAng)*cos(weaBus.lat)));
17
+ HDir = Utilities.positivePart(cosInc*weaBus.HDirNor, 1e-2);
18
+ HDif = weaBus.HDifHor*(0.5*(1 - weaBus.F1)*(1 + cos(til)) + weaBus.F1*Utilities.smoothMax(0, cosInc, 0.01)
19
+ /Utilities.smoothMax(bMin, weaBus.cosZen, 0.01) + weaBus.F2*sin(til)) + weaBus.HGloHor*0.5*rho*(1 - cos(til));
20
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
21
+ Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={255,255,255},
22
+ fillPattern=FillPattern.Solid),
23
+ Ellipse(extent={{-80,80},{-20,20}}, lineColor={255,220,220}, fillColor={255,255,0},
24
+ fillPattern=FillPattern.Sphere),
25
+ Polygon(points={{-20,-80},{80,20},{80,-80},{-20,-80}}, lineColor={0,0,0}, fillColor={175,175,175},
26
+ fillPattern=FillPattern.Solid),
27
+ Line(points={{-30,30},{30,-30}}, color={255,128,0}, arrow={Arrow.None,Arrow.Filled}),
28
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
29
+ end TiltedSurface;
@@ -0,0 +1,99 @@
1
+ within FastSmoothBuildings.BoundaryConditions;
2
+ model Weather "Weather data, solar position and Perez coefficients for the site"
3
+ parameter Real lat(unit="rad") = 0.8868 "Latitude (Uccle by default)";
4
+ parameter Real lon(unit="rad") = 0.0760 "Longitude (Uccle by default)";
5
+ parameter Real timZon(unit="s") = 3600 "Time zone (offset of the standard time from UTC)";
6
+ parameter Real alt(unit="m") = 100 "Altitude of the site";
7
+ parameter Real pAtm(unit="Pa") = 101325
8
+ "Atmospheric pressure, constant (Buildings' default; the runnable model takes the pressure of the site's
9
+ altitude when the YAML reads the pressure from the weather file)";
10
+ Interfaces.RealInput TDryBul(unit="K") "Outdoor dry-bulb air temperature"
11
+ annotation (Placement(transformation(extent={{-120,60},{-100,80}})));
12
+ Interfaces.RealInput TBlaSky(unit="K") "Black-body sky temperature"
13
+ annotation (Placement(transformation(extent={{-120,40},{-100,60}})));
14
+ Interfaces.RealInput winSpe(unit="m/s") "Wind speed"
15
+ annotation (Placement(transformation(extent={{-120,20},{-100,40}})));
16
+ Interfaces.RealInput winDir(unit="rad") "Wind direction, 0 from the north"
17
+ annotation (Placement(transformation(extent={{-120,0},{-100,20}})));
18
+ Interfaces.RealInput HDirNor(unit="W/m2") "Direct normal irradiance"
19
+ annotation (Placement(transformation(extent={{-120,-20},{-100,0}})));
20
+ Interfaces.RealInput HDifHor(unit="W/m2") "Diffuse horizontal irradiance"
21
+ annotation (Placement(transformation(extent={{-120,-40},{-100,-20}})));
22
+ Interfaces.RealInput HGloHor(unit="W/m2") "Global horizontal irradiance"
23
+ annotation (Placement(transformation(extent={{-120,-60},{-100,-40}})));
24
+ Interfaces.WeatherBus weaBus "Weather data and solar position"
25
+ annotation (Placement(transformation(extent={{90,-10},{110,10}})));
26
+ protected
27
+ Real Bt "Intermediate variable of the equation of time";
28
+ Real eqnTim(unit="s") "Equation of time";
29
+ Real solTim(unit="s") "Solar time";
30
+ Real zen(unit="rad") "Solar zenith angle";
31
+ Real zenLim(unit="rad") "Zenith angle bounded by 90 degrees";
32
+ Real relAirMas "Relative air mass";
33
+ Real skyBri "Sky brightness";
34
+ Real HDifHorBou(unit="W/m2") "Diffuse horizontal irradiance bounded away from 0";
35
+ Real tmp "Intermediate variable of the sky clearness";
36
+ Real skyCle "Sky clearness";
37
+ Real a[8] "Weights of the sky clearness bins";
38
+ Real b[8] "Smooth steps of the sky clearness bins";
39
+ constant Real edges[7] = {1.065, 1.23, 1.50, 1.95, 2.80, 4.50, 6.20} "Sky clearness bin edges";
40
+ constant Real F11[8] = {-0.0083117, 0.1299457, 0.3296958, 0.5682053, 0.8730280, 1.1326077, 1.0601591, 0.6777470};
41
+ constant Real F12[8] = {0.5877285, 0.6825954, 0.4868735, 0.1874525, -0.3920403, -1.2367284, -1.5999137, -0.3272588};
42
+ constant Real F13[8] = {-0.0620636, -0.1513725, -0.2210958, -0.2951290, -0.3616149, -0.4118494, -0.3589221, -0.2504286};
43
+ constant Real F21[8] = {-0.0596012, -0.0189325, 0.0554140, 0.1088631, 0.2255647, 0.2877813, 0.2642124, 0.1561313};
44
+ constant Real F22[8] = {0.0721249, 0.0659650, -0.0639588, -0.1519229, -0.4620442, -0.8230357, -1.1272340, -1.3765031};
45
+ constant Real F23[8] = {-0.0220216, -0.0288748, -0.0260542, -0.0139754, 0.0012448, 0.0558651, 0.1310694, 0.2506212};
46
+ equation
47
+ // Weather data
48
+ weaBus.TDryBul = TDryBul;
49
+ weaBus.TBlaSky = TBlaSky;
50
+ weaBus.winSpe = winSpe;
51
+ weaBus.winDir = winDir;
52
+ weaBus.HDirNor = HDirNor;
53
+ weaBus.HDifHor = HDifHor;
54
+ weaBus.HGloHor = HGloHor;
55
+ weaBus.pAtm = pAtm;
56
+ weaBus.lat = lat;
57
+ // Solar position (Buildings.BoundaryConditions.SolarGeometry; the model time is the clock time of the year)
58
+ weaBus.decAng = asin(-sin(23.45*pi/180)*cos((time/86400 + 10)*2*pi/365.25));
59
+ Bt = pi*((time + 86400)/86400 - 81)/182;
60
+ eqnTim = 60*(9.87*sin(2*Bt) - 7.53*cos(Bt) - 1.5*sin(Bt));
61
+ solTim = time - timZon + lon*43200/pi + eqnTim;
62
+ weaBus.solHouAng = (solTim/3600 - 12)*2*pi/24;
63
+ weaBus.cosZen = cos(lat)*cos(weaBus.decAng)*cos(weaBus.solHouAng) + sin(lat)*sin(weaBus.decAng);
64
+ zen = acos(Utilities.smoothLimitInside(weaBus.cosZen, -1, 1, 1e-6));
65
+ // Perez sky model (Buildings.BoundaryConditions.SolarIrradiation.BaseClasses)
66
+ zenLim = Utilities.smoothMin(zen, pi/2, 0.01);
67
+ relAirMas = exp(-0.0001184*alt)/(cos(zenLim) + 0.15*(93.9 - zenLim*180/pi)^(-1.253));
68
+ skyBri = Utilities.smoothMin(HDifHor*relAirMas/(1366.1*(1 + 0.033*cos(2*pi*(solTim/86400 + 1)/365))), 1, 0.025);
69
+ HDifHorBou = Utilities.smoothMax(HDifHor, 0.5e-4, 0.25e-4);
70
+ tmp = 5.534e-6*(180/pi)^3*zen^3;
71
+ skyCle = Utilities.smoothLimitInside(((HDirNor + HDifHorBou)/HDifHorBou + tmp)/(1 + tmp), 1, 8, 0.01);
72
+ for i in 1:7 loop
73
+ b[i] = Utilities.regStep(edges[i] - skyCle, 1, 0, 0.01);
74
+ end for;
75
+ b[8] = Utilities.regStep(skyCle - edges[7], 1, 0, 0.01);
76
+ a[1] = b[1];
77
+ for i in 2:7 loop
78
+ a[i] = b[i] - b[i - 1];
79
+ end for;
80
+ a[8] = b[8];
81
+ weaBus.F1 = Utilities.smoothMax(0, sum(a[i]*(F11[i] + F12[i]*skyBri + F13[i]*zen) for i in 1:8), 0.01);
82
+ weaBus.F2 = sum(a[i]*(F21[i] + F22[i]*skyBri + F23[i]*zen) for i in 1:8);
83
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
84
+ Rectangle(extent={{-100,100},{100,-100}}, lineColor={124,142,255}, fillColor={124,142,255},
85
+ fillPattern=FillPattern.Solid),
86
+ Ellipse(extent={{-73,77},{14,-10}}, lineColor={255,220,220}, lineThickness=1,
87
+ fillPattern=FillPattern.Sphere, fillColor={255,255,0}),
88
+ Polygon(points={{47,53}, {39,21}, {55,26}, {69,25}, {82,19}, {91,-14}, {69,-51}, {5,-55}, {-70,-53},
89
+ {-83,-15}, {-75,12}, {-51,13}, {-39,4}, {-46,35}, {-29,60}, {17,70}, {47,53}}, lineColor={220,220,220},
90
+ lineThickness=0.1, fillPattern=FillPattern.Sphere, smooth=Smooth.Bezier, fillColor={230,230,230}),
91
+ Text(extent={{-98,78},{-60,62}}, textColor={0,0,0}, textString="TDryBul"),
92
+ Text(extent={{-98,58},{-60,42}}, textColor={0,0,0}, textString="TBlaSky"),
93
+ Text(extent={{-98,38},{-60,22}}, textColor={0,0,0}, textString="winSpe"),
94
+ Text(extent={{-98,18},{-60,2}}, textColor={0,0,0}, textString="winDir"),
95
+ Text(extent={{-98,-2},{-60,-18}}, textColor={0,0,0}, textString="HDirNor"),
96
+ Text(extent={{-98,-22},{-60,-38}}, textColor={0,0,0}, textString="HDifHor"),
97
+ Text(extent={{-98,-42},{-60,-58}}, textColor={0,0,0}, textString="HGloHor"),
98
+ Text(extent={{-150,140},{150,100}}, textColor={0,0,255}, textString="%name")}));
99
+ end Weather;
@@ -0,0 +1,8 @@
1
+ within FastSmoothBuildings;
2
+ package BoundaryConditions "Weather and solar irradiance (after Buildings.BoundaryConditions)"
3
+ annotation (Documentation(info="<html>
4
+ <p>
5
+ Weather data and solar irradiance after Buildings.BoundaryConditions: the weather inputs of a model, the solar position, the Perez sky model and the irradiance on tilted surfaces, without the events of a weather file reader.
6
+ </p>
7
+ </html>"));
8
+ end BoundaryConditions;
@@ -0,0 +1,19 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model BoilerDemand
3
+ "Demand of a production (trano BoilerControl, variant simple): on when a valve of its circuits opens beyond 0.5,
4
+ off when all are below 0.01"
5
+ parameter Integer n = 1 "Number of circuits";
6
+ parameter Real dMax = 1e-3 "Width of the smooth maximum of the openings";
7
+ Interfaces.RealInput yMax[n] "Largest opening of the valves of each circuit"
8
+ annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
9
+ Hysteresis hys(uLow=0.01, uHigh=0.5, u=smoothMaxN(yMax, dMax));
10
+ Interfaces.RealOutput y(unit="1") "Demand"
11
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
12
+ equation
13
+ y = hys.y;
14
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
15
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
16
+ fillPattern=FillPattern.Solid),
17
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="demand"),
18
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
19
+ end BoilerDemand;
@@ -0,0 +1,21 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model BoilerTemperatureControl
3
+ "Firing of a boiler without storage (trano Buildings boiler): P controller (k) on the boiler temperature, while
4
+ there is demand"
5
+ parameter Real TempSet(unit="K") = 353.15 "Boiler temperature set point";
6
+ parameter Real k = 1 "Gain";
7
+ parameter Real dY = 1e-3 "Width of the smooth limits of the part load";
8
+ Interfaces.RealInput T(unit="K") "Boiler water temperature"
9
+ annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
10
+ Interfaces.RealInput demand "Demand, 0 or 1"
11
+ annotation (Placement(transformation(extent={{-140,-80},{-100,-40}})));
12
+ Interfaces.RealOutput y(unit="1") "Part load ratio"
13
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
14
+ equation
15
+ y = demand*Utilities.smoothLimit(k*(TempSet - T), 0, 1, dY);
16
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
17
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
18
+ fillPattern=FillPattern.Solid),
19
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="boiler"),
20
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
21
+ end BoilerTemperatureControl;
@@ -0,0 +1,26 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model CollectorControl
3
+ "Collector control of a pump (trano CollectorControl): on when a valve opens beyond 0.5, off when all are
4
+ below 0.01, the speed from a P controller holding the head at dp_nominal"
5
+ parameter Integer nVal = 1 "Number of valves";
6
+ parameter Real k = 1 "Gain";
7
+ parameter Real dY = 1e-3 "Width of the smooth limits of the speed";
8
+ parameter Real dMax = 1e-3 "Width of the smooth maximum of the openings";
9
+ Interfaces.RealInput yVal[nVal] "Openings of the valves of the circuit"
10
+ annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
11
+ Interfaces.RealInput dpRel "Head of the pump relative to its nominal head"
12
+ annotation (Placement(transformation(extent={{-140,-80},{-100,-40}})));
13
+ Interfaces.RealOutput yMax "Largest opening (the boiler control reads it)"
14
+ annotation (Placement(transformation(extent={{100,40},{140,80}})));
15
+ Hysteresis hysPum(uLow=0.01, uHigh=0.5, u=yMax);
16
+ Interfaces.RealOutput y(unit="1") "Speed of the pump"
17
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
18
+ equation
19
+ yMax = smoothMaxN(yVal, dMax);
20
+ y = Utilities.smoothLimit(k*(hysPum.y - dpRel), 0, 1, dY);
21
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
22
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
23
+ fillPattern=FillPattern.Solid),
24
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="collector"),
25
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
26
+ end CollectorControl;
@@ -0,0 +1,20 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model EmissionMonitored
3
+ "Variant MonitoredSetpoint: P controller (IDEAS LimPID) between 0 and 1 towards a set point read from external
4
+ data"
5
+ parameter Real k = 1 "Gain";
6
+ parameter Real dY = 1e-3 "Width of the smooth limits of the output";
7
+ Interfaces.RealInput TSet(unit="K") "Set point"
8
+ annotation (Placement(transformation(extent={{-140,40},{-100,80}})));
9
+ Interfaces.RealInput TZon(unit="K") "Zone air temperature"
10
+ annotation (Placement(transformation(extent={{-140,-80},{-100,-40}})));
11
+ Interfaces.RealOutput y(unit="1") "Valve opening, or share of the power of an ideal emitter"
12
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
13
+ equation
14
+ y = Utilities.smoothLimit(k*(TSet - TZon), 0, 1, dY);
15
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
16
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
17
+ fillPattern=FillPattern.Solid),
18
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="P"),
19
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
20
+ end EmissionMonitored;
@@ -0,0 +1,10 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model EmissionOnOff "Variant onoff: on below the set point minus half the band, off above it plus half the band"
3
+ extends PartialEmissionControl;
4
+ parameter Real bandwidth(unit="K") = 0.1 "Band of the on/off controller (Modelica OnOffController)";
5
+ Hysteresis onOff(uLow=-bandwidth/2, uHigh=bandwidth/2, u=TSet - TZon);
6
+ equation
7
+ y = onOff.y;
8
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
9
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="on/off")}));
10
+ end EmissionOnOff;
@@ -0,0 +1,8 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model EmissionP "Variant PController: P controller (IDEAS LimPID) between 0 and 1"
3
+ extends PartialEmissionControl(k=5);
4
+ equation
5
+ y = Utilities.smoothLimit(k*(TSet - TZon), 0, 1, dY);
6
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
7
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="P")}));
8
+ end EmissionP;
@@ -0,0 +1,11 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model EmissionPI "Variant default: PI heating loop of Buildings G36 ControlLoops (k = 0.1, Ti = 900 s)"
3
+ extends PartialEmissionControl;
4
+ parameter Real kHea = 0.1 "Gain of the heating loop";
5
+ parameter Real TiHea(unit="s") = 900 "Integral time of the heating loop";
6
+ PI conHea(k=kHea, Ti=TiHea, dY=dY, e=TSet - TZon, enable=1);
7
+ equation
8
+ y = conHea.y;
9
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
10
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="PI")}));
11
+ end EmissionPI;
@@ -0,0 +1,45 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model HeatPumpControl
3
+ "Control of trano's air-to-water heat pump (Buildings model): heating curve, heating season, buffer charged
4
+ between TSupSet - dTHys/2 and TSupSet + dTHys/2, compressor PI on the condenser outlet towards TSupSet + dTHys
5
+ (minimum speed yComMin); the minimum on and off times of the safety control are not modelled"
6
+ parameter Real TSet(unit="K") = 323.15 "Supply temperature at the design outdoor temperature";
7
+ parameter Real TSupMin(unit="K") = 303.15 "Supply temperature at the heating limit";
8
+ parameter Real TOutDes(unit="K") = 265.15 "Design outdoor temperature";
9
+ parameter Real TOutHeaLim(unit="K") = 289.15 "Heating limit";
10
+ parameter Real dTHys(unit="K") = 5 "Band of the buffer charging";
11
+ parameter Real kCom = 0.1 "Gain of the compressor controller";
12
+ parameter Real TiCom(unit="s") = 300 "Integral time of the compressor controller";
13
+ parameter Real yComMin = 0.3 "Minimum compressor speed";
14
+ parameter Real tauSen(unit="s") = 30 "Time constant of the condenser outlet temperature";
15
+ parameter Real dT(unit="K") = 0.1 "Width of the smooth limits of the heating curve";
16
+ parameter Real dY = 1e-3*(1 - yComMin) "Width of the smooth limits of the compressor speed";
17
+ Interfaces.RealInput demand "Demand of the circuits, 0 or 1"
18
+ annotation (Placement(transformation(extent={{-140,50},{-100,90}})));
19
+ Interfaces.RealInput TOut(unit="K") "Outdoor air temperature"
20
+ annotation (Placement(transformation(extent={{-140,5},{-100,45}})));
21
+ Interfaces.RealInput TBuf(unit="K") "Buffer temperature"
22
+ annotation (Placement(transformation(extent={{-140,-45},{-100,-5}})));
23
+ Interfaces.RealInput TConOut(unit="K") "Condenser outlet temperature"
24
+ annotation (Placement(transformation(extent={{-140,-90},{-100,-50}})));
25
+ Interfaces.RealOutput y(unit="1") "Compressor speed"
26
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
27
+ Real TSupSet(unit="K") "Supply temperature set point (heating curve)";
28
+ Real TCon(unit="K", start=TSet, fixed=true) "Measured condenser outlet temperature";
29
+ Real heaOn "Heating on";
30
+ Hysteresis warOut(uLow=TOutHeaLim - 1, uHigh=TOutHeaLim + 1, u=TOut) "Outside the heating season";
31
+ Hysteresis bufCha(uLow=-dTHys/2, uHigh=dTHys/2, u=TSupSet - TBuf, y_start=1) "Charging the buffer";
32
+ PI conCom(k=kCom, Ti=TiCom, yMin=yComMin, yMax=1, yReset=yComMin, dY=dY, e=TSupSet + dTHys - TCon,
33
+ enable=heaOn);
34
+ equation
35
+ TSupSet = Utilities.smoothMin(TSet, Utilities.smoothMax(TSupMin, TSet + (TSupMin - TSet)*(TOut - TOutDes)
36
+ /(TOutHeaLim - TOutDes), dT), dT);
37
+ tauSen*der(TCon) = TConOut - TCon;
38
+ heaOn = demand*(1 - warOut.y)*bufCha.y;
39
+ y = heaOn*conCom.y;
40
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
41
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
42
+ fillPattern=FillPattern.Solid),
43
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="heat pump"),
44
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
45
+ end HeatPumpControl;
@@ -0,0 +1,35 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model Hysteresis
3
+ "y goes to 1 when u rises above uHigh and back to 0 when u falls below uLow (CDL Hysteresis), as a bistable
4
+ state switching within tau"
5
+ parameter Real uLow "Threshold of the switch to 0";
6
+ parameter Real uHigh "Threshold of the switch to 1";
7
+ parameter Real tau(unit="s") = 10 "Switching time";
8
+ parameter Real dU = (uHigh - uLow)/10 "Half-width of the smooth transition of the switch";
9
+ parameter Real y_start = 0 "Initial output";
10
+ Interfaces.RealInput u
11
+ annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
12
+ Real y(start=y_start, fixed=true);
13
+ equation
14
+ tau*der(y) = Utilities.regStep(u - (uHigh + (uLow - uHigh)*y), 1, 0, dU) - y;
15
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
16
+ Rectangle(extent={{-100,100},{100,-100}}, lineColor={0,0,0}, fillColor={210,210,210},
17
+ fillPattern=FillPattern.Solid, borderPattern=BorderPattern.Raised),
18
+ Polygon(points={{-80,90},{-88,68},{-72,68},{-80,90}}, lineColor={192,192,192}, fillColor={192,192,192},
19
+ fillPattern=FillPattern.Solid),
20
+ Line(points={{-80,68},{-80,-29}}, color={192,192,192}),
21
+ Polygon(points={{92,-29},{70,-21},{70,-37},{92,-29}}, lineColor={192,192,192}, fillColor={192,192,192},
22
+ fillPattern=FillPattern.Solid),
23
+ Line(points={{-79,-29},{84,-29}}, color={192,192,192}),
24
+ Line(points={{-79,-29},{41,-29}}),
25
+ Line(points={{-15,-21},{1,-29},{-15,-36}}),
26
+ Line(points={{41,51},{41,-29}}),
27
+ Line(points={{33,3},{41,22},{50,3}}),
28
+ Line(points={{-49,51},{81,51}}),
29
+ Line(points={{-4,59},{-19,51},{-4,43}}),
30
+ Line(points={{-59,29},{-49,11},{-39,29}}),
31
+ Line(points={{-49,51},{-49,-29}}),
32
+ Text(extent={{-92,-49},{-9,-92}}, textColor={192,192,192}, textString="%uLow"),
33
+ Text(extent={{2,-49},{91,-92}}, textColor={192,192,192}, textString="%uHigh"),
34
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
35
+ end Hysteresis;
@@ -0,0 +1,39 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model PI
3
+ "PI controller with limits and anti-windup (Modelica LimPID: back-calculation with Ni), its integral relaxed to
4
+ the reset value while disabled"
5
+ parameter Real k "Gain";
6
+ parameter Real Ti(unit="s") "Integral time";
7
+ parameter Real yMin = 0;
8
+ parameter Real yMax = 1;
9
+ parameter Real Ni = 0.9 "Anti-windup gain";
10
+ parameter Real yReset = yMin "Output after a reset";
11
+ parameter Real tauReset(unit="s") = 30 "Time constant of the reset while disabled";
12
+ parameter Real dY = 1e-3*(yMax - yMin) "Width of the smooth limits";
13
+ Interfaces.RealInput e "Control error"
14
+ annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
15
+ Interfaces.RealInput enable "1: integrate, 0: reset"
16
+ annotation (Placement(transformation(extent={{-20,-20},{20,20}}, rotation=90, origin={0,-120})));
17
+ Real I(start=yReset/k, fixed=true) "Integral of the error";
18
+ Real yUnl "Unlimited output";
19
+ Interfaces.RealOutput y
20
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
21
+ equation
22
+ yUnl = k*(e + I);
23
+ y = Utilities.smoothLimit(yUnl, yMin, yMax, dY);
24
+ der(I) = enable*(e/Ti + (y - yUnl)/(k*Ni*Ti)) + (1 - enable)*(yReset/k - e - I)/tauReset;
25
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
26
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
27
+ fillPattern=FillPattern.Solid),
28
+ Polygon(points={{-80,82},{-88,60},{-72,60},{-80,82}}, lineColor={192,192,192}, fillColor={192,192,192},
29
+ fillPattern=FillPattern.Solid),
30
+ Line(points={{-80,68},{-80,-100}}, color={192,192,192}),
31
+ Line(points={{-90,-80},{70,-80}}, color={192,192,192}),
32
+ Polygon(points={{74,-80},{52,-72},{52,-88},{74,-80}}, lineColor={192,192,192}, fillColor={192,192,192},
33
+ fillPattern=FillPattern.Solid),
34
+ Line(points={{-80,-80},{-80,-22}}, color={0,0,0}),
35
+ Line(points={{-80,-22},{6,56}}, color={0,0,0}),
36
+ Line(points={{6,56},{68,56}}, color={0,0,0}),
37
+ Text(extent={{-26,-22},{74,-62}}, textColor={0,0,0}, textString="PI"),
38
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
39
+ end PI;
@@ -0,0 +1,22 @@
1
+ within FastSmoothBuildings.Controls;
2
+ partial model PartialEmissionControl
3
+ "Emission control of a zone (trano EmissionControl): set point of its day schedule, output y to the valve or
4
+ the ideal emitter"
5
+ parameter Real schedule[:](each unit="s") = 3600*{7, 19} "Day schedule: occupied between pairs of instants";
6
+ parameter Real THeaSet(unit="K") = 294.15 "Set point when occupied";
7
+ parameter Real THeaSetBack(unit="K") = 289.15 "Set point otherwise";
8
+ parameter Real k = 1 "Gain";
9
+ parameter Real dY = 1e-3 "Width of the smooth limits of the output";
10
+ parameter Real dtSet(unit="s") = 60 "Duration of a change of the set point";
11
+ Interfaces.RealInput TZon(unit="K") "Zone air temperature"
12
+ annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
13
+ Interfaces.RealOutput y(unit="1") "Valve opening, or share of the power of an ideal emitter"
14
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
15
+ Real TSet(unit="K") "Set point";
16
+ equation
17
+ TSet = THeaSetBack + (THeaSet - THeaSetBack)*Utilities.occupancy(Utilities.timeOfDay(time), schedule, dtSet);
18
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
19
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
20
+ fillPattern=FillPattern.Solid),
21
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
22
+ end PartialEmissionControl;
@@ -0,0 +1,22 @@
1
+ within FastSmoothBuildings.Controls;
2
+ model ThreeWayValveControl
3
+ "Three-way valve control (trano ThreeWayValveControl): P controller on the supply temperature measured
4
+ downstream (filtered by tauSen)"
5
+ parameter Real TColSet(unit="K") = 363.15 "Supply temperature set point";
6
+ parameter Real k = 1 "Gain";
7
+ parameter Real tauSen(unit="s") = 10 "Time constant of the temperature measurement";
8
+ parameter Real dY = 1e-3 "Width of the smooth limits of the opening";
9
+ Interfaces.RealInput u(unit="K") "Measured supply temperature"
10
+ annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
11
+ Interfaces.RealOutput y(unit="1") "Opening of the supply path"
12
+ annotation (Placement(transformation(extent={{100,-20},{140,20}})));
13
+ Real TMea(unit="K", start=TColSet - 30, fixed=true) "Filtered measurement";
14
+ equation
15
+ tauSen*der(TMea) = u - TMea;
16
+ y = Utilities.smoothLimit(k*(TColSet - TMea), 0, 1, dY);
17
+ annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}), graphics={
18
+ Rectangle(extent={{-100,-100},{100,100}}, lineColor={0,0,127}, fillColor={255,255,255},
19
+ fillPattern=FillPattern.Solid),
20
+ Text(extent={{-90,40},{90,-40}}, textColor={0,0,0}, textString="3WV"),
21
+ Text(extent={{-150,150},{150,110}}, textColor={0,0,255}, textString="%name")}));
22
+ end ThreeWayValveControl;