ValveEdgeTableQpx

model ValveEdgeTableQpx
    HydraulicsByFluidon.Components.Resistors.ResistorTableQpx ResistorTableQpx1(ReferenceDensity = ReferenceDensity, forwardFluidProperties = forwardFluidProperties, tableName = tableName, fileName = fileName, 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)));
    Modelica.SIunits.PressureDifference dp;
    Modelica.SIunits.VolumeFlowRate volumeFlowA;
    Modelica.SIunits.VolumeFlowRate volumeFlowB;
    parameter String fileName = "NoFile" "File where look-up table is stored"
        annotation (Dialog(
            group = "Look-up table definition Q(pA - pB, x)",
            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(group = "Look-up table definition Q(pA - pB, x)"));
    parameter Modelica.SIunits.Density ReferenceDensity = 860 "Reference density"
        annotation (Dialog(group = "Flow Parameters"));
    parameter Boolean forwardFluidProperties = true "Forward fluid properties between ports"
        annotation (Dialog(tab = "Fluid Properties"));
protected
    parameter Real inputMin = -1 "Minimum value of the input for look-up table";
equation
    connect(portA,ResistorTableQpx1.fluidPortA) annotation (Line(
        points = {
            {0, -90}, 
            {90, -90}, 
            {90, -8}, 
            {90, -8}, 
            {90, -8}},
        color = {0, 93, 152}));
    connect(portB,ResistorTableQpx1.fluidPortB) annotation (Line(
        points = {
            {0, 90}, 
            {90, 90}, 
            {90, 10}, 
            {90, 10}},
        color = {0, 93, 152}));
    dp = ResistorTableQpx1.dp;
    volumeFlowA = ResistorTableQpx1.volumeFlowA;
    volumeFlowB = ResistorTableQpx1.volumeFlowB;
    ResistorTableQpx1.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 ValveEdgeTableQpx is a model of an adjustable flow resistance which\n                is parameterized through a look-up table of the flow rate.\n            </p>\n            <p>\n                The look-up table provides the flow rate as a function of acting pressure difference (difference between \n                pressures ports A and B) and Input signal. Information regarding the formatting of the look-up table can be\n                found in the documentation of the component <a href=\"modelica://HydraulicsByFluidon.Components.Resistors.ResistorTableQpx\">ResistorTableQpx</a>. \n                Unlike the Resistor component, the look-up table for valveEdgeTableQpx is declared for the input range from -1 to 1.\n            </p>\n            </html>"));
end ValveEdgeTableQpx;