Page 1 of 1

Integration techniques: Impacts on Stock behavior

Posted: Sun Apr 14, 2024 10:41 pm
by geo_curious
Hi,

I recently switched my integration technique on an hourly simulation to RK2Auto. After looking more closely at the impacts on the model, I found significant errors. I understand that the RK methods are basically midpoint Euler steps, but I wonder why they are forcing a delay in integration within Vensim. Here is a very simple stock and flow. When the dimensionless value is above 0.88, then there is no inflow. When the dimensionless value is equal to or less than 0.88, it should immediately take in stock.
Shown:
Current - Euler
Current2 - RK2Auto
Current3 - RK2Fixed
TEST1.png
TEST1.png (11.77 KiB) Viewed 645 times
Can someone attempt a brief explanation on why this is impacting the actual behavior at timesteps? I have always thought, much like PDEs, these are supposed to take the midpoint integration at time X and then report the output at time X, rather than performing the midpoint integration at time X then reporting the output at time X+n. It seems I need to switch back to Euler, despite the inaccuracies, just to get the correct behavior at the time conditional statements are meant to integrate different inputs.

Re: Integration techniques: Impacts on Stock behavior

Posted: Mon Apr 15, 2024 7:06 am
by Administrator
It's impossible to offer any advice without a model to look at.

Re: Integration techniques: Impacts on Stock behavior

Posted: Mon Apr 15, 2024 11:15 pm
by geo_curious
I am not sure that this is impossible to answer. I am not asking anything about my model. Rather, why are the different integration techniques not affecting behavior at the same time step? The signal is entirely the same, offering a control which indicates the only problems are the integration techniques.

Re: Integration techniques: Impacts on Stock behavior

Posted: Tue Apr 16, 2024 1:57 pm
by aliakhavan89
I think RK methods calculate intermediate points and evaluate the function at these points before determining the state at the next timestep. If the threshold condition changes within a timestep, RK might miss the exact point of change because it's looking at the function at intermediate points (not necessarily where the condition changes), which can introduce a delay. RK2Auto shows a different behavior compared to RK2Fixed because the former dynamically adjusts the dt. You could have provided more details to get a more accurate response.

Re: Integration techniques: Impacts on Stock behavior

Posted: Tue Apr 16, 2024 3:35 pm
by geo_curious
Thank you for the answer. It seems you understood quite clearly what I was asking.

Re: Integration techniques: Impacts on Stock behavior

Posted: Sun Apr 21, 2024 1:22 pm
by tomfid
I think Aliakhavan89 is on the right track. However, it's impossible to give a precise answer without more information than the chart provides. What are the TIME STEP and SAVEPER? Presumably 12000 hours from eyeballing the chart? What is the equation for end use efficiency? A step * exponential? Or a stock with a pulse input and a first order outflow?

Some functions, like STEP and PULSE and DELAY FIXED, don't change within RK subintervals, which could affect behavior.