OpenWaterAnalytics / EPANET

The Water Distribution System Hydraulic and Water Quality Analysis Toolkit
MIT License
279 stars 204 forks source link

Wrong response of FCV whit minor loss coefficient when open #695

Closed fmartine closed 1 year ago

fmartine commented 2 years ago

Flow control valves (FCV) operate by sensing the pressure drop across an orifice upstream or downstream of the main plug. See here.

image

The pressure drop across the orifice depends on the square of the flow rate. As long as this loss is below a certain value, the valve remains open. But when the threshold is exceeded (set by the tension of a spring), the excess differential pressure acts on the main obturator to cause an additional loss, so that the flow rate through the valve does not exceed the preset limit (or rather, so that the differential pressure in the orifice does not exceed a limit value).

The operation of an FCV is therefore not understood without assigning it an open state loss coefficient (the orifice loss coefficient), which, moreover, usually has a high value (assuming a value of 0 for this coefficient in an FCV would be a very theoretical case).

Let us now construct a very simple example, configured by two reservoirs with elevations 30 m and 0 m, connected by two pipes of length 1000 m, diameter 200 mm and C = 100 (LPS units). Between the two pipes, a FCV of diameter 200 mm is placed. We initially assign a minor loss coefficient ko = 0 and open the valve. We observe a theoretical maximum flow rate of 41.85 l/s, and heads of 15 m at both ends of the valve.

We now assign a value ko = 50 (somewhat high), and with the valve open the maximum flow rate is reduced to 38.83 l/s, the upstream head becomes 16.95 m and downstream 13.05 m, with a valve head loss of 3.90m. Clearly, for the actual valve, no more flow than 38.83 l/s can pass.

We now activate the valve with a setpoint of 40 l/s, maintaining ko = 50, and EPANET responds confirming this flow, with a head of 16.20 m upstream and 13.80 m downstream, and a loss of 2.41 m at the valve. This is in contradiction with the maximum flow rate allowed for ko = 50. Clearly, the value of ko is not being taken into account when imposing the flow rate setpoint.

LRossman commented 2 years ago

Another way to view the contradiction in @fmartine 's example is to compute the effective loss coefficient that the FCV has when it delivers 40 l/s in the EPANET solution. For a valve diameter of 200 mm and a head loss of 2.41 m this turns out to be 29.14. This is below the open valve loss coefficient of 50 that was assigned to the valve and is therefore impossible to achieve.

Comparing the FCV's effective loss coefficient against its fully open coefficient can eliminate incorrect solutions. The fcvstatus function in status.c has been modified to do this as shown below (note that Kmhas been adjusted previously by a factor of 2gA^2 so it can work with flow rather than velocity):

StatusType  fcvstatus(Project *pr, int k, StatusType s, double h1, double h2)
{
. . .
    else if (status == ACTIVE)
    {
        double dh = h1 - h2;
        double q = hyd->LinkFlow[k];
        double kq = dh / q / q;
        if (kq < pr->network.Link[k].Km) status = XFCV;
    }        
    return status;
}

Making this code change allowed EPANET to correctly solve @fmartine 's example as seen by the attached Status Report. statusrpt.txt

fmartine commented 2 years ago

Thank you Lew for your quick and effective response. As far as I am concerned, the problem has been solved, so I propose to close this issue.

I have many more issues to raise in order to gradually improve the robustness and capabilities of the Toolkit and at the same time bring it closer to the real world, i.e, to the Digital Twins.

fmartine commented 2 years ago

Continuing with the same example, I have now checked that the coefficient of minor losses at the open valve is correctly taken into account for all other valves, except for TCVs.

For an open PRV with ko = 50 the downstream pressure is 13.05 m. If an attempt is made to force a pressure between 15 (ko = 0) and 13.05 the valve opens and does not allow it.

For an open PSV with ko = 50 the upstream pressure is 16.95 m. If an attempt is made to force a pressure between 16.95 and 15 (ko = 0) the valve opens and does not allow it.

Both cases work correctly as expected since the algorithm is well described in paragraph 13 of the EPANET Implementation section of the new manual. By the way, paragraph 15 of the same section will have to be modified to take into account the Hml for FCV.

For the PBVs the minor losses at the open valve are also correctly taken into account. For ko = 50 these are 16.95 - 13.05 = 3.90 m. If the valve is activated with a pressure drop of less than 3.90 m it does not act and remains open.

However, for the TCVs the value of ko is not being taken into account. If activated with a value k < 50, the valve acts causing losses lower than 3.90 m. Perhaps because it is the simplest case it was overlooked.

LRossman commented 2 years ago

I believe that for a TCV the "setting" loss coefficient is meant to override any minor loss coefficient that was specified, meaning that the latter is only used when the valve Status is set to OPEN, while the former is used otherwise even if it has a lower value. I don't think this warrants any change as long as a user understands this convention. Making a change could possibly break backward compatibility for many networks.

fmartine commented 2 years ago

I understand that a valve cannot have losses lower than those corresponding to an open valve. This concept is being applied to the remaining valves. If a user wants to simulate the behaviour of a TCV for any value of k he would have to assign ko = 0 for open valve.

My only concern is to reproduce in the future with the toolkit the reality as it is, allowing certain academic licenses such as assuming ko =0. The only argument that convinces me is to keep the compatibility with previous versions.

LRossman commented 1 year ago

This issue was resolved with PR #696 and can now be closed.