PrescribedHeatFlow

model PrescribedHeatFlow "Prescribed heat flow boundary condition"
    parameter Modelica.SIunits.Temperature T_ref = 293.15 "Reference temperature";
    parameter Modelica.SIunits.LinearTemperatureCoefficient alpha = 0 "Temperature coefficient of heat flow rate";
    Modelica.Blocks.Interfaces.RealInput Q_flow(unit = "W") annotation (Placement(transformation(
        origin = {-100, 0},
        extent = {
            {20, -20}, 
            {-20, 20}},
        rotation = 180)));
    Interfaces.HeatPort_b port annotation (Placement(transformation(extent = {
        {90, -10}, 
        {110, 10}})));
equation
    port.Q_flow = -Q_flow * (1 + alpha * (port.T - T_ref));

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-60, -20}, 
                        {40, -20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Line(
                    points = {
                        {-60, 20}, 
                        {40, 20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Line(
                    points = {
                        {-80, 0}, 
                        {-60, -20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Line(
                    points = {
                        {-80, 0}, 
                        {-60, 20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Polygon(
                    points = {
                        {40, 0}, 
                        {40, 40}, 
                        {70, 20}, 
                        {40, 0}},
                    lineColor = {191, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {40, -40}, 
                        {40, 0}, 
                        {70, -20}, 
                        {40, -40}},
                    lineColor = {191, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Rectangle(
                    extent = {
                        {70, 40}, 
                        {90, -40}},
                    lineColor = {191, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {-150, 100}, 
                        {150, 60}},
                    textString = "%name",
                    lineColor = {0, 0, 255})}),
        Documentation(info = "<html>\n<p>\nThis model allows a specified amount of heat flow rate to be \"injected\"\ninto a thermal system at a given port.  The amount of heat\nis given by the input signal Q_flow into the model. The heat flows into the\ncomponent to which the component PrescribedHeatFlow is connected,\nif the input signal is positive.\n</p>\n<p>\nIf parameter alpha is &lt;&gt; 0, the heat flow is multiplied by (1 + alpha*(port.T - T_ref))\nin order to simulate temperature dependent losses (which are given with respect to reference temperature T_ref).\n</p>\n</html>"),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(
                    points = {
                        {-60, -20}, 
                        {68, -20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Line(
                    points = {
                        {-60, 20}, 
                        {68, 20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Line(
                    points = {
                        {-80, 0}, 
                        {-60, -20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Line(
                    points = {
                        {-80, 0}, 
                        {-60, 20}},
                    color = {191, 0, 0},
                    thickness = 0.5), 
                Polygon(
                    points = {
                        {60, 0}, 
                        {60, 40}, 
                        {90, 20}, 
                        {60, 0}},
                    lineColor = {191, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {60, -40}, 
                        {60, 0}, 
                        {90, -20}, 
                        {60, -40}},
                    lineColor = {191, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid)}));
end PrescribedHeatFlow;