Contents - Index
The $MaxCalls directive is only applicable when placed within a Function or Procedure. The format of the $MaxCalls directive is
where the number provided to the right of the equal sign is the maximum number of times the equations in the Function or Procedure will be called. If the calculations are done in a Parametric table, this number is the maximum number of times the equations in the Function or Procedure will be called for any row in the Parametric table. The number provided must be greater than 2.
Functions and Procedures can employ logic statements such as If-Then-Else and Repeat-Until. In some cases, use of these logic statements results in a repeated sequence of on/off decisions and convergence thereby becomes impossible. The $MaxCalls directive will eliminate such problems by placing an upper limit on the number of times the equations within the Function or Procedure are evaluated. If the number of calls to the Function or Procedure exceeds the specified limit, the Function / Procedure will return the same results as it did for the last valid call. This capability effectively prevents the logic statements from providing alternating values. Use of the $MaxCalls directive is not recommended unless a problem relating to the use of logic statements has been identified.
As example use of the $MaxCalls directive is provided in the following procedure. This procedure calculates the rate of useful energy gain (Q_dot_u) from a solar collector. If the rate of useful energy gas is calculated to be less than zero, its value is set to zero and the pump that circulates fluid through the solar collector is turned off by setting the collector mass flow rate (m_dot_col) to zero. Without the $MaxCalls directive, the use value of Q_dot_u can repeatedly switch from a slightly positive to a slightly negative value on occasion during the solving process causing a convergence error.
PROCEDURE COLLECTOR(A, FRTA, FRUL, G_T, T_bot, T_amb, m_dot_col_on, c : Q_dot_u, m_dot_col, T_col_out)
Q_dot_u = A * (FRTA * G_T - FRUL * (T_bot - T_amb))
m_dot_col = m_dot_col_on
T_col_out = T_bot + Q_dot_u / (m_dot_col_on* c)
if (Q_dot_u <= 0) then
m_dot_col = 0
T_col_out = T_bot
Q_dot_u = 0