Notice: Undefined index: CraftSessionId in /var/www/html/web/forums/qa-external/qa-external-users.php on line 193
ON/OFF inflow or outflow similar to ON/OFF controller - Hydronumerics Q&A
0 votes
in AEM3D by mhmmd.madani@gmail.com (920 points)
Hello All,

Any idea of how to have ON/OFF outflow something similar to what we have in ON/OFF pump working cycle controller based on water level?

I want to have constant outflow in one boundary cell of lets day 20 m3/s when the water HEIGHT reach 1 m and by having outflow the HEIGHT reduce so, when HEIGHT reaches 0.5 m the outflow stop and it should wait until again HEIGHT build up to become 1 m again to start outflow again.

I don't want to have outflow when the HEIGHT build up a little more that 0.5 m and it should wait until the HEIGHT becomes 1 m again and then have outflow.

I tried to use GATE <n> TOP, GATE <n> BOTTOM and GATE <n> OPEN but it seems like I cannot use those boundary conditions for that purpose. I had no success in using INFLOW_MAXDEPTH and INFLOW_MINDEPTH too.

Any idea and advice would be highly appreciated.

Thanks,

Mohammad

1 Answer

+2 votes
by dallimor@hydronumerics.com.au (11.6k points)
Hi Mohammad,

This is a perfect scenario for a dynamic boundary condition.

Chris
by mhmmd.madani@gmail.com (920 points)
Hello Chris,
Any idea how to do it ?
by dallimor@hydronumerics.com.au (11.6k points)
Here's an example dynamic bc for a weir where the flow only begins once the height gets above 45.86m

You can replace the script with a simple constant 20 m3/s

<?xml version="1.0" encoding="UTF-8"?>
<AEM3DDynamicBC>
  <Variable>
    <name>h</name>
    <i>10</i>
    <j>15</j>
    <key>HEIGHT</key>
  </Variable>
  <Variable>
    <name>w</name>
    <key>CONSTANT</key>
    <constant>260</constant>
  </Variable>
  <Range_Variable>
    <name>h</name>
    <i>10</i>
    <j>15</j>
    <key>HEIGHT</key>
  </Range_Variable>
  <Range>
    <maxValue>45.86</maxValue>
    <script>0</script>
  </Range>
  <Range>
    <minValue>45.86</minValue>
    <maxValue>65.86</maxValue>
    <script>0.5*SQRT(2*9.81)*w*((h-45.86)**1.5)</script>
  </Range>
  <Range>
    <minValue>65.86</minValue>
    <script>5000</script>
  </Range>
  <bc>201</bc>
  <bc_key>OUTFLOW</bc_key>
</AEM3DDynamicBC>
by mhmmd.madani@gmail.com (920 points)
Hi Chris,
But ON/OFF pump control system is not like this!
I knew that code and similar thing is provided in the user manual, but the situation I am talking about is different.

In what you propose if the height is less than 45.86 the flow is 0 and if it is between 45.86 and 65.86 it calculate based on height and if it is higher than 65.86 it is 5000.

but the case that I am talking about is like this:

1- if h is higher than 0.5 and less than 1 and it is filling process   ---> outflow =0 because it should let the reservoir to fill.  

2- if h is higher than 1 the outflow start let say constant ouflow = 20 m3/s

3- if h is less than 1 and still higher than 0.5 --> outflow is still 20 m3/s  (this is in contrast with situation number 1), it should let the reservoir to empty out.

4- if h is less than 0.5 --> outflow =0 and let to fill again.


the code should know whether it is filling process or discharge process so we cannot just apply condition based on the height !

This is exactly how ON/OFF pumps work.


I hope you got my point.

Thanks
Mohammad
by dallimor@hydronumerics.com.au (11.6k points)
AEM3D does not store any historical information (as it would take up too much memory).  So there is no way to do this.

One option may be to use the DAY_OF_YEAR variable type if you know when this will happen.

  <Variable>
    <name>doy</name>
    <key>DAY_OF_YEAR</key>
    <constant>NaN</constant>
  </Variable>

And a script like

    <script>var result;
if (doy &lt; 219.79858796296296 || doy &gt; 221.75693287037038) {
  result = 4;
} else {;
  result = 0;
}
result;
</script>

Chris
by mhmmd.madani@gmail.com (920 points)
actually if we can have "if" syntax I think we can do it.

if we get HEIGHT and V_velocity in outlet as variable let say. "h" and "vel" and suppose that outflow is in negative direction of y axis, means if V_VELOCITY is negative value that means we have outflow otherwise we dont have outflow.
we can write the code like this.

<?xml version="1.0" encoding="UTF-8"?>
<AEM3DDynamicBC>
    <Variable>
        <name>h</name>
        <i>10</i>
        <j>15</j>
        <key>HEIGHT</key>
    </Variable>
    <Variable>
        <name>vel</name>
        <i>10</i>
        <j>15</j>
        <k>1</k>
        <key>V_VELOCITY</key>
    </Variable>
    <Range_Variable>
        <name>h</name>
        <i>10</i>
        <j>15</j>
        <key>HEIGHT</key>
    </Range_Variable>
    <Range>
        <maxValue>0.5</maxValue>
        <script>0</script>
    </Range>
    <Range>
        <minValue>0.5</minValue>
        <maxValue>1.0</maxValue>
        <script> var result;
        if (vel&eq;0 || vel&gt;0){          <!-- that means no outflow  -->
        result=0;
        } else{;
        result=20;
        }
        result;

        </script>
    </Range>
    <Range>
        <minValue>1.0</minValue>
        <script>20</script>
    </Range>
    <bc>201</bc>
    <bc_key>OUTFLOW</bc_key>
</AEM3DDynamicBC>



I am not whether my script is correct or not
by mhmmd.madani@gmail.com (920 points)
H higher than 1 we always have outflow
H less than 0.5 we always don't have outflow
In case H is between 0.5 and 1 :

if we have outflow at that time step (V_Velocity negative value) it should continue to outflow of 20.
if we do not have outflow at that time step (V_Velocity of zero) the outflow should remain 0.

That's it .

I think it should work
by dallimor@hydronumerics.com.au (11.6k points)
Sorry, I must still be jet-lagged, I copied that script from a file that doesn't work where I had confused AEM3D and Hydrohub scripts.

There is no way to use if statements in AEM3D scripts
by mhmmd.madani@gmail.com (920 points)
Thank you so much Chris,
OK no problem.
Yeah, you are right, I checked with ROUNLAKE example, it did not give me error when I use that script but it seems like it does not work at all.

Thank you for your time and quick replies. I hope one day we can add this feature to AEM3D

Cheers,
Mohammad
Welcome to Hydronumerics Q&A, where you can ask questions and receive answers about the software we develop and distribute

Categories

Hydronumerics

...