ExpansionContraction

model ExpansionContraction "Sudden Expansion / Contraction"
    parameter Modelica.SIunits.Length D1 = 0.016 "Diameter 1";
    parameter Modelica.SIunits.Length D2 = 0.05 "Diameter 2";
    parameter Modelica.SIunits.Volume deadVolume(final min = 1e-9) = 1e-6 "Dead volume at ports";
    HydraulicsByFluidon.Components.Lines.Base.SimpleExpansionContraction simpleExpansionContaction(forwardFluidProperties = false, D1 = D1, D2 = D2) annotation (Placement(
        visible = true,
        transformation(
            origin = {0, 0},
            extent = {
                {-12, -10}, 
                {12, 10}},
            rotation = 0)));
    HydraulicsByFluidon.Components.Volumes.Volume volumeB(capacity = deadVolume) annotation (Placement(
        visible = true,
        transformation(
            origin = {0, 70},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
    HydraulicsByFluidon.Components.Volumes.Volume volumeA(capacity = deadVolume) annotation (Placement(
        visible = true,
        transformation(
            origin = {0, -70},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));

    extends HydraulicsByFluidon.Components.Base.HydTwoPortVerticalExt;
equation
    connect(fluidPortA,volumeA.fluidPort) annotation (Line(
        points = {
            {0, -100}, 
            {0, -70}},
        color = {0, 93, 152}));
    connect(volumeA.fluidPort,simpleExpansionContaction.fluidPortA) annotation (Line(
        points = {
            {0, -70}, 
            {0, -10}},
        color = {0, 93, 152}));
    connect(volumeB.fluidPort,fluidPortB) annotation (Line(
        points = {
            {0, 70}, 
            {0, 100}},
        color = {0, 93, 152}));
    connect(simpleExpansionContaction.fluidPortB,volumeB.fluidPort) annotation (Line(
        points = {
            {0, 10}, 
            {0, 70}},
        color = {0, 93, 152}));

    annotation (
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(extent = {
                    {-30, -90}, 
                    {30, 0}}), 
                Rectangle(extent = {
                    {-50, 90}, 
                    {50, 0}}), 
                Text(
                    origin = {0, -68},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    extent = {
                        {-78, -20}, 
                        {78, 20}},
                    textString = "1"), 
                Text(
                    origin = {0, 68},
                    lineColor = {0, 0, 255},
                    fillColor = {0, 0, 255},
                    extent = {
                        {-78, -20}, 
                        {78, 20}},
                    textString = "2")}),
        Documentation(info = "<html>\n            <p>\n                The component ExpansionContraction is a model of a cross section enlargement (diffusor) or a cross section reduction (nozzle). It\n                depends on the flow direction.\n            </p>\n            <p>\n                The component computes the loss number zeta\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/Zeta.png\"></center>\n            </p>\n            <p>\n                 according to the following equations:\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Lines/ExpansionContractionExpansion.png\"></center>\n            </p>\n            <p>\n                 Borda-Carnot Equation\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Lines/ExpansionContractionZetaExpansion.png\"></center>\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Lines/ExpansionContractionContraction.png\"></center>\n            </p>\n            <p>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Lines/ExpansionContractionBeta.png\"></center>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Lines/ExpansionContractionMy.png\"></center>\n                <center><img align=\"middle\" src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Lines/ExpansionContractionZetaContraction.png\"></center>\n            </p>\n            <p>\n                Formulas are taken from E. Truckenbrodt, Fluidmechanik, Band 1: Grundlagen und elementare Str&ouml;mungsvorg&auml;nge dichtebest&auml;ndiger Fluide, 4. Auflage, 2008.\n            </p></html>"));
end ExpansionContraction;