# Room Heating

This application example will explore room heat distribution as a combined SystemModel and partial differential equation (PDE) model. The coupling will be unidirectional, as the system modeler model will be used to drive the PDE analysis. In a first step, the System Modeler’s "Thermal College Virtual Lab" is used to explore a virtual model of a room. In a second step, a PDE model is created that will compute the actual heat distribution in the room.

The System Modeler part of this application example being based on a virtual lab offers the benefit of a well-documented system model. If this is a first exposure to system modeler models, going through the "Thermal College Virtual Lab" is advised to gain an understanding of how the System Modeler works.

## Lumped Room Model

In this section, we’ll bring the room model that was created with System Modeler into the Wolfram language. We’ll take a closer look, to understand how different settings affect the room energy dynamics.

### Import Lumped System Model

As a first step we import the system model library "CollegeThermalFEM.mo". When we do this, then there is no need to open the System Modeler application separately. The model library provides us with several premade models.

To use a specific model, in this case the "RoomModelRome", we select that from the model library. We can open the model by checking its children.

Now, that the model is loaded, we can simulate the model. For this, we use SystemModelSimulate.

The result is a SystemModelSimulationData that contains all simulation results of interest.

Other variables can also be plotted by specifying the correct variable name.

### Varying Outside Temperature

We’ll analyze the room behavior with time-dependent temperature data. The model has some predefined temperature data as a function of time in seconds.

Let us now test the model for the varying spring temperature.

Since during spring the outside temperature is around the reference temperature of 20 °C, the radiator is mostly in the OFF state. It is switched ON during the evening when the temperature goes below the reference temperature.

## PDE Room Model

In this section, we’ll build a 2D model of our room and study how temperature changes across the room by using values for the boundary conditions that come from the System Modeler model.

The idea is to find the heat distribution in the room that ensures an average temperature of 20 degrees in the room. For this we set up a parametric partial differential equation where a parameter models the heat generated by the heater. For a given value of heater we will find a temperature distribution in the room. The integration over this temperature distribution will give us an average temperature in the room for a given value of the heater. We then will find the value of the heater such that the average temperature in the room is 20 degrees.

Many of the animations of the simulation results shown in this notebook are generated with a call to Rasterize. This is to reduce the disk space this notebook requires. The downside is that the visual quality of the animations will not be as crisp as without it.

### Heat Transfer Model Setup

One possibility to model the heat distribution in the room is to use a heat transfer equation and use a partial differential equation model to describe the room. The room will be a simple rectangular geometry.

The heat transfer PDE is given as:

The dependent variable in the heat equation is the temperature , which varies with time and position . The partial differential equation (PDE) model describes how thermal energy is transported over time in a medium with density and specific heat capacity . The specific heat capacity is a material property that specifies the amount of heat energy that is needed to raise the temperature of a substance with unit mass by one degree Kelvin.

Besides the time derivative part the PDE is made up of several components. First and foremost, there is a diffusive term: with a thermal conductivity .

More information about modeling with the heat transfer equation can be found in the HeatTransfer monograph.

### Model Parameter Setup

Our goal is to find a steady-state temperature distribution of the room. This means that the temperature dependent terms can be dropped and we arrive at:

We set up a rectangular domain with a width of 4 [m] and a length of 4 [m] to model the room and we have a radiator close to the wall.

Next, we create a mesh of the room. Note that we want the radiator to be part of the mesh. We will use the region of the radiator as an energy source .

To make use of specific material parameters in the equation we extract relevant data from the ThermodynamicData.

In this model, the focus is on the temperature distribution within the room, with air assumed as the medium. The thermal conductivity of air is required for the heat transfer PDE model. The value of the room medium's thermal conductivity, however, was not required for the System Modeler model. There the thermal conductivity of the walls was utilized in its computation. This means that the thermal conductivity of the room's medium air was not set in the system model and we set it here.

Now comes the crucial step where we define a parametric heat source, the radiator. For all spatial coordinates that are within the sub domain of the radiator, we have a heat source of . Outside of the radiator there is 0 heat generated.

Next, we specify the boundary conditions for the four walls. Because the system model is a transient model we need to choose a specific time at which we would like to extract the data. In this case we have chosen arbitrarily the time of the system modeler simulation time.

The system modeler variable we are interested in is "tempRome.outsideTemp".

We now have all components to set up the parametric function.

To get a better understanding of how the model behaves we start by probing the model with a somewhat random value for the heat source.

What we would like to find is the average value of the room temperature for a specific value. For this we write a helper function average.

As a last step we would like to find that value of , that gives us an average room temperature of 20 degrees.

Going from a lumped model to a PDE can be tricky since the lumped model makes assumptions that can not be recovered later but are needed for the PDE model. For example, the temperature of the radiator, the room and the interior walls are all the same in lumped scenario which does not reflect reality.