Show
Ignore:
Timestamp:
12/16/07 03:39:51 (11 months ago)
Author:
rjrw
Message:

Fix lines_supra.in (absolute values for abundances in rate matrix).

Enable abundance asserts for dynamics runs -- need to get these more
accurate.

Location:
branches/newmole/source
Files:
5 modified

Legend:

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

    r1653 r1680  
    77        long int nelem, ion; 
    88        bool lgOK=true; 
    9  
    10         if (dynamics.lgAdvection) 
    11         { 
    12                 // Switch off invariant checks for dynamics -- better to 
    13                 // work out broader invariant which applies here... 
    14                 fixit();  
    15                 return true; 
    16         } 
    179 
    1810        /* this checks that all molecules and ions add up to gas phase abundance 
  • branches/newmole/source/mole_eval_balance.cpp

    r1652 r1680  
    9090                                if(i!=j) 
    9191                                { 
    92                                         rate_deriv[i] *= rate->reactants[j]->hevmol; 
    93                                 } 
    94                         } 
    95                 } 
    96                  
    97                 rate_tot = rate_deriv[0]*rate->reactants[0]->hevmol; 
     92                                        rate_deriv[i] *= fabs(rate->reactants[j]->hevmol); 
     93                                } 
     94                        } 
     95                } 
     96                 
     97                rate_tot = rate_deriv[0]*fabs(rate->reactants[0]->hevmol); 
    9898                 
    9999                for(i=0;i<rate->nreactants;i++) 
  • branches/newmole/source/mole_newton_step.cpp

    r1676 r1680  
    194194                 
    195195                /* add positive ions and neutral atoms: ratios are set by ion_solver, 
    196                  * we determine sum of two here */ 
     196                 * we determine abundance of the group as a whole here */ 
    197197                 
    198198                if (loop == 0) { 
  • branches/newmole/source/pressure_total.cpp

    r1610 r1680  
    7070                pmx; 
    7171        realnum den_hmole , 
    72                 DenseAtomsIons, 
    73                 DensElements; 
     72                DenseAtomsIons; 
    7473 
    7574        DEBUG_ENTRY( "PresTotCurrent()" ); 
     
    132131        TempChange(phycon.te , false); 
    133132 
    134         /* find total number of atoms and ions */ 
    135         DenseAtomsIons = 0.; 
    136         DensElements = 0.; 
    137         realnum factor = 1.1f; 
    138         if( conv.lgSearch ) 
    139                 factor = 2.f; 
    140         for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
    141         { 
    142                 /* only check element solution if it is on, and ionization  
    143                  * has not been set with TABLE ELEMENT command */ 
    144                 if( dense.lgElmtOn[nelem]  ) 
    145                 { 
    146                         /* gas_phase is density of all atoms and ions, but not molecules */ 
    147                         DensElements += dense.gas_phase[nelem]; 
    148                         realnum DenseOne = 0; 
    149                         for( ion=0; ion<=nelem+1; ++ion ) 
    150                                 DenseOne += dense.xIonDense[nelem][ion]; 
    151  
    152                         /* during search phase sums may not add up correctly, and during 
    153                          * early parts of search phase may be badly off.  This test  
    154                          * was introduced as result off fpe due to another 
    155                          * reason - Te had changed too much during initial search 
    156                          * for sim in which chemistry was important - fix was to not 
    157                          * let Te change.  During resulting insanity caused by large 
    158                          * change, linearization did not work, CO and ionization solvers 
    159                          * could diverge leading to molecule or ionization population 
    160                          * larger than 1e38 limit to a realnum, fpe followed.  this is to 
    161                          * catch that in its early stages */ 
    162                         ASSERT( conv.nTotalIoniz<5 || dense.lgSetIoniz[nelem] || 
    163                                 DenseOne <= dense.gas_phase[nelem]*factor ); 
    164                         DenseAtomsIons += DenseOne; 
    165                 } 
    166         } 
    167         /* DensElements is sum of all gas-phase densities of all elements, 
    168          * DenseAtomsIons is sum of density of atoms and ions, does not  
    169          * include molecules */ 
    170         ASSERT( conv.nTotalIoniz<5 || DenseAtomsIons <= DensElements*factor ); 
    171         ASSERT( DenseAtomsIons > 0. ); 
     133        ASSERT(lgElemsConserved()); 
    172134 
    173135        /* evaluate the total ionization energy on a scale where neutral atoms 
     
    203165         * never set and only appears in print statements */ 
    204166        phycon.EnergyBinding = 0.; 
     167 
     168        /* find total number of atoms and ions */ 
     169        DenseAtomsIons = 0.; 
     170        for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
     171        { 
     172                /* only check element solution if it is on, and ionization  
     173                 * has not been set with TABLE ELEMENT command */ 
     174                if( dense.lgElmtOn[nelem]  ) 
     175                { 
     176                        /* gas_phase is density of all atoms and ions, but not molecules */ 
     177                        for( ion=0; ion<=nelem+1; ++ion ) 
     178                                DenseAtomsIons += dense.xIonDense[nelem][ion]; 
     179                } 
     180        } 
     181        /* DensElements is sum of all gas-phase densities of all elements, 
     182         * DenseAtomsIons is sum of density of atoms and ions, does not  
     183         * include molecules */ 
     184        ASSERT( DenseAtomsIons > 0. ); 
    205185 
    206186        /* find number of molecules of the heavy elements in the gas phase.  
  • branches/newmole/source/rt_line_one_tauinc.cpp

    r1610 r1680  
    4848 
    4949                        /* sanity check - total fine opacity should be greater than single ine opacity */ 
    50                         ASSERT( fabs(dTau_line) < 0.01 ||  
     50                        ASSERT( fabs(dTau_line) < 0.01 || wind.windv != 0 || 
    5151                                rfield.fine_opac_zone[t->Emis->ipFine]*1.1 >= opacity*t->Emis->PopOpc  ); 
    5252                }