AbruptAdaptor

model AbruptAdaptor "Pressure drop in pipe due to suddenly expanding or reducing area (for both flow directions)"
    extends BaseClasses.QuadraticTurbulent.BaseModelNonconstantCrossSectionArea(final data = BaseClasses.QuadraticTurbulent.LossFactorData.suddenExpansion(diameter_a, diameter_b));

    parameter SI.Diameter diameter_a "Inner diameter of pipe at port_a";
    parameter SI.Diameter diameter_b "Inner diameter of pipe at port_b";

    annotation (
        Diagram(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(points = {
                    {0, 40}, 
                    {-100, 40}, 
                    {-100, -40}, 
                    {0, -40}, 
                    {0, -100}, 
                    {100, -100}, 
                    {100, 100}, 
                    {0, 100}, 
                    {0, 40}}), 
                Rectangle(
                    extent = {
                        {-100, 40}, 
                        {0, -40}},
                    lineColor = {255, 255, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Rectangle(
                    extent = {
                        {0, 100}, 
                        {100, -100}},
                    lineColor = {255, 255, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Line(points = {
                    {0, 40}, 
                    {-100, 40}, 
                    {-100, -40}, 
                    {0, -40}, 
                    {0, -100}, 
                    {100, -100}, 
                    {100, 100}, 
                    {0, 100}, 
                    {0, 40}}), 
                Line(
                    points = {
                        {-60, -40}, 
                        {-60, 40}},
                    color = {0, 0, 255},
                    arrow = {Arrow.Filled, Arrow.Filled}), 
                Text(
                    extent = {
                        {-50, 16}, 
                        {-26, -10}},
                    lineColor = {0, 0, 255},
                    textString = "diameter_a"), 
                Line(
                    points = {
                        {34, -100}, 
                        {34, 100}},
                    color = {0, 0, 255},
                    arrow = {Arrow.Filled, Arrow.Filled}), 
                Text(
                    extent = {
                        {54, 16}, 
                        {78, -10}},
                    lineColor = {0, 0, 255},
                    textString = "diameter_b")}),
        Icon(
            coordinateSystem(
                preserveAspectRatio = false,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    extent = DynamicSelect({
                        {-100, 22}, 
                        {0, -22}}, {
                        {-100, max(0.1, min(1, diameter_a / max(diameter_a, diameter_b))) * 60}, 
                        {0, -max(0.1, min(1, diameter_a / max(diameter_a, diameter_b))) * 60}}),
                    fillPattern = FillPattern.HorizontalCylinder,
                    fillColor = {0, 127, 255}), 
                Rectangle(
                    extent = DynamicSelect({
                        {0, 60}, 
                        {100, -60}}, {
                        {0, max(0.1, min(1, diameter_b / max(diameter_a, diameter_b))) * 60}, 
                        {100, -max(0.1, min(1, diameter_b / max(diameter_a, diameter_b))) * 60}}),
                    fillPattern = FillPattern.HorizontalCylinder,
                    fillColor = {0, 127, 255})}),
        Documentation(info = "<html>\n\n</html>"));
end AbruptAdaptor;