**Setting Variable Limits**

Some mathematical operations (such as square root, natural log, and others) can not be evaluated with a zero or negative argument, thereby causing EES to stop. This situation can arise when the equations representing the physical situation are not properly formulated. The situation can also arise for a correctly formulated set of equations, since the numerical algorithms in EES may attempt negative values during the iterative calculations needed to solve the equations. You can prevent an argument from becoming negative by setting the lower limit to zero with the Variable Info command.

In some problems, the argument is an expression rather than a single variable. For example, a log-mean temperature difference is often used in heat transfer problems. The log-mean temperature difference may be formulated as

DELTAT=((T_h_in-T_c_in)-(T_h_out-T_c_out)) / ln((T_h_in-T_c_in)/(T_h_out-T_c_out))

where T_h_in and T_h_out are the inlet and outlet temperature of the hot stream and T_c_in and T_c_out are the corresponding temperatures for the cold stream.

Two problems commonly arise in this situation. During the first iteration, both T_h_out and T_c_out may both have a value of 1 unless you have previously set their guess values to other values with the Variable Info command. A division by zero situation occurs and EES stops.

Second, the iteration process may produce an intermediate result in which the T_c_out is greater than T_h_out, resulting in a negative argument for the natural log function. To prevent this situation, you should assign a variable to the argument of the ln function and set its lower limit to zero. Thus the log-mean temperature difference would be better formulated as:

Arg = (T_h_in-T_c_in)/(T_h_out-T_c_out) {the lower limit of Arg is set to 1E-9}

DELTAT=((T_h_in-T_c_in)-(T_h_out-T_c_out)) / ln(Arg)

A similar strategy can be applied to other functions (such as the property functions) in which the range of allowable values is restricted.