$(instance)TemperatureOfTwoMassesTest Icon

TemperatureOfTwoMassesTest

Test component for simulating heat exchange between two masses and verifying temperature sensor readings.

This component models the thermal interaction of two distinct masses, mass1 and mass2, each represented by a HeatCapacitor with specified heat capacities (C) and initial temperatures (T0). A ThermalConductor facilitates heat transfer between the two masses. The system's behavior is monitored using a RelativeTemperatureSensor to measure the temperature difference across the masses, and two TemperatureSensors to read the absolute temperature of each mass individually. The component also calculates the theoretical final equilibrium temperature, final_T, that the combined system will reach, assuming no heat loss to the environment. This final temperature is determined by the conservation of energy, expressed as:

\[final\_T = \frac{mass1.T0 \cdot mass1.C + mass2.T0 \cdot mass2.C}{mass1.C + mass2.C}\]

The connect statements define the acausal thermal connections between the masses, the conductor, and the sensors. The metadata reveals this component is intended for testing the functionality of the temperature sensors and the heat exchange model under defined conditions.

Usage

TemperatureOfTwoMassesTest()

Variables

NameDescriptionUnits
final_TProjected final equilibrium temperature of the two masses.K

Behavior

\[ \begin{equation} \left[ \begin{array}{c} \mathtt{final\_T}\left( t \right) = \frac{\mathtt{mass1.C} \mathtt{mass1.T0} + \mathtt{mass2.C} \mathtt{mass2.T0}}{\mathtt{mass1.C} + \mathtt{mass2.C}} \\ \mathrm{connect}\left( mass1_{+}node, conduction_{+}node_{a} \right) \\ \mathrm{connect}\left( conduction_{+}node_{b}, mass2_{+}node \right) \\ \mathrm{connect}\left( mass1_{+}node, relative_{temperature\_sensor_{+}node\_a} \right) \\ \mathrm{connect}\left( mass2_{+}node, relative_{temperature\_sensor_{+}node\_b} \right) \\ \mathrm{connect}\left( mass1_{+}node, temperature_{sensor1_{+}node} \right) \\ \mathrm{connect}\left( mass2_{+}node, temperature_{sensor2_{+}node} \right) \\ \mathtt{mass1.T}\left( t \right) = \mathtt{mass1.node.T}\left( t \right) \\ \frac{\mathrm{d} \mathtt{mass1.T}\left( t \right)}{\mathrm{d}t} = \mathtt{mass1.dT}\left( t \right) \\ \mathtt{mass1.dT}\left( t \right) = \frac{\mathtt{mass1.node.Q}\left( t \right)}{\mathtt{mass1.C}} \\ \mathtt{mass2.T}\left( t \right) = \mathtt{mass2.node.T}\left( t \right) \\ \frac{\mathrm{d} \mathtt{mass2.T}\left( t \right)}{\mathrm{d}t} = \mathtt{mass2.dT}\left( t \right) \\ \mathtt{mass2.dT}\left( t \right) = \frac{\mathtt{mass2.node.Q}\left( t \right)}{\mathtt{mass2.C}} \\ \mathtt{conduction.{\Delta}T}\left( t \right) = - \mathtt{conduction.node\_b.T}\left( t \right) + \mathtt{conduction.node\_a.T}\left( t \right) \\ \mathtt{conduction.node\_a.Q}\left( t \right) = \mathtt{conduction.Q}\left( t \right) \\ \mathtt{conduction.node\_a.Q}\left( t \right) + \mathtt{conduction.node\_b.Q}\left( t \right) = 0 \\ \mathtt{conduction.Q}\left( t \right) = \mathtt{conduction.G} \mathtt{conduction.{\Delta}T}\left( t \right) \\ \mathtt{relative\_temperature\_sensor.T\_rel}\left( t \right) = - \mathtt{relative\_temperature\_sensor.node\_b.T}\left( t \right) + \mathtt{relative\_temperature\_sensor.node\_a.T}\left( t \right) \\ 0 = \mathtt{relative\_temperature\_sensor.node\_a.Q}\left( t \right) \\ 0 = \mathtt{relative\_temperature\_sensor.node\_b.Q}\left( t \right) \\ \mathtt{temperature\_sensor1.T}\left( t \right) = \mathtt{temperature\_sensor1.node.T}\left( t \right) \\ \mathtt{temperature\_sensor1.node.Q}\left( t \right) = 0 \\ \mathtt{temperature\_sensor2.T}\left( t \right) = \mathtt{temperature\_sensor2.node.T}\left( t \right) \\ \mathtt{temperature\_sensor2.node.Q}\left( t \right) = 0 \\ \end{array} \right] \end{equation} \]

Source

