RelativeTemperature

model RelativeTemperature "Ideal relative temperature sensor"
    extends Sensors.BaseClasses.PartialRelativeSensor;

    Modelica.Blocks.Interfaces.RealOutput T_rel(final quantity = "ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min = 0) "Relative temperature signal"
        annotation (Placement(transformation(
            origin = {0, -90},
            extent = {
                {10, -10}, 
                {-10, 10}},
            rotation = 90)));
equation
    T_rel = Medium.temperature(Medium.setState_phX(port_a.p, inStream(port_a.h_outflow), inStream(port_a.Xi_outflow))) - Medium.temperature(Medium.setState_phX(port_b.p, inStream(port_b.h_outflow), inStream(port_b.Xi_outflow)));

    annotation (
        Icon(graphics = {
            Line(
                points = {
                    {0, -30}, 
                    {0, -80}},
                color = {0, 0, 127}), 
            Text(
                extent = {
                    {128, -70}, 
                    {10, -100}},
                textString = "T_rel")}),
        Documentation(info = "<html>\n<p>\nThe relative temperature \"T(port_a) - T(port_b)\" is determined between\nthe two ports of this component and is provided as output signal. The\nsensor should be connected in parallel with other equipment, no flow\nthrough the sensor is allowed.\n</p>\n</html>"));
end RelativeTemperature;