HeatFlowSensor

model HeatFlowSensor "Heat flow rate sensor"
    extends Modelica.Icons.RotationalSensor;

    Modelica.Blocks.Interfaces.RealOutput Q_flow(unit = "W") "Heat flow from port_a to port_b as output signal"
        annotation (Placement(transformation(
            origin = {0, -100},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 270)));
    Interfaces.HeatPort_a port_a annotation (Placement(transformation(extent = {
        {-110, -10}, 
        {-90, 10}})));
    Interfaces.HeatPort_b port_b annotation (Placement(transformation(extent = {
        {90, -10}, 
        {110, 10}})));
equation
    port_a.Q_flow + port_b.Q_flow = 0;
    Q_flow = port_a.Q_flow;
    port_a.T = port_b.T;

    annotation (
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-70, 0}, 
                        {-95, 0}},
                    color = {191, 0, 0}), 
                Line(
                    points = {
                        {0, -70}, 
                        {0, -90}},
                    color = {0, 0, 127}), 
                Line(
                    points = {
                        {94, 0}, 
                        {69, 0}},
                    color = {191, 0, 0})}),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Text(
                    extent = {
                        {5, -86}, 
                        {116, -110}},
                    textString = "Q_flow"), 
                Line(
                    points = {
                        {-70, 0}, 
                        {-90, 0}},
                    color = {191, 0, 0}), 
                Line(
                    points = {
                        {69, 0}, 
                        {90, 0}},
                    color = {191, 0, 0}), 
                Line(
                    points = {
                        {0, -70}, 
                        {0, -90}},
                    color = {0, 0, 127}), 
                Text(
                    extent = {
                        {-150, 125}, 
                        {150, 85}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Documentation(info = "<html>\n<p>\nThis model is capable of monitoring the heat flow rate flowing through\nthis component. The sensed value of heat flow rate is the amount that\npasses through this sensor while keeping the temperature drop across the\nsensor zero.  This is an ideal model so it does not absorb any energy\nand it has no direct effect on the thermal response of a system it is included in.\nThe output signal is positive, if the heat flows from port_a to port_b.\n</p>\n</html>"));
end HeatFlowSensor;