# Test component for simulating heat exchange between two masses and verifying temperature sensor readings.
#
# This component models the thermal interaction of two distinct masses, `mass1` and `mass2`, each represented by a `HeatCapacitor` with
# specified heat capacities (`C`) and initial temperatures (`T0`).  A `ThermalConductor` facilitates heat transfer between the two masses.
# The system's behavior is monitored using a `RelativeTemperatureSensor` to measure the temperature difference across the masses,
# and two `TemperatureSensor`s to read the absolute temperature of each mass individually. The component also calculates the theoretical
# final equilibrium temperature, `final_T`, that the combined system will reach, assuming no heat loss to the environment. This final
# temperature is determined by the conservation of energy, expressed as:
# ```math
# final\_T = \frac{mass1.T0 \cdot mass1.C + mass2.T0 \cdot mass2.C}{mass1.C + mass2.C}
# ```
# The `connect` statements define the acausal thermal connections between the masses, the conductor, and the sensors. The metadata reveals this component is intended for testing the functionality
# of the temperature sensors and the heat exchange model under defined conditions.
test component TemperatureOfTwoMassesTest
  # First heat capacitor with initial temperature T0 = 373.15 K and heat capacity C = 15 J/K.
  mass1 = HeatCapacitor(C=15, T0=373.15)
  # Second heat capacitor with initial temperature T0 = 273.15 K and heat capacity C = 15 J/K.
  mass2 = HeatCapacitor(C=15, T0=273.15)
  # Thermal conductor with thermal conductance G = 10 W/K connecting the two masses.
  conduction = ThermalConductor(G=10)
  # Sensor to measure the relative temperature difference between mass1 and mass2.
  relative_temperature_sensor = RelativeTemperatureSensor()
  # Sensor to measure the absolute temperature of mass1.
  temperature_sensor1 = TemperatureSensor()
  # Sensor to measure the absolute temperature of mass2.
  temperature_sensor2 = TemperatureSensor()
  # Projected final equilibrium temperature of the two masses.
  variable final_T::Temperature
relations
  final_T = (mass1.T0*mass1.C+mass2.T0*mass2.C)/(mass1.C+mass2.C)
  connect(mass1.node, conduction.node_a)
  connect(conduction.node_b, mass2.node)
  connect(mass1.node, relative_temperature_sensor.node_a)
  connect(mass2.node, relative_temperature_sensor.node_b)
  connect(mass1.node, temperature_sensor1.node)
  connect(mass2.node, temperature_sensor2.node)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 10,
        "atol": {
          "mass1.T": 0.001,
          "mass2.T": 0.001,
          "temperature_sensor1.T": 0.001,
          "temperature_sensor2.T": 0.001,
          "relative_temperature_sensor.T_rel": 0.001
        },
        "expect": {
          "initial": {
            "temperature_sensor1.T": 373.15,
            "temperature_sensor2.T": 273.15,
            "relative_temperature_sensor.T_rel": 100
          },
          "signals": [
            "mass1.node.T",
            "mass2.node.T",
            "temperature_sensor1.T",
            "temperature_sensor2.T",
            "relative_temperature_sensor.T_rel"
          ]
        }
      }
    }
  }
}
end
Flattened Source
# Test component for simulating heat exchange between two masses and verifying temperature sensor readings.
#
# This component models the thermal interaction of two distinct masses, `mass1` and `mass2`, each represented by a `HeatCapacitor` with
# specified heat capacities (`C`) and initial temperatures (`T0`).  A `ThermalConductor` facilitates heat transfer between the two masses.
# The system's behavior is monitored using a `RelativeTemperatureSensor` to measure the temperature difference across the masses,
# and two `TemperatureSensor`s to read the absolute temperature of each mass individually. The component also calculates the theoretical
# final equilibrium temperature, `final_T`, that the combined system will reach, assuming no heat loss to the environment. This final
# temperature is determined by the conservation of energy, expressed as:
# ```math
# final\_T = \frac{mass1.T0 \cdot mass1.C + mass2.T0 \cdot mass2.C}{mass1.C + mass2.C}
# ```
# The `connect` statements define the acausal thermal connections between the masses, the conductor, and the sensors. The metadata reveals this component is intended for testing the functionality
# of the temperature sensors and the heat exchange model under defined conditions.
test component TemperatureOfTwoMassesTest
  # First heat capacitor with initial temperature T0 = 373.15 K and heat capacity C = 15 J/K.
  mass1 = HeatCapacitor(C=15, T0=373.15)
  # Second heat capacitor with initial temperature T0 = 273.15 K and heat capacity C = 15 J/K.
  mass2 = HeatCapacitor(C=15, T0=273.15)
  # Thermal conductor with thermal conductance G = 10 W/K connecting the two masses.
  conduction = ThermalConductor(G=10)
  # Sensor to measure the relative temperature difference between mass1 and mass2.
  relative_temperature_sensor = RelativeTemperatureSensor()
  # Sensor to measure the absolute temperature of mass1.
  temperature_sensor1 = TemperatureSensor()
  # Sensor to measure the absolute temperature of mass2.
  temperature_sensor2 = TemperatureSensor()
  # Projected final equilibrium temperature of the two masses.
  variable final_T::Temperature
relations
  final_T = (mass1.T0*mass1.C+mass2.T0*mass2.C)/(mass1.C+mass2.C)
  connect(mass1.node, conduction.node_a)
  connect(conduction.node_b, mass2.node)
  connect(mass1.node, relative_temperature_sensor.node_a)
  connect(mass2.node, relative_temperature_sensor.node_b)
  connect(mass1.node, temperature_sensor1.node)
  connect(mass2.node, temperature_sensor2.node)
metadata {
  "Dyad": {
    "tests": {
      "case1": {
        "stop": 10,
        "atol": {
          "mass1.T": 0.001,
          "mass2.T": 0.001,
          "temperature_sensor1.T": 0.001,
          "temperature_sensor2.T": 0.001,
          "relative_temperature_sensor.T_rel": 0.001
        },
        "expect": {
          "initial": {
            "temperature_sensor1.T": 373.15,
            "temperature_sensor2.T": 273.15,
            "relative_temperature_sensor.T_rel": 100
          },
          "signals": [
            "mass1.node.T",
            "mass2.node.T",
            "temperature_sensor1.T",
            "temperature_sensor2.T",
            "relative_temperature_sensor.T_rel"
          ]
        }
      }
    }
  }
}
end


Test Cases

Test Case case1

plt
Example block output
plt
Example block output
plt
Example block output
plt
Example block output
plt
Example block output