Show
Ignore:
Timestamp:
12/16/07 13:43:02 (11 months ago)
Author:
rjrw
Message:

More renaming of variables and moving other stuff to more logical places.

Promote struct mole_s to class Mole.

Location:
branches/newmole/source
Files:
24 modified

Legend:

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

    r1658 r1686  
    199199         * will confirm that these are converged */ 
    200200        EdenTrue_old = dense.EdenTrue; 
    201         EdenFromMolecOld = co.comole_eden; 
     201        EdenFromMolecOld = mole.elec; 
    202202        EdenFromGrainsOld = gv.TotalEden; 
    203203        HeatingOld = thermal.htot; 
     
    867867 
    868868        /* check on molecular electron den */ 
    869         if( fabs(EdenFromMolecOld - co.comole_eden)/dense.EdenTrue > conv.EdenErrorAllowed/2. ) 
     869        if( fabs(EdenFromMolecOld - mole.elec)/dense.EdenTrue > conv.EdenErrorAllowed/2. ) 
    870870        { 
    871871                conv.lgConvIoniz = false; 
     
    905905 
    906906        /* check on sum of grain and molecular electron den - often two large numbers that cancel */ 
    907         if( fabs( (EdenFromMolecOld-EdenFromGrainsOld) - (co.comole_eden-gv.TotalEden) )/dense.eden >  
     907        if( fabs( (EdenFromMolecOld-EdenFromGrainsOld) - (mole.elec-gv.TotalEden) )/dense.eden >  
    908908                conv.EdenErrorAllowed/4. ) 
    909909        { 
     
    911911                sprintf( conv.chConvIoniz, "edn grn e" ); 
    912912                conv.BadConvIoniz[0] = (EdenFromMolecOld-EdenFromGrainsOld); 
    913                 conv.BadConvIoniz[1] = (co.comole_eden-gv.TotalEden); 
     913                conv.BadConvIoniz[1] = (mole.elec-gv.TotalEden); 
    914914        } 
    915915 
  • branches/newmole/source/dynamics.cpp

    r1681 r1686  
    951951                                frac_next; 
    952952                        /* Atoms and positive ions are already counted in UpstreamElem */ 
    953                         if(COmole[mol]->n_nuclei != 1 || COmole[mol]->nElec < 0)  
     953                        if(COmole[mol]->n_nuclei != 1 || COmole[mol]->charge < 0)  
    954954                        { 
    955955                                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
     
    983983                { 
    984984                        Upstream_molecules[mol] = Old_molecules[ipUpstream][mol]/Old_density[ipUpstream]; 
    985                         if(COmole[mol]->n_nuclei > 1 || COmole[mol]->nElec < 0) 
     985                        if(COmole[mol]->n_nuclei > 1 || COmole[mol]->charge < 0) 
    986986                        { 
    987987                                for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
  • branches/newmole/source/eden_sum.cpp

    r1610 r1686  
    1818int eden_sum(void) 
    1919{ 
    20         long int i, 
     20        long int  
    2121          ion,  
    2222          nelem; 
     
    5454        dense.EdenTrue += sum_all_ions; 
    5555        ASSERT( dense.EdenTrue >= 0. ); 
    56  
    57         /* add on molecules */ 
    58         co.comole_eden = 0.; 
    59         for(i=0;i<mole.num_calc;i++) 
    60         { 
    61                 if (COmole[i]->n_nuclei > 1 || COmole[i]->nElec < 0) 
    62                         co.comole_eden += COmole[i]->hevmol*COmole[i]->nElec; 
    63         } 
    6456         
    6557#if 1 
     
    6961        /* >>chng 04 feb 20, recoil_ion.in shows this important, 
    7062         * update test so prevent neg eden */ 
    71         if( (-co.comole_eden) > dense.EdenTrue/4. && conv.lgSearch ) 
     63        if( (-mole.elec) > dense.EdenTrue/4. && conv.lgSearch ) 
    7264        { 
    7365                /*dense.EdenTrue += MIN2(dense.EdenTrue*0.05,hmole_eden);*/ 
    7466                dense.EdenTrue *= 0.9; 
    7567        } 
    76         else if( (-co.comole_eden) > dense.EdenTrue ) 
     68        else if( (-mole.elec) > dense.EdenTrue ) 
    7769        { 
    7870                /* >>chng 04 mar 14, add this branch to prevent 
     
    8173                fprintf(ioQQQ," PROBLEM sum eden from hmole too neg, set to  limt.  EdenTrue:%.3e hmole_eden:%.3e \n", 
    8274                        dense.EdenTrue,  
    83                         co.comole_eden); 
     75                        mole.elec); 
    8476                dense.EdenTrue = dense.EdenTrue/2.; 
    8577        } 
     
    8779        { 
    8880                /* account for electrons on all molecules */ 
    89                 dense.EdenTrue += co.comole_eden; 
     81                dense.EdenTrue += mole.elec; 
    9082        } 
    9183#else 
    92         dense.EdenTrue += co.comole_eden; 
     84        dense.EdenTrue += mole.elec; 
    9385#endif 
    9486 
     
    149141                  dense.EdenTrue ,  
    150142                  sum_all_ions , 
    151                   co.comole_eden , 
     143                  mole.elec , 
    152144                  gv.TotalEden*gv.lgGrainElectrons, 
    153145                  dense.EdenExtra , 
    154                   sum_all_ions + co.comole_eden + gv.TotalEden*gv.lgGrainElectrons + dense.EdenExtra, 
     146                  sum_all_ions + mole.elec + gv.TotalEden*gv.lgGrainElectrons + dense.EdenExtra, 
    155147                  rfield.otslin[2182] ); 
    156148 
  • branches/newmole/source/h2.h

    r1610 r1686  
    159159        long int Jlowest[N_H2_ELEC]; 
    160160 
     161        /** std and mean for the noise, log normal distribution */ 
     162        double xMeanNoise , xSTDNoise; 
     163 
     164        /** limit to the ratio H2/Htot - if ratio is below this, large atom is not called */ 
     165        double H2_to_H_limit; 
     166 
     167        /** the number of electronic quantum states to include. 
     168        * To do both Lyman and Werner bands want nelec = 3 */ 
     169        long int n_h2_elec_states; 
     170 
     171        /** this is option to use estimates of the collision rates from g-bar approximations */ 
     172        /** turn mole.lgColl_gbar on/off with atom h2 gbar on off */ 
     173        bool lgColl_gbar; 
     174 
     175        /** this is option to turn off the calculated collision rates */ 
     176        bool lgColl_deexec_Calc; 
     177 
     178        /** this is option to turn off guesses of collisional dissociation rates */ 
     179        bool lgColl_dissoc_coll; 
     180 
    161181        /* true to use 2007 set of H2 - H collision rate, false use 1999 */ 
    162182        bool lgH2_H_coll_07; 
    163183 
     184        /** include collision rates that come from real calculations, 
     185         * off with atom h2 collisions off command */ 
     186        bool lgH2_grain_deexcitation; 
     187 
     188        /** flag to force LTE level populations, atom H2 LTE */ 
     189        bool lgH2_LTE; 
     190 
     191        /** option to turn off ortho-para collisions, command ATOM H2 COLLISIONS ORTHO PARA OFF */ 
     192        bool lgH2_ortho_para_coll_on; 
     193 
     194        /** which set of He - H2 collisions to use? default is ORNL, other 
     195         * is Le BOURlet */ 
     196        bool lgH2_He_ORNL; 
     197 
     198        /** turn on trace information */ 
     199        int nH2_TRACE; 
     200 
     201        /** put noise into collision rates */ 
     202        bool lgH2_NOISE , 
     203                /** noise for the CR collisions */ 
     204                lgH2_NOISECOSMIC; 
     205 
     206        /** this sets how fine a trace we want for atom  h2 trace */ 
     207        int nH2_trace_final ,  
     208                nH2_trace_iterations ,  
     209                nH2_trace_full, 
     210                nH2_trace_matrix; 
     211         
    164212}       h2; 
    165213 
  • branches/newmole/source/hcmap.cpp

    r1610 r1686  
    235235 
    236236                /* this will force reinitialization of co network */ 
    237                 co.iteration_co = -2; 
     237                mole.iteration = -2; 
    238238 
    239239                /* now get ionization solution for this temperature */ 
  • branches/newmole/source/heat_sum.cpp

    r1610 r1686  
    118118        for( i=0; i < mole.num_calc; i++ ) 
    119119        { 
    120                 if(COmole[i]->n_nuclei > 1 || COmole[i]->nElec < 0) 
     120                if(COmole[i]->n_nuclei > 1 || COmole[i]->charge < 0) 
    121121                        AtomicCollidDensity += COmole[i]->hevmol; 
    122122        } 
  • branches/newmole/source/init_coreload.cpp

    r1610 r1686  
    1111#include "date.h" 
    1212#include "version.h" 
    13 #include "mole.h" 
     13#include "h2.h" 
    1414#include "extinc.h" 
    1515#include "heavy.h" 
     
    344344        /* these are used to set trace levels of output by options on atom h2 trace command  
    345345         * first is minimum level of trace, keyword is FINAL */ 
    346         mole.nH2_trace_final = 1; 
     346        h2.nH2_trace_final = 1; 
    347347        /* intermediate level of trace, info per iteration, key ITERATION */ 
    348         mole.nH2_trace_iterations = 2; 
     348        h2.nH2_trace_iterations = 2; 
    349349        /* full trace, keyword is FULL */ 
    350         mole.nH2_trace_full = 3; 
     350        h2.nH2_trace_full = 3; 
    351351        /* print matrices used in solving X */ 
    352         mole.nH2_trace_matrix = 4; 
     352        h2.nH2_trace_matrix = 4; 
    353353 
    354354        /* initialization for punch files - must call after input commands have 
  • branches/newmole/source/init_defaults_preparse.cpp

    r1610 r1686  
    1212#include "extinc.h" 
    1313#include "h2.h" 
    14 #include "mole.h" 
    1514#include "wind.h" 
    1615#include "thermal.h" 
     
    6968 
    7069        /* holds options for trace set with atom h2 command */ 
    71         mole.nH2_TRACE = false; 
     70        h2.nH2_TRACE = false; 
    7271 
    7372        /* option to scramble collision data */ 
    74         mole.lgH2_NOISE = false; 
    75         mole.lgH2_NOISECOSMIC = false;  
     73        h2.lgH2_NOISE = false; 
     74        h2.lgH2_NOISECOSMIC = false;  
    7675 
    7776        /* option to turn off or on gbar collisions of the collision rate, 
    7877        * default is to have it on */ 
    79         /* turn mole.lgColl_gbar on/off with atom h2 gbar on off */ 
    80         mole.lgColl_gbar = true; 
     78        /* turn h2.lgColl_gbar on/off with atom h2 gbar on off */ 
     79        h2.lgColl_gbar = true; 
    8180 
    8281        /* include collision rates that come from real calculations, 
    8382        * off with atom h2 collisions off command */ 
    84         mole.lgColl_deexec_Calc = true; 
    85  
    86         mole.lgColl_dissoc_coll = true; 
     83        h2.lgColl_deexec_Calc = true; 
     84 
     85        h2.lgColl_dissoc_coll = true; 
    8786 
    8887        /* option to turn off H2 - grain collision & deexcitation, 
    8988        * atom h2 grain collision on/off */ 
    90         mole.lgH2_grain_deexcitation = false; 
     89        h2.lgH2_grain_deexcitation = false; 
    9190 
    9291        /* option to turn off ortho-para collisions, command ATOM H2 COLLISIONS ORTHO PARA OFF */ 
    93         mole.lgH2_ortho_para_coll_on = true; 
     92        h2.lgH2_ortho_para_coll_on = true; 
    9493 
    9594        /* which set of H2 - He collision data to use?  default is Le Bourlot Meudon set, 
    9695        * set to ORNL with command 
    9796        * atom H2 He collisions ORNL */ 
    98         mole.lgH2_He_ORNL = true; 
     97        h2.lgH2_He_ORNL = true; 
    9998 
    10099        /* use 1999 or 2007 H2 - H collision set atomic data mole H2 h */ 
  • branches/newmole/source/init_sim_postparse.cpp

    r1658 r1686  
    2424        thermal.lgUnstable = false; 
    2525 
    26         mole_Init(); 
     26        mole.init(); 
    2727        mole_zero(); 
    2828 
  • branches/newmole/source/mole.h

    r1684 r1686  
    129129        double h2lim; 
    130130 
    131         long co_nzone , iteration_co; 
    132  
    133         /** total electron density in molecules */ 
    134         double comole_eden; 
    135  
    136131}       co; 
    137132 
    138 EXTERN struct t_mole { 
    139  
     133class Mole { 
     134 
     135        public: 
     136        void init(void); 
    140137                 
    141         /** limit to the ratio H2/Htot - if ratio is below this, large atom is not called */ 
    142         double H2_to_H_limit; 
    143  
    144         /** the number of electronic quantum states to include. 
    145         * To do both Lyman and Werner bands want nelec = 3 */ 
    146         long int n_h2_elec_states; 
    147  
    148         /** this is option to use estimates of the collision rates from g-bar approximations */ 
    149         /** turn mole.lgColl_gbar on/off with atom h2 gbar on off */ 
    150         bool lgColl_gbar; 
    151  
    152         /** this is option to turn off the calculated collision rates */ 
    153         bool lgColl_deexec_Calc; 
    154  
    155         /** this is option to turn off guesses of collisional dissociation rates */ 
    156         bool lgColl_dissoc_coll; 
    157  
    158         /** include collision rates that come from real calculations, 
    159          * off with atom h2 collisions off command */ 
    160         bool lgH2_grain_deexcitation; 
    161  
    162         /** flag to force LTE level populations, atom H2 LTE */ 
    163         bool lgH2_LTE; 
    164  
    165         /** option to turn off ortho-para collisions, command ATOM H2 COLLISIONS ORTHO PARA OFF */ 
    166         bool lgH2_ortho_para_coll_on; 
    167  
    168         /** which set of He - H2 collisions to use? default is ORNL, other 
    169          * is Le BOURlet */ 
    170         bool lgH2_He_ORNL; 
    171  
    172         /** turn on trace information */ 
    173         int nH2_TRACE; 
    174  
    175         /** put noise into collision rates */ 
    176         bool lgH2_NOISE , 
    177                 /** noise for the CR collisions */ 
    178                 lgH2_NOISECOSMIC; 
    179  
    180         /** this sets how fine a trace we want for atom  h2 trace */ 
    181         int nH2_trace_final ,  
    182                 nH2_trace_iterations ,  
    183                 nH2_trace_full, 
    184                 nH2_trace_matrix; 
    185          
     138        long nzone , iteration; 
     139 
    186140         /** do we include capture of molecules onto grain surfaces?  default is true, 
    187141          * turned off with NO GRAIN MOLECULES command */ 
    188142         bool lgGrain_mole_deplete; 
    189  
    190         /** std and mean for the noise, log normal distribution */ 
    191         double xMeanNoise , xSTDNoise; 
    192143 
    193144        /** flag saying whether an element is in the chemistry network */ 
     
    195146         
    196147        realnum eden_f, grain_area; 
     148 
     149        /** total charge in molecules */ 
     150        double elec; 
    197151 
    198152        /** these are source and sink terms for the ionization ladder, for chemical 
     
    205159                *snk; 
    206160        realnum ***xMoleChTrRate;/***[LIMELM][LIMELM+1][LIMELM+1];*/ 
    207 }       mole; 
     161}; 
     162 
     163extern Mole mole; 
    208164 
    209165enum {CHARS_SPECIES=7}; 
     
    214170        char  label[CHARS_SPECIES];      /** molecule name */ 
    215171        int   nElem[LIMELM];    /** number of each element in molecule */ 
    216         int   nElec;          /* Charge on species/number of e- liberated by formation */ 
     172        int   charge;          /* Charge on species/number of e- liberated by formation */ 
    217173        int   Excit;          /* Is species excited (e.g. H2*) */ 
    218174        bool  lgGas_Phase;    /** Solid or gas phase? */ 
  • branches/newmole/source/mole_co_drive.cpp

    r1658 r1686  
    178178         * to converge the molecules - there will be problems during initial 
    179179         * search so do not print anything in this case */ 
    180         lgFirstTry = (nzone==co.co_nzone && iteration==co.iteration_co); 
     180        lgFirstTry = (nzone==mole.nzone && iteration==mole.iteration); 
    181181 
    182182        /* did the molecule network have negative pops? */ 
     
    271271        /* >>chng 05 jul 15, do not init if we have never evaluated CO in this iteration 
    272272         * and we are below limit where it should be evaluated */ 
    273         if( iteration!=co.iteration_co &&  
     273        if( iteration!=mole.iteration &&  
    274274                        hmi.H2_total/dense.gas_phase[ipHYDROGEN] < h2lim ) 
    275275        { 
    276276                return; 
    277277        } 
    278         else if( co.iteration_co < 0 || lgMoleZeroed ) 
     278        else if( mole.iteration < 0 || lgMoleZeroed ) 
    279279        { 
    280280 
     
    290290                                 
    291291                /* set iteration flag */ 
    292                 co.iteration_co = iteration; 
    293                 co.co_nzone = nzone; 
     292                mole.iteration = iteration; 
     293                mole.nzone = nzone; 
    294294                 
    295295                /* for constant pressure models when molecules are reset on second 
     
    302302                                                        iteration,nzone,hmi.H2_total/dense.gas_phase[ipHYDROGEN]); 
    303303        } 
    304         else if( iteration > co.iteration_co ) 
     304        else if( iteration > mole.iteration ) 
    305305        { 
    306306                realnum ratio = dense.gas_phase[ipHYDROGEN] / hden_save_prev_call; 
     
    313313                } 
    314314 
    315                 co.iteration_co = iteration; 
    316                 co.co_nzone = nzone; 
     315                mole.iteration = iteration; 
     316                mole.nzone = nzone; 
    317317                 
    318318                if( DEBUG_MOLECAVER ) 
     
    322322                                                        hmi.H2_total/dense.gas_phase[ipHYDROGEN]); 
    323323        } 
    324         else if( iteration == co.iteration_co && nzone==co.co_nzone+1 ) 
     324        else if( iteration == mole.iteration && nzone==mole.nzone+1 ) 
    325325        { 
    326326                /* this branch, second zone with solution, so save previous 
     
    331331                } 
    332332                 
    333                 co.co_nzone = -2; 
     333                mole.nzone = -2; 
    334334                hden_save_prev_call = dense.gas_phase[ipHYDROGEN]; 
    335335                 
  • branches/newmole/source/mole_co_etc.cpp

    r1683 r1686  
    5151struct molecule **groupspecies; 
    5252 
     53Mole mole; 
     54 
    5355/*=================================================================*/ 
    54 /*CO_Init called from cdInit to initialize CO routines */ 
    55 void mole_Init(void) 
     56/*mole_Init called from cdInit to initialize CO routines */ 
     57void Mole::init(void) 
    5658{ 
    5759        long int i, 
     
    5961        struct molecule *sp; 
    6062        static realnum one=1.0; 
    61         static bool lgCO_Init_called=false; 
     63        static bool lgmole_Init_called=false; 
    6264 
    6365        DEBUG_ENTRY( "mole_Init()" ); 
     
    6567        /* these tell the molecular solver what zone and iteration it has 
    6668         * been evaluated on */ 
    67         co.co_nzone = -2; 
    68         co.iteration_co = -2; 
     69        mole.nzone = -2; 
     70        mole.iteration = -2; 
    6971 
    7072        /* prevent memory leaks */ 
    7173        /* \todo        this is a temporary fix for PR14. We should improve the overall design 
    7274         * of this code to prevent valid pointers being overwritten in a second call to mole_Init */ 
    73         if( lgCO_Init_called ) 
     75        if( lgmole_Init_called ) 
    7476        { 
    7577                return; 
     
    7779 
    7880        /* say that we have been called */ 
    79         lgCO_Init_called = true; 
     81        lgmole_Init_called = true; 
    8082 
    8183        for(nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) 
     
    227229        /* Add passive species to complete network */ 
    228230        sp = newspecies("e-    ",OTHER,MOLE_PASSIVE,&(mole.eden_f),0.00e+00, 0.0f); 
    229         sp->nElec = -1; sp->mole_mass = (realnum)ELECTRON_MASS; /* Augment properties for this non-molecular species */ 
     231        sp->charge = -1;        sp->mole_mass = (realnum)ELECTRON_MASS; /* Augment properties for this non-molecular species */ 
    230232        sp = newspecies("grn   ",OTHER,MOLE_PASSIVE,&(mole.grain_area),0.00e+00, 0.0f); 
    231233        sp = newspecies("PHOTON",OTHER,MOLE_PASSIVE,&one,0.00e+00, 0.0f); 
     
    317319                                } 
    318320                        } 
    319                         if(sp->nElec < N_MOLE_ION && sp->nElec >= 0)  
    320                         { 
    321                                 element_list[nelem]->ipMl[sp->nElec] = i; 
     321                        if(sp->charge < N_MOLE_ION && sp->charge >= 0)  
     322                        { 
     323                                element_list[nelem]->ipMl[sp->charge] = i; 
    322324                        } 
    323325                } 
     
    382384                mol->nElem[nelem] = 0; 
    383385        } 
    384         mol->nElec = mol->Excit = 0; 
     386        mol->charge = mol->Excit = 0; 
    385387        mol->mole_mass = 0.0; 
    386388        mol->state = state; 
     
    418420                                n = 1; 
    419421                        if(*s == '+') 
    420                                 mol->nElec = n; 
     422                                mol->charge = n; 
    421423                        else 
    422                                 mol->nElec = -n; 
     424                                mol->charge = -n; 
    423425                        *s = '\0'; 
    424426                } 
     
    653655        total_molecule_elems(dense.xMolecules);  
    654656 
     657        /* add on molecules */ 
     658        mole.elec = 0.; 
     659        for(i=0;i<mole.num_calc;i++) 
     660        { 
     661                if (COmole[i]->n_nuclei > 1 || COmole[i]->charge < 0) 
     662                        mole.elec += COmole[i]->hevmol*COmole[i]->charge; 
     663        } 
     664