Changeset 2185

Show
Ignore:
Timestamp:
07/09/08 12:05:44 (6 months ago)
Author:
peter
Message:

source/conv_itercheck.cpp:

Use safe way to check for convergence (see PR73).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/conv_itercheck.cpp

    r2133 r2185  
    7070                                        { 
    7171                                                /* test if Lya converged, nLyaLevel is upper level of Lya for iso seq */ 
    72                                                 if( fabs(Transitions[ipISO][nelem][iso.nLyaLevel[ipISO]][0].Emis->TauTot/ 
    73                                                         (Transitions[ipISO][nelem][iso.nLyaLevel[ipISO]][0].Emis->TauIn*rt.DoubleTau)-1.) >  
    74                                                         conv.autocv ) 
     72                                                if( fabs(Transitions[ipISO][nelem][iso.nLyaLevel[ipISO]][0].Emis->TauTot - 
     73                                                         Transitions[ipISO][nelem][iso.nLyaLevel[ipISO]][0].Emis->TauIn*rt.DoubleTau) >  
     74                                                    conv.autocv*fabs(Transitions[ipISO][nelem][iso.nLyaLevel[ipISO]][0].Emis->TauIn*rt.DoubleTau) ) 
    7575                                                { 
    7676                                                        /* not converged to within AUTOCV, normally 15 percent */ 
     
    9393                                                } 
    9494 
    95                                                 if( fabs(Transitions[ipISO][nelem][ipHi][ipLo].Emis->TauTot/ 
    96                                                         (Transitions[ipISO][nelem][ipHi][ipLo].Emis->TauIn*rt.DoubleTau)-1.) > conv.autocv ) 
     95                                                if( fabs(Transitions[ipISO][nelem][ipHi][ipLo].Emis->TauTot - 
     96                                                         Transitions[ipISO][nelem][ipHi][ipLo].Emis->TauIn*rt.DoubleTau) > 
     97                                                    conv.autocv*fabs(Transitions[ipISO][nelem][ipHi][ipLo].Emis->TauIn*rt.DoubleTau) ) 
    9798                                                { 
    9899                                                        /* not converged to within AUTOCV, normally 15 percent */ 
     
    122123                for( i=0; i<NCOLD; ++i ) 
    123124                { 
    124                         double differ = fabs(colden.colden_old[i]-colden.colden[i]) / 
    125                                 SDIV(colden.colden[i]); 
    126125                        /* was the species column density significant relative to 
    127126                         * the total H column density, and was its abundance changing? */ 
    128                         if( (colden.colden[i]/colden.colden[ipCOL_HTOT] > 1e-5) && 
    129                                 (differ > conv.autocv) ) 
     127                        if( colden.colden[i]/colden.colden[ipCOL_HTOT] > 1e-5 && 
     128                            fabs(colden.colden_old[i]-colden.colden[i]) > conv.autocv*colden.colden[i] ) 
    130129                        { 
    131130                                /* not converged to within conv.autocv, normally 20 percent */ 
     
    151150                for( i=0; i<mole.num_comole_calc; ++i ) 
    152151                { 
    153                         double differ; 
    154152                        if(COmole[i]->n_nuclei == 1) 
    155153                                continue; 
    156154 
    157155                        /* was the species abundance and changing? */ 
    158                         differ = (double)fabs(COmole[i]->hevcol_old-COmole[i]->hevcol) / 
    159                                 (double)SDIV(COmole[i]->hevcol); 
    160                         if( (COmole[i]->hevcol/colden.colden[ipCOL_HTOT] > 1e-5) && 
    161                                 (differ > conv.autocv) ) 
     156                        if( COmole[i]->hevcol/colden.colden[ipCOL_HTOT] > 1e-5 && 
     157                            fabs(COmole[i]->hevcol_old-COmole[i]->hevcol) > conv.autocv*COmole[i]->hevcol ) 
    162158                        { 
    163159                                /* not converged to within conv.autocv, normally 20 percent */ 
     
    182178                if( dynamics.lgAdvection ) 
    183179                { 
    184                         double error1 = dynamics.convergence_error / SDIV(dynamics.error_scale2); 
    185                         double error2 = dynamics.discretization_error / SDIV(dynamics.error_scale2); 
    186180                        /* >>chng 02 nov 29, as per Will Henney email */ 
    187                         if( MAX2(error1/dynamics.convergence_tolerance, error2 ) > conv.autocv ) 
    188                         /*if( MAX2(error1, error2 ) > conv.autocv )*/ 
     181                        if( dynamics.convergence_error > conv.autocv*dynamics.error_scale2*dynamics.convergence_tolerance || 
     182                            dynamics.discretization_error > conv.autocv*dynamics.error_scale2 ) 
    189183                        { 
    190184                                lgConverged = false;