contents

decide_iter

Called by:  main each iteration.

Includes:   iscloc.h

External:
avg_weight_thresh    set in read_config
alpha_thresh        set in read_config
dalpha_thresh     set in read_config
dsigma_low      set in read_config
dsigma_high     set in read_config

Input arguments:
Pointer to solution structure.
Array of  phase structures.

Structure members updated:
converged or diverging in the solution structure.

Return:   0/1  for success/failure.

Each iteration, after a solution has been calculated, this function decides whether it has changed little enough from the previous solution to be considered to have converged.  It does this by calculating the change in sigma , the standard deviation of the weighted residuals, between this iteration and the previous one and comparing this change to thresholds imported from config.txt .  The absolute value of alpha , the average weighted residual, must also be below a certain threshold for convergence to decided.

A decision is also made as to whether the solution is drifting so badly that it can be considered to be diverging.  Divergence is implied if the average weight of the defining phases is above a certain threshold or if alpha has changed more than a given amount while sigma has decreased more than a given amount.

If this function decides that either of the above cases are true it sets the corresponding flag in the solution structure.