Show
Ignore:
Timestamp:
12/16/07 11:29:33 (11 months ago)
Author:
rjrw
Message:

Eliminate coreactions list in favour of iterator on reaction table.

Location:
branches/newmole/source
Files:
4 modified

Legend:

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

    r1682 r1683  
    278278        /* ...first active species */ 
    279279        i = 0; 
    280         for (map<string,struct molecule *>::iterator p 
     280        for (molecule_i p 
    281281                                 =mole_priv.spectab.begin(); p != mole_priv.spectab.end(); p++)  
    282282        { 
     
    290290                                mole_cmp); 
    291291 
    292         for (map<string,struct molecule *>::iterator p 
     292        for (molecule_i p 
    293293                                 =mole_priv.spectab.begin(); p != mole_priv.spectab.end(); p++)  
    294294        { 
     
    531531struct molecule *findspecies(const char buf[]) 
    532532{ 
    533         map<string,struct molecule *>::iterator p; 
     533        molecule_i p; 
    534534 
    535535        DEBUG_ENTRY("findspecies()"); 
     
    545545STATIC struct chem_element_s *findelement(const char buf[]) 
    546546{ 
    547         map<string,struct chem_element_s *>::iterator p; 
     547        chem_element_i p; 
    548548 
    549549        DEBUG_ENTRY("findelement()"); 
     
    559559struct mole_reaction_s *mole_findrate_s(const char buf[]) 
    560560{ 
    561         map<string,struct mole_reaction_s *>::iterator p; 
     561        mole_reaction_i p; 
    562562 
    563563        DEBUG_ENTRY("mole_findrate_s()"); 
     
    672672double mole_sink_rate(const char chSpecies[7]) 
    673673{ 
    674         int ipthis, i, n, nt; 
     674        int ipthis, i; 
    675675        double ratev, ratevi; 
    676676        struct mole_reaction_s *rate; 
     
    681681        sp = findspecies(chSpecies); 
    682682        ratev = 0; 
    683         nt = coreactions.n; 
    684  
    685         for(n=0;n<nt;n++)  
    686         { 
    687                 rate = coreactions.list[n]; 
     683 
     684        for(mole_reaction_i p=mole_priv.reactab.begin();  
     685                        p != mole_priv.reactab.end(); p++)  
     686        { 
     687                rate = p->second; 
    688688                ipthis = -1; 
    689689                for(i=0;i<rate->nreactants && ipthis == -1;i++) 
     
    729729void mole_update_rks(void) 
    730730{ 
    731         int n, nt; 
    732731        struct mole_reaction_s *rate; 
    733732 
     
    740739        hmole_reactions(); 
    741740         
    742         nt = coreactions.n; 
    743  
    744         for(n=0;n<nt;n++)  
    745         { 
    746                 rate = coreactions.list[n]; 
     741        for (mole_reaction_i p 
     742                                 =mole_priv.reactab.begin(); p != mole_priv.reactab.end(); p++)  
     743        { 
     744                rate = p->second; 
    747745                if(rate->fun != NULL) { 
    748746                        rate->rk = rate->a*rate->fun(rate); 
     
    753751double mole_dissoc_rate(const char chSpecies[7]) 
    754752{ 
    755         int ipsp, ipph, i, n, nt; 
     753        int ipsp, ipph, i; 
    756754        double ratev, ratevi; 
    757755        struct mole_reaction_s *rate; 
     
    763761        ph = findspecies("PHOTON"); 
    764762        ratev = 0; 
    765         nt = coreactions.n; 
    766  
    767         for(n=0;n<nt;n++)  
    768         { 
    769                 rate = coreactions.list[n]; 
     763 
     764        for (mole_reaction_i p 
     765                                 =mole_priv.reactab.begin(); p != mole_priv.reactab.end(); p++)  
     766        { 
     767                rate = p->second; 
    770768                 
    771769                ipph = 0; 
     
    807805double mole_source_rate(const char chSpecies[7]) 
    808806{ 
    809         int ipthis, i, n, nt; 
     807        int ipthis, i; 
    810808        double ratev, ratevi; 
    811809        struct mole_reaction_s *rate; 
     
    816814        sp = findspecies(chSpecies); 
    817815        ratev = 0; 
    818         nt = coreactions.n; 
    819  
    820         for(n=0;n<nt;n++)  
    821         { 
    822                 rate = coreactions.list[n]; 
     816 
     817        for (mole_reaction_i p 
     818                                 =mole_priv.reactab.begin(); p != mole_priv.reactab.end(); p++)  
     819        { 
     820                rate = p->second; 
    823821                ipthis = 0; 
    824822                for(i=0;i<rate->nproducts;i++) 
     
    855853         */ 
    856854 
    857         long int  nt, n, i; 
     855        long int  i; 
    858856        struct mole_reaction_s *rate; 
    859857        double rate_tot, heating; 
    860858        realnum reaction_enthalpy; 
    861859         
    862         nt = coreactions.n; 
    863          
    864860        heating = 0; 
    865861        /* loop over all reactions */ 
    866         for(n=0;n<nt;n++)  
    867         {                
    868                 rate = coreactions.list[n]; 
     862        for (mole_reaction_i p 
     863                                 =mole_priv.reactab.begin(); p != mole_priv.reactab.end(); p++)  
     864        { 
     865                rate = p->second; 
    869866                /* This loop calculates the product of the rate constant times the densities*/ 
    870867                rate_tot = rate->rk; 
     
    904901                                                                        bool lgData, double depth) 
    905902{ 
    906         int n, nt, i, ipthis; 
     903        int i, ipthis; 
    907904        double ratevi; 
    908905        struct mole_reaction_s *rate; 
     
    922919        } 
    923920                 
    924         nt = coreactions.n; 
    925         for(n=0;n<nt;n++) { 
    926                 rate = coreactions.list[n]; 
     921        for (mole_reaction_i p 
     922                                 =mole_priv.reactab.begin(); p != mole_priv.reactab.end(); p++)  
     923        { 
     924                rate = p->second; 
    927925                ipthis = 0; 
    928926                for (i=0;i<rate->nreactants;i++) 
  • branches/newmole/source/mole_eval_balance.cpp

    r1680 r1683  
    3232void mole_eval_balance(long int num_total, double *b, double **c) 
    3333{ 
    34         long int i, j, n, nt, nelem, ratei, ratej, ion, ion2; 
     34        long int i, j, nelem, ratei, ratej, ion, ion2; 
    3535        struct mole_reaction_s *rate, *ratesnk=NULL, *ratesrc=NULL; 
    3636        double rate_tot, rate_deriv[MAXREACTANTS], rated, rk; 
     
    7777        /* Fills matrix elements for passive species -- these can be used to 
    7878                 derive sources & sinks resulting from this part of the network */ 
    79         nt = coreactions.n; 
    80         for(n=0;n<nt;n++)  
    81         { 
    82                 rate = coreactions.list[n]; 
     79        for(mole_reaction_i p=mole_priv.reactab.begin();  
     80                        p != mole_priv.reactab.end(); p++)  
     81        { 
     82                rate = p->second; 
    8383                rk = rate->rk; 
    8484                 
  • branches/newmole/source/mole_priv.h

    r1682 r1683  
    1313        map <string,double (*)(struct mole_reaction_s *rate)> functab; 
    1414} mole_priv; 
     15typedef map<string,struct mole_reaction_s *>::iterator mole_reaction_i; 
     16typedef map<string,struct molecule *>::iterator molecule_i; 
     17typedef map<string,struct chem_element_s *>::iterator chem_element_i; 
    1518 
    1619extern struct molecule **groupspecies; 
    1720 
    1821extern struct molecule *null_mole; 
    19  
    20 EXTERN struct t_coreactions { 
    21         struct mole_reaction_s **list; 
    22         long int n; 
    23 } coreactions; 
    2422 
    2523#define MAXREACTANTS 3 
  • branches/newmole/source/mole_reactions.cpp

    r1682 r1683  
    4040 
    4141enum {UDFA = 0}; /* UDFA = 1 for: make UDFA comparison and stop */ 
    42  
    43 /* Structures containing reaction data */ 
    44 struct t_coreactions coreactions; 
    4542 
    4643STATIC void newreact(const char label[],  
     
    146143 
    147144        long int i; 
    148         /* Initialize number of reactions added to list in coreactions of reactions 
    149            treated by new methodology, incremented by newreact() */ 
    150145 
    151146        DEBUG_ENTRY("mole_create_react()"); 
     
    153148        if (UDFA) 
    154149                read_data("rate05_feb17.csv",parse_udfa); 
    155  
    156         coreactions.n = 0;  
    157150 
    158151        /* Set up registry of rate functions -- could do something intelligent about 
     
    415408        } 
    416409 
    417         /* Create linear list of reactions ... */ 
    418         if (coreactions.n != 0) 
    419         { 
    420                 coreactions.list =  (struct mole_reaction_s **) 
    421                         MALLOC((size_t)coreactions.n*sizeof(struct mole_reaction_s *)); 
    422         } 
    423         else 
    424         { 
    425                 coreactions.list = NULL; 
    426         } 
    427  
    428         /* ...and populate it */ 
    429         i = 0; 
    430         for (map<string,struct mole_reaction_s *>::iterator p 
    431                                  =mole_priv.reactab.begin(); p != mole_priv.reactab.end(); p++)  
    432         { 
    433                 coreactions.list[i++] = p->second; 
    434         } 
    435         ASSERT (i == coreactions.n);  
    436  
    437410        if (0)  
    438411                plot_sparsity(); 
     
    462435        struct molecule    *sp; 
    463436        ratefunc func; 
    464         map <string,struct mole_reaction_s *>::iterator p; 
     437        mole_reaction_i p; 
    465438        int i,j,k,exists; 
    466439        char buf[NBUF]; 
     
    653626                free(p->second); 
    654627        } 
    655         else 
    656         { 
    657                 coreactions.n++; 
    658         } 
    659628        mole_priv.reactab[label] = rate; 
    660629        rate->label = label; 
     
    14871456        FILE *sparsefp; 
    14881457        int i, j, nb, ch; 
    1489         long int ratej, nt, n; 
     1458        long int ratej; 
    14901459        struct mole_reaction_s *rate; 
    14911460        double **c; 
     
    15081477        } 
    15091478 
    1510         nt = coreactions.n; 
    1511          
    1512         for (n=0;n<nt;n++)  
    1513         { 
    1514                 rate = coreactions.list[n]; 
     1479        for(mole_reaction_i p=mole_priv.reactab.begin();  
     1480                        p != mole_priv.reactab.end(); p++)  
     1481        { 
     1482                rate = p->second; 
    15151483                 
    15161484                for (j=0;j<rate->nreactants;j++)