Integration techniques: Impacts on Stock behavior

Use this forum to post Vensim related questions.
Post Reply
geo_curious
Member
Posts: 46
Joined: Tue Mar 14, 2023 2:05 am
Vensim version: DSS

Integration techniques: Impacts on Stock behavior

Post 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 226 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.
Administrator
Super Administrator
Posts: 4590
Joined: Wed Mar 05, 2003 3:10 am

Re: Integration techniques: Impacts on Stock behavior

Post by Administrator »

It's impossible to offer any advice without a model to look at.
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559
geo_curious
Member
Posts: 46
Joined: Tue Mar 14, 2023 2:05 am
Vensim version: DSS

Re: Integration techniques: Impacts on Stock behavior

Post 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.
aliakhavan89
Senior Member
Posts: 94
Joined: Sun Oct 21, 2018 7:09 am
Vensim version: DSS

Re: Integration techniques: Impacts on Stock behavior

Post 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.
geo_curious
Member
Posts: 46
Joined: Tue Mar 14, 2023 2:05 am
Vensim version: DSS

Re: Integration techniques: Impacts on Stock behavior

Post by geo_curious »

Thank you for the answer. It seems you understood quite clearly what I was asking.
tomfid
Administrator
Posts: 3811
Joined: Wed May 24, 2006 4:54 am

Re: Integration techniques: Impacts on Stock behavior

Post 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.
Post Reply