---
url: /dyad/stable/stdlib/ThermalComponents/examples/Examples.HeatSystem.md
description: >-
  Dyad Examples.HeatSystem docs.  Models a thermal system with a fixed
  temperature source heating a heat capacitor via a conductor; serves as a test
  component.
---

# `Examples.HeatSystem` {#Examples.HeatSystem}

Models a thermal system with a fixed temperature source heating a heat capacitor via a conductor; serves as a test component.

This component simulates the transient thermal behavior of a heat capacitor (`mass`) connected to an ideal fixed temperature source (`source`) through a thermal conductor (`conductor`). It is designed as a test component for the `HeatCapacitor`, `FixedTemperature`, and `ThermalConductor` base models. The heat capacitor is characterized by its thermal capacitance `C` and an initial temperature `T0`. The fixed temperature source maintains a constant temperature `T`. Heat transfer between the source and the capacitor is facilitated by the thermal conductor, which has a thermal conductance `G`. The temperature of the heat capacitor, denoted `mass.T`, changes over time according to the first-order differential equation:

$$C \cdot \frac{d(mass.T)}{dt} = Q\_{flow}$$

where `Q_{flow}` represents the heat flow rate into the capacitor. This heat flow is determined by the temperature difference across the conductor and its conductance:

$$Q\_{flow} = G \cdot (T\_{source} - mass.T)$$

In this component, `T_{source}` is the temperature `T` from the `source` subcomponent. Consequently, `mass.T` will asymptotically approach `T` as the simulation progresses.

## Usage {#Usage}

`ThermalComponents.Examples.HeatSystem(T=10.0, T0=-10.0, C=10.0, G=10.0)`

## Parameters: {#Parameters:}

| Name |                                 Description | Units | Default value |
| ----:| -------------------------------------------:| -----:| -------------:|
|  `T` | Temperature of the fixed temperature source |     – |          10.0 |
| `T0` |   Initial temperature of the heat capacitor |     – |         -10.0 |
|  `C` |   Thermal capacitance of the heat capacitor |     – |          10.0 |
|  `G` |        Thermal conductance of the conductor |     – |          10.0 |

## Behavior {#Behavior}

$$ \begin{align}
0 &= \mathrm{connect}\left( source\_{+}port, conductor\_{+}port\_{a} \right) \\
0 &= \mathrm{connect}\left( conductor\_{+}port\_{b}, mass\_{+}port \right) \\
\mathtt{mass.T}\left( t \right) &= \mathtt{mass.port.T}\left( t \right) \\
\frac{\mathrm{d}\mathtt{mass.T}\left( t \right)}{\mathrm{d}t} &= \mathtt{mass.dT}\left( t \right) \\
\mathtt{mass.dT}\left( t \right) &= \frac{\mathtt{mass.port.Q_flow}\left( t \right)}{\mathtt{mass.C}} \\
\mathtt{source.port.T}\left( t \right) &= \mathtt{source.T} \\
\mathtt{conductor.{\Delta}T}\left( t \right) &= \mathtt{conductor.port_a.T}\left( t \right) - \mathtt{conductor.port_b.T}\left( t \right) \\
\mathtt{conductor.port_a.Q_flow}\left( t \right) &= \mathtt{conductor.Q_flow}\left( t \right) \\
\mathtt{conductor.port_a.Q_flow}\left( t \right) + \mathtt{conductor.port_b.Q_flow}\left( t \right) &= 0 \\
\mathtt{conductor.Q_flow}\left( t \right) &= \mathtt{conductor.G} ~ \mathtt{conductor.{\Delta}T}\left( t \right)
\end{align}
$$

## Source {#Source}

