Jump to content

Using a previously calculated value for future calculation


Recommended Posts

Hi! I am trying to do a calculation of the residence time in a tank per hour based on a selection of parameters. In my formula I wish to use the previously calculated value for the residence time in the calculation for the next hour or calculation point. I tried using $signal.valueAt(now()-1h), however, I am not sure how to get this for every calculation point and not only for the last value. This might not be the best solution either so I would appreciate any advice. 

Additionally, I realize I will need a starting point for this formula. For this I have both a time and a value I can use, although I am not sure how to incorporate this into the formula.

Does anyone know if this is possible to do through SEEQ? Thanks in advance.

Link to comment
Share on other sites

Thank you for the response.

The challenge in this case is that the volume and flow in/out of the tank for which I am calculating the residence time are constantly changing. Occasionally, there is no flow in at all for up to a week or two, significantly affecting the residence time but not being taken into account through the traditional Volume/Flow. Basically, what my formula does is to estimate the average residence time (RT) for the fraction which has already been on the tank for x hours and the fraction which has just entered in the past hour. For simplicity, and since there is stirring on the tank, I assume a homogeneous mixture for the flow out of the tank. I figured estimating the residence time per hour should be enough. My final formula is:

RTaverage= ((RTold+RTnew)*amountold + (RTnew*amountnew)/2) / (amounttotal)

where RTold is RTaverage-1h (which is what I am struggling with expressing in my formula), RTnew is an hourly signal running regardless of conditions, amountold is the amount that was on the tank at the previous hour, and amountnew is the amount entering the tank for the past hour, and the amounttotal is the sum of amountold and amountnew.

At a certain point, the flow in was closed for approximately 2 weeks, and I figured this could serve as the starting point for the formula, providing an RTaverage starting point of 2 weeks. I am not sure how to incorporate this into the formula, or how to get the formula started seeing how it is dependent on a previously calculated point.

Link to comment
Share on other sites

  • 2 weeks later...
  • Administrators

Maren,

I recommend trying to avoid setting the problem up in a way that it depends on an initial value if you can. Initial values lead to excessive calculations because it will need to calculate from the initial value to your current window.  If finding the instantaneous residence time and averaging that over an hour is an option, it would be much more performant even when including mass weighted averaging.

If you still want to go down the initial value route you will want to look at the reduce() function in formula.

Regards,
Teddy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...