|
| 1 | +package ModelicaServices "ModelicaServices (OpenModelica implementation) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation" |
| 2 | + extends Modelica.Icons.Package; |
| 3 | + |
| 4 | + package Machine |
| 5 | + extends Modelica.Icons.Package; |
| 6 | + final constant Real eps = 1.e-15 "Biggest number such that 1.0 + eps = 1.0"; |
| 7 | + final constant Real small = 1.e-60 "Smallest number such that small and -small are representable on the machine"; |
| 8 | + final constant Real inf = 1.e+60 "Biggest Real number such that inf and -inf are representable on the machine"; |
| 9 | + final constant Integer Integer_inf = OpenModelica.Internal.Architecture.integerMax() "Biggest Integer number such that Integer_inf and -Integer_inf are representable on the machine"; |
| 10 | + end Machine; |
| 11 | + annotation(Protection(access = Access.hide), version = "3.2.1", versionBuild = 2, versionDate = "2013-08-14", dateModified = "2013-08-14 08:44:41Z"); |
| 12 | +end ModelicaServices; |
| 13 | + |
| 14 | +package Modelica "Modelica Standard Library - Version 3.2.1 (Build 4)" |
| 15 | + extends Modelica.Icons.Package; |
| 16 | + |
| 17 | + package Blocks "Library of basic input/output control blocks (continuous, discrete, logical, table blocks)" |
| 18 | + extends Modelica.Icons.Package; |
| 19 | + |
| 20 | + package Interfaces "Library of connectors and partial models for input/output blocks" |
| 21 | + extends Modelica.Icons.InterfacesPackage; |
| 22 | + connector BooleanInput = input Boolean "'input Boolean' as connector"; |
| 23 | + connector BooleanOutput = output Boolean "'output Boolean' as connector"; |
| 24 | + end Interfaces; |
| 25 | + end Blocks; |
| 26 | + |
| 27 | + package Math "Library of mathematical functions (e.g., sin, cos) and of functions operating on vectors and matrices" |
| 28 | + extends Modelica.Icons.Package; |
| 29 | + |
| 30 | + package Icons "Icons for Math" |
| 31 | + extends Modelica.Icons.IconsPackage; |
| 32 | + |
| 33 | + partial function AxisCenter "Basic icon for mathematical function with y-axis in the center" end AxisCenter; |
| 34 | + end Icons; |
| 35 | + |
| 36 | + function asin "Inverse sine (-1 <= u <= 1)" |
| 37 | + extends Modelica.Math.Icons.AxisCenter; |
| 38 | + input Real u; |
| 39 | + output .Modelica.SIunits.Angle y; |
| 40 | + external "builtin" y = asin(u); |
| 41 | + end asin; |
| 42 | + |
| 43 | + function exp "Exponential, base e" |
| 44 | + extends Modelica.Math.Icons.AxisCenter; |
| 45 | + input Real u; |
| 46 | + output Real y; |
| 47 | + external "builtin" y = exp(u); |
| 48 | + end exp; |
| 49 | + end Math; |
| 50 | + |
| 51 | + package Constants "Library of mathematical constants and constants of nature (e.g., pi, eps, R, sigma)" |
| 52 | + extends Modelica.Icons.Package; |
| 53 | + final constant Real pi = 2 * Math.asin(1.0); |
| 54 | + final constant Real small = ModelicaServices.Machine.small "Smallest number such that small and -small are representable on the machine"; |
| 55 | + final constant .Modelica.SIunits.Velocity c = 299792458 "Speed of light in vacuum"; |
| 56 | + final constant Real mue_0(final unit = "N/A2") = 4 * pi * 1.e-7 "Magnetic constant"; |
| 57 | + end Constants; |
| 58 | + |
| 59 | + package Icons "Library of icons" |
| 60 | + extends Icons.Package; |
| 61 | + |
| 62 | + partial package ExamplesPackage "Icon for packages containing runnable examples" |
| 63 | + extends Modelica.Icons.Package; |
| 64 | + end ExamplesPackage; |
| 65 | + |
| 66 | + partial model Example "Icon for runnable examples" end Example; |
| 67 | + |
| 68 | + partial package Package "Icon for standard packages" end Package; |
| 69 | + |
| 70 | + partial package InterfacesPackage "Icon for packages containing interfaces" |
| 71 | + extends Modelica.Icons.Package; |
| 72 | + end InterfacesPackage; |
| 73 | + |
| 74 | + partial package SourcesPackage "Icon for packages containing sources" |
| 75 | + extends Modelica.Icons.Package; |
| 76 | + end SourcesPackage; |
| 77 | + |
| 78 | + partial package IconsPackage "Icon for packages containing icons" |
| 79 | + extends Modelica.Icons.Package; |
| 80 | + end IconsPackage; |
| 81 | + end Icons; |
| 82 | + |
| 83 | + package SIunits "Library of type and unit definitions based on SI units according to ISO 31-1992" |
| 84 | + extends Modelica.Icons.Package; |
| 85 | + |
| 86 | + package Conversions "Conversion functions to/from non SI units and type definitions of non SI units" |
| 87 | + extends Modelica.Icons.Package; |
| 88 | + |
| 89 | + package NonSIunits "Type definitions of non SI units" |
| 90 | + extends Modelica.Icons.Package; |
| 91 | + type Temperature_degC = Real(final quantity = "ThermodynamicTemperature", final unit = "degC") "Absolute temperature in degree Celsius (for relative temperature use SIunits.TemperatureDifference)" annotation(absoluteValue = true); |
| 92 | + end NonSIunits; |
| 93 | + end Conversions; |
| 94 | + |
| 95 | + type Angle = Real(final quantity = "Angle", final unit = "rad", displayUnit = "deg"); |
| 96 | + type Time = Real(final quantity = "Time", final unit = "s"); |
| 97 | + type Velocity = Real(final quantity = "Velocity", final unit = "m/s"); |
| 98 | + type Acceleration = Real(final quantity = "Acceleration", final unit = "m/s2"); |
| 99 | + type FaradayConstant = Real(final quantity = "FaradayConstant", final unit = "C/mol"); |
| 100 | + end SIunits; |
| 101 | + annotation(version = "3.2.1", versionBuild = 4, versionDate = "2013-08-14", dateModified = "2015-09-30 09:15:00Z"); |
| 102 | +end Modelica; |
| 103 | + |
| 104 | +package Modelica_Synchronous "Modelica_Synchronous (version 0.92 Build 2) - Basic synchronous input/output control blocks |
| 105 | +that are triggered by clocks" |
| 106 | + extends Modelica.Icons.Package; |
| 107 | + |
| 108 | + package Examples "Library of examples to demonstrate the usage of package Modelica_Synchronous" |
| 109 | + extends Modelica.Icons.ExamplesPackage; |
| 110 | + |
| 111 | + package Elementary "Examples that are used for the documentation of the blocks" |
| 112 | + extends Modelica.Icons.ExamplesPackage; |
| 113 | + |
| 114 | + package BooleanSignals "Examples that are used for the documentation of the Modelica_Synchronous.BooleanSignals sub-library" |
| 115 | + extends Modelica.Icons.ExamplesPackage; |
| 116 | + |
| 117 | + model TimeBasedPulse "Example of using the clocked simulation time based Boolean Pulse source block" |
| 118 | + extends Modelica.Icons.Example; |
| 119 | + .Modelica_Synchronous.BooleanSignals.TimeBasedSources.Pulse pulse(width = 50, period = 0.4, startTime = 0.1); |
| 120 | + .Modelica_Synchronous.ClockSignals.Clocks.PeriodicRealClock periodicClock1(period = 0.1); |
| 121 | + .Modelica_Synchronous.BooleanSignals.Sampler.AssignClock assignClock1; |
| 122 | + equation |
| 123 | + connect(periodicClock1.y, assignClock1.clock); |
| 124 | + connect(pulse.y, assignClock1.u); |
| 125 | + annotation(experiment(StopTime = 1.0)); |
| 126 | + end TimeBasedPulse; |
| 127 | + end BooleanSignals; |
| 128 | + end Elementary; |
| 129 | + end Examples; |
| 130 | + |
| 131 | + package ClockSignals "Library of blocks for clocked signals" |
| 132 | + extends Modelica.Icons.Package; |
| 133 | + |
| 134 | + package Clocks "Library of blocks that generate clocks" |
| 135 | + extends Modelica.Icons.SourcesPackage; |
| 136 | + |
| 137 | + block PeriodicRealClock "Generates a periodic clock signal with a period defined by a Real number" |
| 138 | + parameter Modelica.SIunits.Time period "Period of clock (defined as Real number)" annotation(Evaluate = true); |
| 139 | + extends Modelica_Synchronous.ClockSignals.Interfaces.PartialPeriodicClock; |
| 140 | + equation |
| 141 | + if useSolver then |
| 142 | + y = Clock(Clock(period), solverMethod = solverMethod); |
| 143 | + else |
| 144 | + y = Clock(period); |
| 145 | + end if; |
| 146 | + end PeriodicRealClock; |
| 147 | + end Clocks; |
| 148 | + |
| 149 | + package Interfaces "Library of connectors and partial blocks with clock signals" |
| 150 | + extends Modelica.Icons.InterfacesPackage; |
| 151 | + connector ClockInput = input Clock "'input Clock' as connector"; |
| 152 | + connector ClockOutput = output Clock "'output Clock' as connector"; |
| 153 | + |
| 154 | + partial block PartialClock "Icon, connector, and solver method of a block that generates a clock" |
| 155 | + parameter Boolean useSolver = false "= true, if solverMethod shall be explicitely defined" annotation(Evaluate = true); |
| 156 | + parameter Modelica_Synchronous.Types.SolverMethod solverMethod = "ExplicitEuler" "Integration method used for discretized continuous-time partitions"; |
| 157 | + Modelica_Synchronous.ClockSignals.Interfaces.ClockOutput y; |
| 158 | + end PartialClock; |
| 159 | + |
| 160 | + partial block PartialPeriodicClock "Icon, connector, and solver method of a block that generates a periodic clock" |
| 161 | + extends Modelica_Synchronous.ClockSignals.Interfaces.PartialClock; |
| 162 | + end PartialPeriodicClock; |
| 163 | + |
| 164 | + partial block ClockedBlockIcon "Basic graphical layout of block where at least one input or output is a clocked variable" end ClockedBlockIcon; |
| 165 | + end Interfaces; |
| 166 | + end ClockSignals; |
| 167 | + |
| 168 | + package BooleanSignals "Library of clocked blocks for Boolean signals" |
| 169 | + extends Modelica.Icons.Package; |
| 170 | + |
| 171 | + package Sampler "Library of sampler and hold blocks for Boolean signals" |
| 172 | + extends Modelica.Icons.Package; |
| 173 | + |
| 174 | + block AssignClock "Assigns a clock to a clocked Boolean signal" |
| 175 | + Modelica.Blocks.Interfaces.BooleanInput u "Connector of clocked, Boolean input signal"; |
| 176 | + Modelica.Blocks.Interfaces.BooleanOutput y "Connector of clocked, Boolean output signal"; |
| 177 | + Modelica_Synchronous.ClockSignals.Interfaces.ClockInput clock; |
| 178 | + equation |
| 179 | + when clock then |
| 180 | + y = u; |
| 181 | + end when; |
| 182 | + end AssignClock; |
| 183 | + end Sampler; |
| 184 | + |
| 185 | + package TimeBasedSources "Package of signal source blocks generating clocked simulation time based Boolean signals" |
| 186 | + extends Modelica.Icons.SourcesPackage; |
| 187 | + |
| 188 | + block Pulse "Generate pulse signal of type Boolean" |
| 189 | + extends BooleanSignals.Interfaces.PartialClockedSO; |
| 190 | + parameter Real width(final min = Modelica.Constants.small, final max = 100) = 50 "Width of pulse in % of period"; |
| 191 | + parameter Modelica.SIunits.Time period(final min = Modelica.Constants.small, start = 1) "Time for one period"; |
| 192 | + parameter Modelica.SIunits.Time startTime = 0 "Time instant of first pulse"; |
| 193 | + protected |
| 194 | + Modelica.SIunits.Time simTime; |
| 195 | + parameter Modelica.SIunits.Time Twidth = period * width / 100 "width of one pulse" annotation(HideResult = true); |
| 196 | + Modelica.SIunits.Time next(start = startTime, fixed = true) "next = startTime + n*period, for smallest n such that next>simTime"; |
| 197 | + equation |
| 198 | + simTime = sample(time); |
| 199 | + next = if simTime >= previous(next) and previous(next) < simTime + period then previous(next) + period else previous(next); |
| 200 | + y = simTime >= previous(next) or simTime <= next - period + Twidth; |
| 201 | + end Pulse; |
| 202 | + end TimeBasedSources; |
| 203 | + |
| 204 | + package Interfaces "Library of partial blocks for components with clocked Boolean signals" |
| 205 | + extends Modelica.Icons.InterfacesPackage; |
| 206 | + |
| 207 | + partial block PartialClockedSO "Block with clocked single output Boolean signals" |
| 208 | + extends Modelica_Synchronous.ClockSignals.Interfaces.ClockedBlockIcon; |
| 209 | + Modelica.Blocks.Interfaces.BooleanOutput y "Connector of clocked, Real output signal"; |
| 210 | + end PartialClockedSO; |
| 211 | + end Interfaces; |
| 212 | + end BooleanSignals; |
| 213 | + |
| 214 | + package Types "Library of types with choices, especially to build menus" |
| 215 | + extends Modelica.Icons.Package; |
| 216 | + type SolverMethod = String "Enumeration defining the integration method to solve differential equations in a clocked discretized continuous-time partition"; |
| 217 | + end Types; |
| 218 | + annotation(version = "0.92", versionBuild = 2, versionDate = "2013-09-19", dateModified = "2015-09-09 18:16:00Z"); |
| 219 | +end Modelica_Synchronous; |
| 220 | + |
| 221 | +model TimeBasedPulse_total "Example of using the clocked simulation time based Boolean Pulse source block" |
| 222 | + extends Modelica_Synchronous.Examples.Elementary.BooleanSignals.TimeBasedPulse; |
| 223 | + annotation(experiment(StopTime = 1.0)); |
| 224 | +end TimeBasedPulse_total; |
0 commit comments