Temperature

model Temperature "Ideal one port temperature sensor"
    extends Sensors.BaseClasses.PartialAbsoluteSensor;

    Modelica.Blocks.Interfaces.RealOutput T(final quantity = "ThermodynamicTemperature", final unit = "K", displayUnit = "degC", min = 0) "Temperature in port medium"
        annotation (Placement(transformation(extent = {
            {60, -10}, 
            {80, 10}})));
equation
    T = Medium.temperature(Medium.setState_phX(port.p, inStream(port.h_outflow), inStream(port.Xi_outflow)));

    annotation (
        defaultComponentName = "temperature",
        Documentation(info = "<html>\n<p>\nThis component monitors the temperature of the fluid passing its port.\nThe sensor is ideal, i.e., it does not influence the fluid.\n</p>\n</html>"),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {0, -70}, 
                        {0, -100}},
                    color = {0, 0, 127}), 
                Ellipse(
                    extent = {
                        {-20, -98}, 
                        {20, -60}},
                    lineThickness = 0.5,
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Rectangle(
                    extent = {
                        {-12, 40}, 
                        {12, -68}},
                    lineColor = {191, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-12, 40}, 
                        {-12, 80}, 
                        {-10, 86}, 
                        {-6, 88}, 
                        {0, 90}, 
                        {6, 88}, 
                        {10, 86}, 
                        {12, 80}, 
                        {12, 40}, 
                        {-12, 40}},
                    lineThickness = 0.5), 
                Line(
                    points = {
                        {-12, 40}, 
                        {-12, -64}},
                    thickness = 0.5), 
                Line(
                    points = {
                        {12, 40}, 
                        {12, -64}},
                    thickness = 0.5), 
                Line(points = {
                    {-40, -20}, 
                    {-12, -20}}), 
                Line(points = {
                    {-40, 20}, 
                    {-12, 20}}), 
                Line(points = {
                    {-40, 60}, 
                    {-12, 60}}), 
                Line(
                    points = {
                        {12, 0}, 
                        {60, 0}},
                    color = {0, 0, 127})}),
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Ellipse(
                    extent = {
                        {-20, -88}, 
                        {20, -50}},
                    lineThickness = 0.5,
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Rectangle(
                    extent = {
                        {-12, 50}, 
                        {12, -58}},
                    lineColor = {191, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-12, 50}, 
                        {-12, 90}, 
                        {-10, 96}, 
                        {-6, 98}, 
                        {0, 100}, 
                        {6, 98}, 
                        {10, 96}, 
                        {12, 90}, 
                        {12, 50}, 
                        {-12, 50}},
                    lineThickness = 0.5), 
                Line(
                    points = {
                        {-12, 50}, 
                        {-12, -54}},
                    thickness = 0.5), 
                Line(
                    points = {
                        {12, 50}, 
                        {12, -54}},
                    thickness = 0.5), 
                Line(points = {
                    {-40, -10}, 
                    {-12, -10}}), 
                Line(points = {
                    {-40, 30}, 
                    {-12, 30}}), 
                Line(points = {
                    {-40, 70}, 
                    {-12, 70}}), 
                Text(
                    extent = {
                        {126, -30}, 
                        {6, -60}},
                    textString = "T"), 
                Text(
                    extent = {
                        {-150, 110}, 
                        {150, 150}},
                    textString = "%name",
                    lineColor = {0, 0, 255}), 
                Line(
                    points = {
                        {12, 0}, 
                        {60, 0}},
                    color = {0, 0, 127})}));
end Temperature;