````dyad
"""
Models a thermal system with a fixed temperature source heating a heat capacitor via a conductor; serves as a test component.

This component simulates the transient thermal behavior of a heat capacitor (`mass`)
connected to an ideal fixed temperature source (`source`) through a thermal conductor (`conductor`).
It is designed as a test component for the `HeatCapacitor`, `FixedTemperature`, and `ThermalConductor` base models.
The heat capacitor is characterized by its thermal capacitance `C` and an initial temperature `T0`.
The fixed temperature source maintains a constant temperature `T`. Heat transfer between the
source and the capacitor is facilitated by the thermal conductor, which has a thermal conductance `G`.
The temperature of the heat capacitor, denoted `mass.T`, changes over time according to the
first-order differential equation:
```math
C \cdot \frac{d(mass.T)}{dt} = Q_{flow}
```
where `Q_{flow}` represents the heat flow rate into the capacitor. This heat flow is
determined by the temperature difference across the conductor and its conductance:
```math
Q_{flow} = G \cdot (T_{source} - mass.T)
```
In this component, `T_{source}` is the temperature `T` from the `source` subcomponent.
Consequently, `mass.T` will asymptotically approach `T` as the simulation progresses.
"""
example component HeatSystem
  "Heat capacitor subcomponent representing the thermal mass"
  mass = ThermalComponents.Components.HeatCapacitor(C = C, T0 = T0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 320, "x2": 670, "y2": 420, "rot": 0}
      },
      "tags": []
    }
  }
  "Fixed temperature source subcomponent"
  source = ThermalComponents.Sources.FixedTemperature(T = T) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 290, "y1": 450, "x2": 390, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Thermal conductor subcomponent facilitating heat flow"
  conductor = ThermalComponents.Components.ThermalConductor(G = G) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Temperature of the fixed temperature source"
  parameter T::Real = 10.0
  "Initial temperature of the heat capacitor"
  parameter T0::Real = -10.0
  "Thermal capacitance of the heat capacitor"
  parameter C::Real = 10.0
  "Thermal conductance of the conductor"
  parameter G::Real = 10.0
relations
  connect(source.port, conductor.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(conductor.port_b, mass.port) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 620, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ThermalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 10,
        "atol": {"mass.T": 0.001, "mass.dT": 0.001},
        "expect": {"final": {"mass.T": 9.999, "mass.dT": 0}}
      }
    }
  }
}
end
````

````dyad
"""
Models a thermal system with a fixed temperature source heating a heat capacitor via a conductor; serves as a test component.

This component simulates the transient thermal behavior of a heat capacitor (`mass`)
connected to an ideal fixed temperature source (`source`) through a thermal conductor (`conductor`).
It is designed as a test component for the `HeatCapacitor`, `FixedTemperature`, and `ThermalConductor` base models.
The heat capacitor is characterized by its thermal capacitance `C` and an initial temperature `T0`.
The fixed temperature source maintains a constant temperature `T`. Heat transfer between the
source and the capacitor is facilitated by the thermal conductor, which has a thermal conductance `G`.
The temperature of the heat capacitor, denoted `mass.T`, changes over time according to the
first-order differential equation:
```math
C \cdot \frac{d(mass.T)}{dt} = Q_{flow}
```
where `Q_{flow}` represents the heat flow rate into the capacitor. This heat flow is
determined by the temperature difference across the conductor and its conductance:
```math
Q_{flow} = G \cdot (T_{source} - mass.T)
```
In this component, `T_{source}` is the temperature `T` from the `source` subcomponent.
Consequently, `mass.T` will asymptotically approach `T` as the simulation progresses.
"""
example component HeatSystem
  "Heat capacitor subcomponent representing the thermal mass"
  mass = ThermalComponents.Components.HeatCapacitor(C = C, T0 = T0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 570, "y1": 320, "x2": 670, "y2": 420, "rot": 0}
      },
      "tags": []
    }
  }
  "Fixed temperature source subcomponent"
  source = ThermalComponents.Sources.FixedTemperature(T = T) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 290, "y1": 450, "x2": 390, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Thermal conductor subcomponent facilitating heat flow"
  conductor = ThermalComponents.Components.ThermalConductor(G = G) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 450, "x2": 550, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  "Temperature of the fixed temperature source"
  parameter T::Real = 10.0
  "Initial temperature of the heat capacitor"
  parameter T0::Real = -10.0
  "Thermal capacitance of the heat capacitor"
  parameter C::Real = 10.0
  "Thermal conductance of the conductor"
  parameter G::Real = 10.0
relations
  connect(source.port, conductor.port_a) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(conductor.port_b, mass.port) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 620, "y": 500}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ThermalComponents/Example.svg"},
    "tests": {
      "case1": {
        "stop": 10,
        "atol": {"mass.T": 0.001, "mass.dT": 0.001},
        "expect": {"final": {"mass.T": 9.999, "mass.dT": 0}}
      }
    }
  }
}
end
````

## Test Cases {#Test-Cases}

### Test Case `case1` {#Test-Case-case1}

## Related {#Related}

* Examples

* Experiments

* Analyses
