ValveEdgeTableAx

model ValveEdgeTableAx
    HydraulicsByFluidon.Components.Resistors.ResistorTableAx idealResistorVariable1(forwardFluidProperties = forwardFluidProperties, manualTable = manualTable, tableFromFile = tableFromFile, tableName = tableName, fileName = fileName, alphaD = alphaD, inputMin = inputMin) annotation (Placement(
        visible = true,
        transformation(
            origin = {90, 0},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
    Modelica.Blocks.Interfaces.RealInput Input annotation (Placement(
        visible = true,
        transformation(
            origin = {-80, 80},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0),
        iconTransformation(
            origin = {-80, 80},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0)));
    Modelica.Blocks.Interfaces.RealInput Offset annotation (Placement(
        visible = true,
        transformation(
            origin = {-80, -80},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0),
        iconTransformation(
            origin = {-80, -80},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0)));
    Modelica.Blocks.Interfaces.RealInput InputMax annotation (Placement(
        visible = true,
        transformation(
            origin = {-80, 0},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0),
        iconTransformation(
            origin = {-80, 0},
            extent = {
                {-20, -20}, 
                {20, 20}},
            rotation = 0)));
    HydraulicsByFluidon.Interfaces.FluidPort portA annotation (Placement(
        visible = true,
        transformation(
            origin = {0, -90},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0),
        iconTransformation(
            origin = {0, -90},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
    HydraulicsByFluidon.Interfaces.FluidPort portB annotation (Placement(
        visible = true,
        transformation(
            origin = {0, 90},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0),
        iconTransformation(
            origin = {0, 90},
            extent = {
                {-10, -10}, 
                {10, 10}},
            rotation = 0)));
    parameter Boolean forwardFluidProperties = true "Forward fluid properties between ports";
    Modelica.SIunits.PressureDifference dp;
    Modelica.SIunits.VolumeFlowRate volumeFlowA;
    Modelica.SIunits.VolumeFlowRate volumeFlowB;
    parameter Boolean tableFromFile = false "Table is provided by file"
        annotation (Dialog(tab = "Flow Parameters"));
    parameter String fileName = "NoFile" "File where look-up table is stored"
        annotation (Dialog(
            tab = "Flow Parameters",
            loadSelector(
                filter = "Text files (*.txt);;MATLAB MAT-files (*.mat)",
                caption = "Open file in which table is present")));
    parameter String tableName = "NoName" "Table name on file"
        annotation (Dialog(tab = "Flow Parameters"));
    parameter Real manualTable[:,:] = [0,0; 1,2.444e-5] "Manually provided look-up table"
        annotation (Dialog(
            tab = "Flow Parameters",
            enable = not tableFromFile));
    parameter Real alphaD = 0.6 "Flow coefficient alphaD"
        annotation (Dialog(tab = "Flow Parameters"));
protected
    parameter Real inputMin = -1 "Minimum value of the input for look-up table"
        annotation (Dialog(tab = "Flow Parameters"));
equation
    connect(portA,idealResistorVariable1.fluidPortA) annotation (Line(
        points = {
            {0, -90}, 
            {90, -90}, 
            {90, -8}, 
            {90, -8}, 
            {90, -8}},
        color = {0, 93, 152}));
    connect(portB,idealResistorVariable1.fluidPortB) annotation (Line(
        points = {
            {0, 90}, 
            {90, 90}, 
            {90, 10}, 
            {90, 10}},
        color = {0, 93, 152}));
    dp = idealResistorVariable1.dp;
    volumeFlowA = idealResistorVariable1.volumeFlowA;
    volumeFlowB = idealResistorVariable1.volumeFlowB;
    idealResistorVariable1.u = if InputMax - Offset == 0 then Input - Offset else (Input - Offset) / (InputMax - Offset);

    annotation (
        Icon(
            coordinateSystem(initialScale = 0.1),
            graphics = {
                Line(
                    origin = {0, 0},
                    points = {
                        {-80, -20}, 
                        {80, 20}}), 
                Polygon(
                    origin = {82, 32},
                    fillPattern = FillPattern.Solid,
                    points = {
                        {-6, -6}, 
                        {14, -6}, 
                        {-2, -20}, 
                        {-6, -6}}), 
                Line(
                    origin = {30, 0},
                    rotation = 90,
                    points = {
                        {-40, -10}, 
                        {0, 20}, 
                        {40, -10}}), 
                Line(
                    origin = {0, 0},
                    points = {
                        {0, -80}, 
                        {0, 80}}), 
                Line(
                    origin = {-30, 0},
                    rotation = -90,
                    points = {
                        {-40, -10}, 
                        {0, 20}, 
                        {40, -10}})}),
        Documentation(info = "<html>\n            <p>\n                The component ValveEdgeTableAx is a model of a flow resistance that behaves like an orifice.\n            </p>\n            <p>\n                The parameterization of the ValveEdgeTableAx is done by providing the <var>Flow coefficient alphaD</var> and a \n                look-up table of the <var>Cross-sectional area</var> as a function of the input signal. Further information \n                regarding the formatting of the look-up table can be found in the documentation of the component \n                <a href=\"modelica://HydraulicsByFluidon.Components.Resistors.ResistorTableAx\">ResistorTableAx</a>. \n                Unlike the Resistor component, the look-up table for valveEdgeTableAx is declared for the input range from -1 to 1.\n            <p>\n                The flow rate is calculated based on <var>Flow coefficient alphaD</var>, <var>Cross-sectional area</var>, \n                density of the fluid and pressure difference between the two edges of the valve, according to the formula given below:\n            </p>\n            <p>\n                <center><img align=\"middle\" src= \"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/TurbulentFlow.png\"></center>\n            </p>\n            <p>\n                By variation in input signal, the cross sectional area of the valve edge is changed which in turn changes the flow through the valve edge.\n            </p>           \n            </html>"));
end ValveEdgeTableAx;