Ticket #135: rt.diff

File rt.diff, 5.2 kB (added by gary, 2 years ago)

redo RT update within level2 and level3 solvers in attempt to make consistent

  • atom_level2.cpp

     
    1212#include "rfield.h" 
    1313#include "thermal.h" 
    1414#include "cooling.h" 
     15#include "conv.h" 
     16#include "doppvel.h" 
     17#include "rt.h" 
    1518#include "atoms.h" 
    1619 
    1720void atom_level2(transition * t) 
     
    9396                return; 
    9497        } 
    9598 
     99        // update RT quantities to keep them synched with level populations 
     100        if( conv.nTotalIoniz && !conv.lgLastSweepThisZone ) 
     101                RT_line_one( t, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     102 
    96103        /* net rate down A21*(escape + destruction) */ 
    97104        a21 = t->Emis->Aul*(t->Emis->Pesc+ t->Emis->Pdest + t->Emis->Pelec_esc); 
    98105 
  • atom_level3.cpp

     
    44#include "cddefines.h" 
    55#include "phycon.h" 
    66#include "physconst.h" 
     7#include "conv.h" 
     8#include "doppvel.h" 
     9#include "rt.h" 
    710#include "dense.h" 
    811#include "transition.h" 
    912#include "thermal.h" 
     
    168171                TotalInsanity(); 
    169172        } 
    170173 
     174        long nelem; 
    171175        /* abundances from the elements grid 
    172176         * one of these must be a true line */ 
    173177        if( g010 > 0. ) 
    174178        { 
    175179                /* put null terminated line label into chLab using line array*/ 
    176180                chIonLbl(chLab, t10); 
     181                nelem = t10->Hi->nelem; 
    177182                AbunxIon = dense.xIonDense[ t10->Hi->nelem -1][t10->Hi->IonStg-1]; 
    178183        } 
    179184 
     
    181186        { 
    182187                /* put null terminated line label into chLab using line array*/ 
    183188                chIonLbl(chLab, t21); 
     189                nelem = t21->Hi->nelem; 
    184190                AbunxIon = dense.xIonDense[t21->Hi->nelem -1][t21->Hi->IonStg-1]; 
    185191        } 
    186192 
     
    198204        c = t20->EnergyK*phycon.teinv; 
    199205 
    200206        if( c == 0. ) 
    201         { 
    202207                c = a + b; 
    203         } 
    204208 
    205209        /* if still neg at end, then success!, so possible to 
    206210         * to check why zero returned */ 
     
    209213        /* if two of the lines are below the plasma frequency, hand the third in atom_level2 */ 
    210214        if( ( t10->EnergyErg/EN1RYD < rfield.plsfrq && t20->EnergyErg/EN1RYD < rfield.plsfrq ) ) 
    211215        { 
     216                // update RT quantities to keep them synched with level populations 
     217                if( conv.nTotalIoniz && !conv.lgLastSweepThisZone ) 
     218                        RT_line_one( t21, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
    212219                atom_level2( t21 ); 
    213220                return; 
    214221        } 
    215222        else if( ( t10->EnergyErg/EN1RYD < rfield.plsfrq && t21->EnergyErg/EN1RYD < rfield.plsfrq ) ) 
    216223        { 
     224                // update RT quantities to keep them synched with level populations 
     225                if( conv.nTotalIoniz && !conv.lgLastSweepThisZone ) 
     226                        RT_line_one( t20, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
    217227                atom_level2( t20 ); 
    218228                return; 
    219229        } 
    220230        else if( ( t20->EnergyErg/EN1RYD < rfield.plsfrq && t21->EnergyErg/EN1RYD < rfield.plsfrq ) ) 
    221231        { 
     232                // update RT quantities to keep them synched with level populations 
     233                if( conv.nTotalIoniz && !conv.lgLastSweepThisZone ) 
     234                        RT_line_one( t10, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
    222235                atom_level2( t10 ); 
    223236                return; 
    224237        } 
     
    314327        ASSERT( (t20->Hi->nelem * t21->Hi->nelem == 0) || (t20->Hi->nelem == t21->Hi->nelem) ); 
    315328 
    316329        ASSERT( o10 > 0. && o21 > 0. && o20 > 0. ); 
    317  
    318330        /*end sanity checks */ 
    319331 
    320332        /* net loss of line escape and destruction */ 
     
    335347                temp12 = t21->EnergyK; 
    336348                temp02 = t20->EnergyK; 
    337349                temp01 = temp02 - temp12; 
     350 
     351                // update RT quantities to be in sync with level populations 
     352                RT_line_one( t21, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     353                RT_line_one( t20, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
    338354        } 
    339355 
    340356        else if( a21 == 0. ) 
     
    348364                temp02 = t20->EnergyK; 
    349365                temp01 = t10->EnergyK; 
    350366                temp12 = temp02 - temp01; 
     367                // update RT quantities to be in sync with level populations 
     368                if( conv.nTotalIoniz && !conv.lgLastSweepThisZone ) 
     369                { 
     370                        RT_line_one( t10, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     371                        RT_line_one( t20, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     372                } 
    351373        } 
    352374 
    353375        else if( a20 == 0. ) 
     
    361383                temp01 = t10->EnergyK; 
    362384                temp12 = t21->EnergyK; 
    363385                temp02 = temp01 + temp12; 
     386                // update RT quantities to be in sync with level populations 
     387                if( conv.nTotalIoniz && !conv.lgLastSweepThisZone ) 
     388                { 
     389                        RT_line_one( t21, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     390                        RT_line_one( t10, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     391                } 
    364392        } 
    365393 
    366394        else 
     
    375403                temp02 = t20->EnergyK; 
    376404                temp01 = t10->EnergyK; 
    377405                temp12 = t21->EnergyK; 
     406                // update RT quantities to be in sync with level populations 
     407                if( conv.nTotalIoniz && !conv.lgLastSweepThisZone ) 
     408                { 
     409                        RT_line_one( t21, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     410                        RT_line_one( t10, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     411                        RT_line_one( t20, true,0.f, GetDopplerWidth(dense.AtomicWeight[nelem-1]) ); 
     412                } 
    378413        } 
    379414 
    380415        /* check all energies positive */ 
  • cool_dima.cpp

     
    5353                        } 
    5454                        /* now put the cs into the line array */ 
    5555                        PutCS(cs,&TauLine2[i] ); 
    56                         RT_line_one( &TauLine2[i], true,0.f, GetDopplerWidth(dense.AtomicWeight[TauLine2[i].Hi->nelem-1]) ); 
    5756                        atom_level2(&TauLine2[i] ); 
    5857                } 
    5958        }