Show
Ignore:
Timestamp:
05/06/08 16:35:36 (8 months ago)
Author:
rjrw
Message:

Further refactor newton_step to more purely numerical function.

Remove more dead or leftover code and data.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/newmole/source/mole_drive.cpp

    r2027 r2028  
    3232static const double MOLETOLER = 0.10; 
    3333 
    34 /*lgMolecSetup use previous iteration's converged solution to initialize if available */ 
    35 STATIC void MolecSetup (void); 
    3634STATIC void mole_effects(void); 
    3735STATIC void mole_h_rate_diagnostics(void); 
     
    4745        DEBUG_ENTRY( "mole_drive()" ); 
    4846 
    49         MolecSetup(); 
    50  
    5147        mole_update_species_cache();  /* Update densities of species controlled outside the chemical network */ 
    5248         
     
    6965 
    7066        mole_effects(); 
    71          
    72         return; 
    73 } 
    74  
    75 STATIC void MolecSetup(void) 
    76 { 
    77         long int i; 
    78         /* this will be used to rescale old saved abundances in constant pressure model */ 
    79         static realnum hden_save_prev_call; 
    80         const bool DEBUG_MOLECAVER = false; 
    81  
    82         DEBUG_ENTRY( "MolecSetup()" ); 
    83  
    84         /* mole_Init set this to -2 when code initialized, so negative 
    85          * number shows very first call in this model */ 
    86         /* >>chng 05 jul 15, do not init if we have never evaluated CO in this iteration 
    87          * and we are below limit where it should be evaluated */ 
    88         if( mole.iteration < 0 || true ) /* ???? */ 
    89         { 
    90  
    91                 /* very first attempt at ever obtaining a solution - 
    92                  * called one time per model since co.iteration_co set negative 
    93                  * when cdInit called */ 
    94                  
    95                 /* >>chng 05 jun 24, during map phase do not reset molecules to zero 
    96                  * since we probably have a better estimate right now */ 
    97                  
    98                 /* we should have a neutral carbon solution at this point */ 
    99                 //ASSERT( !dense.lgElmtOn[ipCARBON] || dense.xIonDense[ipCARBON][0]>SMALLFLOAT ); 
    100                                  
    101                 /* set iteration flag */ 
    102                 mole.iteration = iteration; 
    103                 mole.nzone = nzone; 
    104                  
    105                 /* for constant pressure models when molecules are reset on second 
    106                  * and higher iterations, total density will be different, so 
    107                  * must take this into account when abundances are reset */ 
    108                 hden_save_prev_call = dense.gas_phase[ipHYDROGEN]; 
    109                  
    110                 if( DEBUG_MOLECAVER ) 
    111                         fprintf(ioQQQ," DEBUG MolecSetup iteration %li zone %li zeroing since very first call. H2/H=%.2e\n",  
    112                                                         iteration,nzone,hmi.H2_total/dense.gas_phase[ipHYDROGEN]); 
    113         } 
    114         else if( iteration > mole.iteration ) 
    115         { 
    116                 realnum ratio = dense.gas_phase[ipHYDROGEN] / hden_save_prev_call; 
    117                  
    118                 /* this is first call on new iteration, reset 
    119                  * to first initial abundances from previous iteration */ 
    120                 for( i=0; i < mole.num_calc; i++ ) 
    121                 { 
    122                         mole.list[i]->den = mole.list[i]->den_reinit*ratio; 
    123                 } 
    124  
    125                 mole.iteration = iteration; 
    126                 mole.nzone = nzone; 
    127                  
    128                 if( DEBUG_MOLECAVER ) 
    129                         fprintf(ioQQQ," DEBUG MolecSetup iteration %li zone %li resetting since first call on new iteration. H2/H=%.2e\n",  
    130                                                         iteration, 
    131                                                         nzone, 
    132                                                         hmi.H2_total/dense.gas_phase[ipHYDROGEN]); 
    133         } 
    134         else if( iteration == mole.iteration && nzone==mole.nzone+1 ) 
    135         { 
    136                 /* this branch, second zone with solution, so save previous 
    137                  * zone's solution to reset things in next iteration */ 
    138                 for( i=0; i < mole.num_calc; i++ ) 
    139                 { 
    140                         mole.list[i]->den_reinit = (realnum) mole.list[i]->den; 
    141                 } 
    142                  
    143                 mole.nzone = -2; 
    144                 hden_save_prev_call = dense.gas_phase[ipHYDROGEN]; 
    145                  
    146                 if( DEBUG_MOLECAVER ) 
    147                         fprintf(ioQQQ,"DEBUG MolecSetup iteration %li zone %li second zone on new iteration, saving reset.\n", iteration,nzone); 
    148         } 
    14967         
    15068        return;