|
In our simulator, we want to simulate the temperature of the rooms in a house. Browsing through the physical effects section of the pattern catalog, the pattern ThermalMass which provides this functionality can easily be found. The interface of ThermalMass is described by the following parameters:
ThermalMass | ||
|---|---|---|
| Name | Type | Description |
| target | ObjectType | An Objecttype whose temperature should be simulated |
| temperature | Attribute | Actual (i.e. last computed) temperature |
| amountOfHeat | Attribute | Actual amount of heat in Joule |
| volume | Attribute | Volume of the thermal mass |
| timeOfLastComputation | Attribute (preset) | Last timestamp when the calculation was executed |
| init | SingleMethod (implement, preset) | Initialize temperature and amountOfHeat |
| compute | SingleMethod (implement) | Computes the actual temperature |
| calculateTemperature | SingleMethod (implement, preset) | Internal calculation method |
| getHeatCapacity | SingleMethod | Determines the heat storage capacity (may be assumed as constant but is correctly depending on the actual temperature) |
| getHeatFlowFor | SingleMethod | Determines the heat flow has has affected the thermal mass since the last computation |
The first value that has to be assigned is the target parameter. In our case, target is bound to the objecttype Room in order to simulate the rooms temperature. The parameters of type Attribute can now easily be bound to the attributes of our Room Objecttype (compare class model ).
Next, a name for the computation method (that is later generated by PSiGene) must be assigned. In our example we call it doCalcLoop. The heat capacity of our rooms are assumed to be constant so the parameter getHeatCapacity is bound to the attribute heatCapacity of the objecttype Room.
The only question left is, how to collect the heat flows affecting a room.
In our example, heat is flowing from one room to another through walls, and
additional radiators can be installed to act as heat sources.
A second Pattern (ThermalJunction) is used to define how the
heat flow can be calculated depending on the thermal resistance of the
separation (i.e. the wall or the air surrounding a radiator) and on the
difference of temperatures of both adjoining areas. Therefore,
ThermalJunction is bound twice to the class model: to
the objecttype Wall and to the objecttype Surface.
The ThermalMass pattern needs the sum of both of these heat
flows. The heat flows are calculated locally in the classes Wall
and Surface so we need a function to sum up all heat flows from all
walls and surfaces that are connected to a room. A third pattern,
FollowRelationAndSum can provide this functionality. It is
bound to the relations Room_Surface and Room_Wall and calls on every
connected object the method getHeatFlowFor.
These three patterns basically form our mini-simulator. There are only a
few more patterns missing to display the simulated temperature
(DisplayGraph and DisplaySlider) and to continuously
calculate the actual temperature (ContinuousComputation).
The complete Pattern bindings are shown in the following picture. A
textual description of the pattern bindings is stored in a special
POC file. This file is used as input to our
pattern generator.
|
|
|