DecayDraining a stock with a given average residence time 
This information is part of the Business Simulation Library (BSL).
The stock connected to port A (stockA) will be gradually drained at a rate determined by the average time of residence (residenceTime
) in the stock. The rate which drains the stock (draining
) is given by:
draining = stockA.y / residenceTime
The residence time is clipped to never be smaller than the global parameter dt
.
The process of decay is essentially exponential decline, since the outflow is a fraction of the stock. The rate of decay thus also exponentially declines towards zero if there is no inflow to the stock, that is connected to port A.
If there is no inflow to the stock the level of the stock will be less than α x InitialLevel (0 < α <1) after a time span of  ln(α) × residenceTime.
So we can note the following multiples for the residenceTime
to calculate the time it takes to drain the stock A to α [%] of its initial level:
α [%]  Time to drain as multiple of the residenceTime 
50 
0.69 ⋅ 
1/e ≈ 37 
1.0 ⋅ 
10 
2.3 ⋅ 
5 
3.0 ⋅ 
1 
4.6 ⋅ 
0.1 = 1 ‰ 
6.9 ⋅ 
The time span it takes to drain the stock by half is called its half life. As can be seen from the equation and table above it is about ln(2) ⋅ residenceTime
≈ 69% of the (average) residence time.
residenceTime 
Value: unspecified Type: Time (s) Description: Constant time of average residence (optional) 

hasConstantResidenceTime 
Value: false Type: Boolean Description: = true, if the parameter residenceTime will be used instead of the continuous input u 
portA 
Type: FlowPort Description: Flow from/to Stock A 


portB 
Type: FlowPort Description: Flow to/from Stock B 

y 
Type: RealOutput Description: Rate information 

y1 
Type: RealOutput Description: Rate information 

y2 
Type: RealOutput Description: Rate information 

u 
Type: RealInput Description: Residence time input 
levelA 
Type: FlowPortSensor Description: Report the amount in the connected stock (Port A) 


parDelayTime 
Type: ConstantConverterTime Description: Constant delay time (optional) 

clippedResidenceTime 
Type: ClipProcessTime Description: Residence time may not be smaller than dt 

indicatedRate 
Type: Division 

draining 
Type: Transition Description: Flow from stock A to stock B 
BusinessSimulation.SourcesOrSinks A stock is drained at a rate proportional to its content 
unspecified
in v2.1.0.