Appendix A. Mathematical Model of Flowing Tank Farm Simulation

Appendix A. Mathematical Formulation of the Predictive Flow Control Algorithm

Appendix A. Mathematical Formulation of the Predictive Flow Control Algorithm

This appendix presents the mathematical formulation of the predictive flow control algorithm implemented in the RpFlowing simulation component of the Petroleum Refining Library (PRL). The controller predicts the availability of both source and receiving tank farms and continuously determines the maximum sustainable outlet flow while respecting operational constraints.

This appendix presents the mathematical model of the Flowing Tank Farm simulation algorithm described in the article Flowing Tank Farm Simulation for Refinery Digital Twin Models .

A.1 Assumptions

  • Only one tank can be filled or discharged at a time.
  • Pipeline transportation delay is neglected.
  • The receiving tank farm has limited storage capacity.
  • The outlet flow is constrained by hydraulic limits.
  • The controller evaluates both source and receiving tank availability before updating the outlet flow.

A.2 Allowable Outlet Flow Range

The controller first determines the allowable outlet flow interval.

$$ V_{1,out,max,1}(t)= \max \left( V_{1,out}(t-1)+dV,\; V_{1,out,min} \right) $$
(2.1)

Maximum flow allowed by the flow ramp constraint.

$$ V_{1,out,max,2}(t)= V_{1,max} $$
(2.2)

Maximum pump capacity.

$$ V_{1,out,max,s}(t)= \min \left( V_{1,out,max,1}(t), V_{1,out,max,2}(t) \right) $$
(2.3)

Upper allowable outlet flow.

$$ V_{1,out,min,1}(t)= \max \left( V_{1,out}(t-1)-dV,\; V_{1,out,min} \right) $$
(2.4)

Minimum flow allowed by the flow ramp constraint.

$$ V_{1,out,min,2}(t)= V_{1,min} $$
(2.5)

Minimum pump operating flow.

$$ V_{1,out,min,s}(t)= \max \left( V_{1,out,min,1}(t), V_{1,out,min,2}(t) \right) $$
(2.6)

Lower allowable outlet flow.

A.3 Prediction of Source Tank Availability

The controller predicts the waiting time for every source tank.

$$ D_{1,i}(t)= C_1+R+ \frac{ S_{1,max}-S_i(t) }{ V_{mid} } $$
(2.7)

Waiting time for a tank currently being filled.

  • C1 — certification duration;
  • R — safety time reserve;
  • Vmid — estimated average filling rate.
$$ D_{1,i}(t)= C_1+R- D_{1i}(t) $$
(2.8)

Waiting time for a tank undergoing certification.

$$ D_{1,i}(t)= S $$
(2.9)

Unavailable tanks are assigned a sufficiently large waiting time.

$$ D_{1,min}(t)= \min_{i=1..Q} D_{1,i}(t) $$
(2.10)

The smallest waiting time determines the next available source tank.

$$ V_{1,max}(t)= \frac{ S_{1,k}(t)-S_{1,min} }{ D_{1,min}(t) } $$
(2.11)

Maximum sustainable outlet flow determined by the source tank farm.

A.4 Prediction of Receiving Tank Availability

The same procedure is applied to the receiving tank farm.

$$ D_{2,j}(t)= \frac{ S_{2,j}(t)-S_{2,min} }{ V_{2,out}(t) } $$
(2.12)

Remaining unloading time for a tank in the shipment state.

$$ D_{2,j}(t)= Delay_2 + R - D_{2j}(t) + \frac{ S_{2,j}(t)-S_{2,min} }{ V_{2,out}(t) } $$
(2.13)

Waiting time for a tank undergoing certification.

  • Delay2 — certification duration;
  • D2j — elapsed certification time;
  • R — safety reserve.
$$ D_{2,min}(t)= \min_{j=1..U} D_{2,j}(t) $$
(2.14)

The receiving tank with the minimum waiting time is selected.

$$ V_{2,max}(t)= \frac{ S_{2,l}(t)-S_{2,min} }{ D_{2,min}(t) } $$
(2.15)

Maximum sustainable receiving flow.

A.5 Target Outlet Flow

The controller combines the predictions obtained for both tank farms.

$$ V_{out,g}(t)= \min \left( V_{1,max}(t), V_{2,max}(t) \right) $$
(2.16)

The governing outlet flow is determined by the most restrictive tank farm.

$$ V_{1,out}(t)= \left\{ \begin{array}{ll} V_{max}, & V_{out,g}>V_{max} \\ V_{min}, & V_{out,g}<V_{min} \\ V_{out,g}, & V_{min}\le V_{out,g}\le V_{max} \end{array} \right. $$
(2.17)

The outlet flow is finally limited to the allowable operating range.

Notation

Symbol Description
\(V_{1,in}\) Inlet flow rate of the source tank farm.
\(V_{1,out}\) Outlet flow rate of the source tank farm.
\(V_{2,in}\) Inlet flow rate of the receiving tank farm.
\(V_{2,out}\) Outlet flow rate of the receiving tank farm.
\(V_{max}\) Maximum allowable outlet flow.
\(V_{min}\) Minimum allowable outlet flow.
\(dV\) Maximum flow variation during one control interval.
\(S\) Tank inventory.
\(S_{min}\) Minimum allowable inventory.
\(S_{max}\) Maximum allowable inventory.
\(C\) Certification duration.
\(Delay\) Remaining certification time.
\(R\) Safety time reserve.
\(D\) Predicted waiting time until tank availability.
\(Q\) Number of source tanks.
\(U\) Number of receiving tanks.

Summary

The predictive flow control algorithm forms the mathematical basis of the RpFlowing simulation component implemented in the Petroleum Refining Library (PRL) for AnyLogic. The controller continuously predicts tank availability, evaluates inventory constraints, and automatically selects the maximum sustainable outlet flow, thereby minimizing transfer interruptions while respecting hydraulic and storage limitations.