This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to include Mass Transfer Coefficient into MSX

Hi Everyone,

We're currently working on developing an MSX model for Chlorine Decay that can account for wall decay as a factor of Biofilm growth (thus removing the need to specify wall decay for specific pipes throughout the network).

Unfortunately the equation for this relies on the mass transfer coefficient, which is dependent on the type of flow, as explained here: https://docs.bentley.com/LiveContent/web/Bentley%20WaterGEMS%20SS6-v1/en/GUID-D7D70292-50F6-4066-A30E-3B98BBB2BF7B.html.

This is built into the WaterGEMS standard pipe wall reaction calculations, however I need to know whether we can reference this coefficient in MSX, does anyone know whether this is possible? My understanding is that EPANET is capable of this so I assume WaterGEMS is capable as well, I just don’t know how.

For anyone wondering, the equations for Bulk decay are very simple. Below is a copy of what we use currently (no wall decay):

The Wall Decay equations are derived as follows (A&B are constants to be determined by trial and error, kw is what we need from WaterGEMS)

Thank you,

 Ryan

  • Ryan, what kind of real world system are you dealing with? For pretty much any water distribution system, you  never get into laminar flow. Plus with bends, partly open valves, crosses, tee, etc., you may still be in turbulent flow at low Reynolds numbers.

    Bulk reaction rates are usually higher than wall reactions and if wall reactions are that high, it may be that. pipes are very rough and turbulent.

    And there is so much uncertainty in wall reaction rates to start with.

    What is the practical use case where this really matters?

  • Hi Tom.

    We're attempting to model Chlorine Decay for the water reticulation network of a town of over 50,000 people and 750 km of water mains.

    Certainly, when chlorine residuals and dissolved organic compounds are high Bulk decay far outstrips wall decay. But when the water reaches the outer parts of the system, where the flows overnight are negligible (laminar) and the chlorine residual is below 0.5mg/L Biofilm growth starts to occur.

    This Biofilm growth consumes and lowers chlorine, which can lead to more biofilm growth, which leads to faster consumption of chlorine and so forth.

    These outer areas with low water flows, low chlorine and biofilm growth are our highest risk areas. We would like to be able to be able to account for that biofilm growth in the Chlorine decay model to provide indicative results that are at least somewhat reasonably reliable.

    It would also be great if pipe material and age were terms that could also be referenced in MSX, but you're right about the uncertainty in wall reaction rates for these variables so for the moment our primary concern is Biofilms.

  • Hi Ryan,

    I think there has been some confusion in this thread for which I apologize.

    The first thing to note is that the UDX route won't work, not because there is anything wrong with UDX (it's a cool feature), but because there is no way (currently) to plug in UDX fields into the input side of an MSX calculation. (It is possible to do that kind of thing for regular calculations with some programming knowledge, but that is outside the scope of this thread).

    So to re-iterate, it is definitely possible to do what you want using the TERMS feature of MSX just as I initially stated. I think I understand now that what you were missing is not that the terms can be defined as a function of Reynold's number (and other pre-defined variables), but how to apply different behaviors based on different value ranges of Reynolds Number (i.e., different flow regimes). It wasn't clear to me that this was the stumbling block based on the way I was reading your responses.

    The key to the application of different formulae to different value ranges of Reynolds Number, or indeed different value ranges of any different kind of variable is the STEP(x) function in MSX. An example of its usage is given on page 62 of the EPANET MSX 1.1 user manual, and it is described on page 63. If you think about it, a tool like MSX wouldn't have much value if this type of thing was not possible, since it would completely prevent the type of situation you are trying to model from being modeled.

    The step function works as follows (example only; this is not implementing the actual mass transfer coefficient equations you want, just demonstrating the general mechanism by which it can be achieved using MSX).

    Let's say that you had 3 flow regimes that you were interested in.

    1: Re <= 1.0e5
    2: 1.0e5 < Re <= 1.0e7
    3: Re > 1.0e7

    You could apply different sets of reaction equations subject to these three regimes.

    First to capture the different flow regimes, you could define new TERMS as follows.

    [TERMS]
    FR1 STEP(1.0e5 - Re) ; Re <= 1.0e5
    FR2 STEP(1.0e7 - Re) * (1 - FR1) ; Re <= 1.0e7
    FR3 STEP(1.0e9 - Re) * (1 - FR2) ; Re <= 1.0e9
    FR1M FR1
    FR2M FR2 * 10
    FR3M FR3 * 25

    The first three terms (FR1, FR2, and FR3) are the flow regimes. These terms evaluate to 1 or 0 depending on whether the pipe flow is within the defined range of Reynolds Number. These could be used directly to "turn on" (or off) various parts of a decay equation thus enabling the ability to define reaction rates that involve different equations for different flow regimes.

    The second three terms (FR1M, FR2M and FR3M) are simply terms (multipliers) that I created to demonstrate that the previous three terms work as expected. We will see how this works in a moment.

    Then to implement the regimes in the equations you simply write equations that leverage the previous terms. (In my example the FR1M, FR2M and FR3M terms; in your case the FR1 FR2 and FR3 terms).

    [PIPES]
    ;Free chlorine decay
    RATE CL2 FR1M*(-Ks20*TC*Cs*CL2-Kf20*TC*Cf*CL2-Km20*TC*Cm*CL2) + FR2M*(-Ks20*TC*Cs*CL2-Kf20*TC*Cf*CL2-Km20*TC*Cm*CL2)+ FR3M*(-Ks20*TC*Cs*CL2-Kf20*TC*Cf*CL2-Km20*TC*Cm*CL2)

    What I am doing above in my example is modifying the CL2 decay rate for pipes subject to the flow regime. The equation above, simplified is:

    RATE CL2 FR1M*Const + FR2M*Const + FR3M*Const, where Const is the result of all the terms that define the decay rate.

    (In my example I am using the same equation for each multiplier and increasing the decay rate by a factor, but in your case you would likely stick to multipliers of 0 and 1 (FR1, FR2, FR3) to turn on/off parts of the decay rate equation that do not apply to the specific flow regime).

    In my example, and referring to the simplified form of the equation, the outcomes are that:

    ...if the flow regime is such that Re < 1.0e5, then the decay rate is 1*Const.
    ...if the flow regime is such that Re > 1.0e5 and Re <= 1.0e7 then the decay rate is 10*Const
    ...if the flow regime is such that Re > 1.0e7 and Re <= 1.0e9 then the decay rate is 25*Const

    In other words, the higher the value of Re (subject to the stepwise evaluation within the defined ranges), the higher the decay rate.

    I know this is not the specific equations you want to implement, but it's illustrating the underlying mechanism by which you, or anyone else, can do it, subject to an arbitrary number of different ranges in Reynolds number (or any other variable or term), and making it easy to clearly demonstrate that it works (by exaggerating the effects).

    When I run the above equations in a model that uses the following combinations of multipliers...

    1. FR1M = 1, FRM2 = 10, FRM3 = 25
    2. FR1M = 1, FRM2 = 10, FRM3 = 50
    3. FR1M = 1, FRM2 = 25, FRM3 = 50

    ... it is easy to see that the decay in the modeled system in my test model does vary depending on the defined factors, and thus varies depending on the decay function applied for the specific flow regime under consideration. In other words the evaluation of the step function is working as intended.

    Given that MSX provides the ability for users to flexibly define their own constants, calculated terms and equations I am sure that the above is just one or many ways to approach this use case.

    The only thing left to do is for you to write the actual equations you wish to use and apply them to the ranges of Reynolds number that you deem relevant to your system. If you run into any issue where you cannot access information that you need to define a specific equation, then please feel free to post again.

    I hope this helps.

    Regards,
    Wayne.



    Answer Verified By: Ryan Catling 

  • Re: "It would also be great if pipe material and age were terms that could also be referenced in MSX,"

    Pipe material is not possible right now, but Age is. You could do this by modeling age as a species that does not grow or decay.

    [SPECIES]
    ; Age
    BULK Age MG

    [PIPES]
    RATE Age 1.0

    [TANKS]
    ;Age
    RATE Age 1.0

    [QUALITY]
    GLOBAL Age 24.0

    (The last part is just if you want to use an initial age... you can do that globally or by element).

    The units are just a label and can be ignored, especially if the purpose is just to calculate some other dependent value.

    In my test model this seems to have the desired outcome.

    Hope this helps.

    Regards,

    Wayne.