ValveEdge

model ValveEdge
    HydraulicsByFluidon.Components.Resistors.IdealResistorVariable idealResistorVariable1(NominalVolumeFlow = NominalVolumeFlow, NominalPressureDifference = NominalPressureDifference, ReferenceDensity = ReferenceDensity, forwardFluidProperties = forwardFluidProperties, ZeroVolumeFlow = ZeroVolumeFlow, ZeroFlowPressureDifference = ZeroFlowPressureDifference, tableFromFile = tableFromFile, fileName = fileName, tableName = tableName, manualTable = manualTable, 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 Modelica.SIunits.VolumeFlowRate NominalVolumeFlow = 5e-4 "Nominal volume flow";
    parameter Modelica.SIunits.Pressure NominalPressureDifference = 500000 "Nominal pressure difference";
    parameter Modelica.SIunits.Density ReferenceDensity = 860 "Reference density for volume flow and pressure difference";
    parameter Modelica.SIunits.VolumeFlowRate ZeroVolumeFlow = 0 "Volume flow due to leakage";
    parameter Modelica.SIunits.Pressure ZeroFlowPressureDifference = 500000 "Pressure difference for leakage flow";
    parameter Boolean tableFromFile = false "Table is provided by file";
    parameter String fileName = "NoFile" "File where look-up table is stored";
    parameter String tableName = "NoName" "Table name on file";
    parameter Real manualTable[:,:] = [-1,0; 0,0; 1,1] "Manually provided look-up table";
    parameter Boolean forwardFluidProperties = true "Forward fluid properties between ports";
    Modelica.SIunits.PressureDifference dp;
    Modelica.SIunits.VolumeFlowRate volumeFlowA;
    Modelica.SIunits.VolumeFlowRate volumeFlowB;
protected
    parameter Real inputMin = -1 "Minimum value of the input for look-up table";
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 ValveEdge is a model of a flow resistance that behaves either as an orifice or a throttle, depending on the parameter setting.\n            </p>\n            <p>\n                Flow is adjusted proportional to the <i>Input signal</i> starting from <var>Minimum value of the input for look-up table</var> with nominal flow (as given by <var>nominal flow</var>/<var>nominal pressure difference</var>) corresponding to an input value of <i>InputMax</i>. Unlike the Resistor component, the look-up table for valveEdge is declared for the input range from -1 to 1. \n            </p>\n            <p>\n                <i>Input</i> is shifted by <i>Offset</i> with within +/- 1. In accordance with common valve parameters a negative offset will open the valve edge.\n            </p>\n            <p>\n                Leakage is specified by <var>Volume flow due to leakage/Pressure difference for leakage flow</var>, this flow is permanent \n                and the overall flow of the valve edge is calculated as max(<var>Nominal volume flow</var>, <var>Volume flow due to leakage</var>). \n            </p>\n            <p>\n                The default relationship between input signal and flow rate of the resistor is linear, but can be changed through the use of a 1D look-up table. \n                The look-up table is provided either manually or by importing a text file. If the parameter <var>Table is provided by file</var> is set to <i>false</i>, the \n                manually entered datapoints from <var>Manually provided look-up table</var> will be used. If it is set to <i>true</i>, the table <var>Table name on file</var> \n                from the file <var>File where look-up table is stored</var> will be utilized. \n            </p> \n            <p>\n                The text file must follow a specific syntax such that it can be read by Modelica. The input values as well as the output values must lie within \n                the range from 0 to 1. An output value of 1 (100 %) corresponds to a fully-opened resistor. An example for a properly formatted text file with \n                two tables is given in the figure below: \n            </p>\n            <p>\n                <center><img src=\"modelica://HydraulicsByFluidon/Resources/Images/Components/Resistors/ModelicaTableIdealResistorVariable.png\" width=\"300\"></center>\n            </p>\n            <p>\n                A table is declared by its datatype (e. g. double), followed by the table name (e. g. tab1) and its dimensions in brackets (e. g. (5,2)). As can \n                be seen, multiple tables can be defined in the same text file. The table declaration is followed by the actual data. The first column of the table \n                represents the input of the 1D table, whereas the second column lists the corresponding output values. The input values of the table must be in \n                increasing order. The component interpolates linearly between the listed input values. More information regarding the format of tables can be found \n                at <a href=\"modelica://Modelica.Blocks.Tables.CombiTable1D\">CombiTable1D</a>.\n            </p>\n            </html>"));
end ValveEdge;