VariableHeatCapacitor

model VariableHeatCapacitor "Lumped thermal element storing heat with variable capacity"
    input Modelica.Blocks.Interfaces.RealInput C(unit = "J/K") "Variable thermal conductance"
        annotation (Placement(
            visible = true,
            transformation(
                origin = {0, 80},
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = -90),
            iconTransformation(
                origin = {0, 80},
                extent = {
                    {-20, -20}, 
                    {20, 20}},
                rotation = -90)));
    Modelica.SIunits.Temperature T(start = 293.15) "Temperature of element";
    Modelica.SIunits.TemperatureSlope der_T(start = 0) "Time derivative of temperature (= der(T))";
    Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_a port annotation (Placement(transformation(
        origin = {0, -100},
        extent = {
            {-10, -10}, 
            {10, 10}},
        rotation = 90)));
equation
    C * der(T) = port.Q_flow;
    T = port.T;
    der_T = der(T);

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Polygon(
                    points = {
                        {0, 67}, 
                        {-20, 63}, 
                        {-40, 57}, 
                        {-52, 43}, 
                        {-58, 35}, 
                        {-68, 25}, 
                        {-72, 13}, 
                        {-76, -1}, 
                        {-78, -15}, 
                        {-76, -31}, 
                        {-76, -43}, 
                        {-76, -53}, 
                        {-70, -65}, 
                        {-64, -73}, 
                        {-48, -77}, 
                        {-30, -83}, 
                        {-18, -83}, 
                        {-2, -85}, 
                        {8, -89}, 
                        {22, -89}, 
                        {32, -87}, 
                        {42, -81}, 
                        {54, -75}, 
                        {56, -73}, 
                        {66, -61}, 
                        {68, -53}, 
                        {70, -51}, 
                        {72, -35}, 
                        {76, -21}, 
                        {78, -13}, 
                        {78, 3}, 
                        {74, 15}, 
                        {66, 25}, 
                        {54, 33}, 
                        {44, 41}, 
                        {36, 57}, 
                        {26, 65}, 
                        {0, 67}},
                    lineColor = {160, 160, 164},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-58, 35}, 
                        {-68, 25}, 
                        {-72, 13}, 
                        {-76, -1}, 
                        {-78, -15}, 
                        {-76, -31}, 
                        {-76, -43}, 
                        {-76, -53}, 
                        {-70, -65}, 
                        {-64, -73}, 
                        {-48, -77}, 
                        {-30, -83}, 
                        {-18, -83}, 
                        {-2, -85}, 
                        {8, -89}, 
                        {22, -89}, 
                        {32, -87}, 
                        {42, -81}, 
                        {54, -75}, 
                        {42, -77}, 
                        {40, -77}, 
                        {30, -79}, 
                        {20, -81}, 
                        {18, -81}, 
                        {10, -81}, 
                        {2, -77}, 
                        {-12, -73}, 
                        {-22, -73}, 
                        {-30, -71}, 
                        {-40, -65}, 
                        {-50, -55}, 
                        {-56, -43}, 
                        {-58, -35}, 
                        {-58, -25}, 
                        {-60, -13}, 
                        {-60, -5}, 
                        {-60, 7}, 
                        {-58, 17}, 
                        {-56, 19}, 
                        {-52, 27}, 
                        {-48, 35}, 
                        {-44, 45}, 
                        {-40, 57}, 
                        {-58, 35}},
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid)}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Polygon(
                    points = {
                        {0, 67}, 
                        {-20, 63}, 
                        {-40, 57}, 
                        {-52, 43}, 
                        {-58, 35}, 
                        {-68, 25}, 
                        {-72, 13}, 
                        {-76, -1}, 
                        {-78, -15}, 
                        {-76, -31}, 
                        {-76, -43}, 
                        {-76, -53}, 
                        {-70, -65}, 
                        {-64, -73}, 
                        {-48, -77}, 
                        {-30, -83}, 
                        {-18, -83}, 
                        {-2, -85}, 
                        {8, -89}, 
                        {22, -89}, 
                        {32, -87}, 
                        {42, -81}, 
                        {54, -75}, 
                        {56, -73}, 
                        {66, -61}, 
                        {68, -53}, 
                        {70, -51}, 
                        {72, -35}, 
                        {76, -21}, 
                        {78, -13}, 
                        {78, 3}, 
                        {74, 15}, 
                        {66, 25}, 
                        {54, 33}, 
                        {44, 41}, 
                        {36, 57}, 
                        {26, 65}, 
                        {0, 67}},
                    lineColor = {160, 160, 164},
                    fillColor = {192, 192, 192},
                    fillPattern = FillPattern.Solid), 
                Polygon(
                    points = {
                        {-58, 35}, 
                        {-68, 25}, 
                        {-72, 13}, 
                        {-76, -1}, 
                        {-78, -15}, 
                        {-76, -31}, 
                        {-76, -43}, 
                        {-76, -53}, 
                        {-70, -65}, 
                        {-64, -73}, 
                        {-48, -77}, 
                        {-30, -83}, 
                        {-18, -83}, 
                        {-2, -85}, 
                        {8, -89}, 
                        {22, -89}, 
                        {32, -87}, 
                        {42, -81}, 
                        {54, -75}, 
                        {42, -77}, 
                        {40, -77}, 
                        {30, -79}, 
                        {20, -81}, 
                        {18, -81}, 
                        {10, -81}, 
                        {2, -77}, 
                        {-12, -73}, 
                        {-22, -73}, 
                        {-30, -71}, 
                        {-40, -65}, 
                        {-50, -55}, 
                        {-56, -43}, 
                        {-58, -35}, 
                        {-58, -25}, 
                        {-60, -13}, 
                        {-60, -5}, 
                        {-60, 7}, 
                        {-58, 17}, 
                        {-56, 19}, 
                        {-52, 27}, 
                        {-48, 35}, 
                        {-44, 45}, 
                        {-40, 57}, 
                        {-58, 35}},
                    fillColor = {160, 160, 164},
                    fillPattern = FillPattern.Solid), 
                Ellipse(
                    extent = {
                        {-6, -1}, 
                        {6, -12}},
                    lineColor = {255, 0, 0},
                    fillColor = {191, 0, 0},
                    fillPattern = FillPattern.Solid), 
                Text(
                    extent = {
                        {11, 13}, 
                        {50, -25}},
                    textString = "T"), 
                Line(
                    points = {
                        {0, -12}, 
                        {0, -96}},
                    color = {255, 0, 0})}),
        Documentation(info = "<html>\n                <p>\n                    This is a generic model for the heat capacity of a material.\n                    No specific geometry is assumed beyond a total volume with\n                    uniform temperature for the entire volume.\n                    The heat capacity is set by an input.\n                </p></html>"));
end VariableHeatCapacitor;