Changeset 2042 for branches/newmole/source
- Timestamp:
- 05/11/08 12:53:42 (6 months ago)
- Location:
- branches/newmole/source
- Files:
-
- 6 modified
-
molcol.cpp (modified) (1 diff)
-
mole.h (modified) (4 diffs)
-
mole_eval_balance.cpp (modified) (1 diff)
-
mole_reactions.cpp (modified) (9 diffs)
-
mole_species.cpp (modified) (9 diffs)
-
nemala2.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/newmole/source/molcol.cpp
r2028 r2042 47 47 /* print the molecular column densities */ 48 48 int j=0; 49 long heavy=-1, lastheavy=0; 49 50 for( i=0; i < mole.num_calc; i++ ) 50 51 { 51 52 if(mole.list[i]->location == NULL) 52 53 { 54 lastheavy = heavy; 55 heavy = mole.list[i]->heavyElem(); 56 if(j == 8 || heavy != lastheavy) 57 { 58 fprintf( ioMEAN, "\n" ); 59 if (heavy != lastheavy) 60 { 61 fprintf ( ioMEAN, "==== %-2.2s compounds ====\n",element_list[heavy]->label); 62 } 63 j = 0; 64 } 53 65 fprintf( ioMEAN, " %-6.6s:", mole.list[i]->label ); 54 66 fprintf( ioMEAN, "%7.3f",log10(MAX2(SMALLFLOAT,mole.list[i]->column ))); 55 67 j++; 56 fixit(); /* Separate elemental chem more clearly -- would need to refactor mole.nElem */57 if( j == 8 )58 {59 fprintf( ioMEAN, "\n" );60 j = 0;61 }62 68 } 63 69 } -
branches/newmole/source/mole.h
r2028 r2042 7 7 /* mole.h */ 8 8 9 enum {CHARS_SPECIES=7}; 9 10 enum mole_state {MOLE_NULL, MOLE_PASSIVE, MOLE_ACTIVE}; 11 12 /* Structure containing molecule data, initially only CO */ 13 class molecule { 14 public: 15 /* Species physical data */ 16 char label[CHARS_SPECIES]; /** name */ 17 int nElem[LIMELM]; /** number of each element in molecule */ 18 int charge; /** Charge on species/number of e- liberated by formation */ 19 bool lgExcit; /** Is species excited (e.g. H2*) */ 20 bool lgGas_Phase; /** Solid or gas phase? */ 21 int n_nuclei; /** total number of nuclei */ 22 realnum *location; /** Location of density in non-molecule code, NULL if none exists */ 23 realnum form_enthalpy; /** formation enthalpy for the molecule (at 0K), in units of KJ/mol */ 24 realnum mole_mass; /** Mass of molecule */ 25 26 /* Parameters as computational object */ 27 enum mole_state state; 28 int index, groupnum; 29 30 /* Current zone data */ 31 double den; /** density (cm-3) */ 32 realnum column; /** total column density in this iteration */ 33 int nElemLim; /** atomic number MINUS ONE of element for which is closest to limiting molecule density */ 34 realnum xFracLim; /** The fraction of that element in this species */ 35 36 /* Historical solution data */ 37 realnum column_old; /** total column density in previous iteration */ 38 39 long heavyElem(void) const 40 { 41 for (long nelem=LIMELM-1;nelem>=ipHYDROGEN;nelem--) 42 { 43 if (0 != nElem[nelem]) 44 { 45 return nelem; 46 } 47 } 48 return -1; 49 } 50 }; 10 51 11 52 /**mole_drive main driver for chemical equilibrium routines */ … … 29 70 extern double mole_findrate(const char buf[]); 30 71 31 extern structmolecule *findspecies(const char buf[]);72 extern molecule *findspecies(const char buf[]); 32 73 33 74 /** \verbatim >>chng 03 feb 09, rm ipH3P_hev, since not used, and decrement NUM_HEAVY_MOLEC to 17 … … 120 161 realnum ***xMoleChTrRate;/***[LIMELM][LIMELM+1][LIMELM+1];*/ 121 162 122 valarray< structmolecule *> list;163 valarray<molecule *> list; 123 164 124 165 valarray<struct molezone> zone; … … 131 172 double src, snk; 132 173 }; 133 134 enum {CHARS_SPECIES=7};135 /* Structure containing molecule data, initially only CO */136 137 struct molecule {138 /* Species physical data */139 char label[CHARS_SPECIES]; /** name */140 int nElem[LIMELM]; /** number of each element in molecule */141 int charge; /** Charge on species/number of e- liberated by formation */142 bool lgExcit; /** Is species excited (e.g. H2*) */143 bool lgGas_Phase; /** Solid or gas phase? */144 int n_nuclei; /** total number of nuclei */145 realnum *location; /** Location of density in non-molecule code, NULL if none exists */146 realnum form_enthalpy; /** formation enthalpy for the molecule (at 0K), in units of KJ/mol */147 realnum mole_mass; /** Mass of molecule */148 149 /* Parameters as computational object */150 enum mole_state state;151 int index, groupnum;152 153 /* Current zone data */154 double den; /** density (cm-3) */155 realnum column; /** total column density in this iteration */156 int nElemLim; /** atomic number MINUS ONE of element for which is closest to limiting molecule density */157 realnum xFracLim; /** The fraction of that element in this species */158 159 /* Historical solution data */160 realnum column_old; /** total column density in previous iteration */161 };162 174 163 175 extern void mole_punch(FILE *punit, const char speciesname[], -
branches/newmole/source/mole_eval_balance.cpp
r2031 r2042 35 35 double rate_tot, rate_deriv[MAXREACTANTS], rated, rk; 36 36 char debug_name[] = ""; /* Insert name of species to print largest rates for, e.g. "CH4" */ 37 structmolecule *sp;38 const structmolecule *debug_species = findspecies(debug_name);37 molecule *sp; 38 const molecule *debug_species = findspecies(debug_name); 39 39 double snkx=0.,srcx=0.; 40 40 -
branches/newmole/source/mole_reactions.cpp
r2027 r2042 450 450 { 451 451 struct mole_reaction_s *rate; 452 structmolecule *sp;452 molecule *sp; 453 453 ratefunc func; 454 454 mole_reaction_i p; … … 558 558 required (look for references to "reactants[0]" for examples) */ 559 559 qsort((void *)rate->reactants,(size_t)rate->nreactants, 560 sizeof( structmolecule *),mole_cmp);560 sizeof(molecule *),mole_cmp); 561 561 qsort((void *)rate->products,(size_t)rate->nproducts, 562 sizeof( structmolecule *),mole_cmp);562 sizeof(molecule *),mole_cmp); 563 563 564 564 ASSERT(lgReactBalance(rate)); /* Verify rate conserves particles and charge */ … … 1683 1683 class formula_species { 1684 1684 public: 1685 structmolecule *reactants[MAXREACTANTS], *products[MAXPRODUCTS];1685 molecule *reactants[MAXREACTANTS], *products[MAXPRODUCTS]; 1686 1686 }; 1687 1687 … … 1767 1767 } 1768 1768 } 1769 qsort((void *)r->l.reactants,(size_t)i,sizeof( structmolecule *),1769 qsort((void *)r->l.reactants,(size_t)i,sizeof(molecule *), 1770 1770 mole_cmp); 1771 1771 … … 1787 1787 } 1788 1788 } 1789 qsort((void *)r->l.products,(size_t)i,sizeof( structmolecule *),1789 qsort((void *)r->l.products,(size_t)i,sizeof(molecule *), 1790 1790 mole_cmp); 1791 1791 … … 2933 2933 double ratev, ratevi; 2934 2934 struct mole_reaction_s *rate; 2935 structmolecule *sp;2935 molecule *sp; 2936 2936 2937 2937 DEBUG_ENTRY("mole_sink_rate()"); … … 2990 2990 double ratev, ratevi; 2991 2991 struct mole_reaction_s *rate; 2992 structmolecule *sp, *ph;2992 molecule *sp, *ph; 2993 2993 2994 2994 DEBUG_ENTRY("mole_dissoc_rate()"); … … 3044 3044 double ratev, ratevi; 3045 3045 struct mole_reaction_s *rate; 3046 structmolecule *sp;3046 molecule *sp; 3047 3047 3048 3048 DEBUG_ENTRY("mole_source_rate()"); … … 3140 3140 double ratevi; 3141 3141 struct mole_reaction_s *rate; 3142 structmolecule *sp;3142 molecule *sp; 3143 3143 3144 3144 DEBUG_ENTRY("mole_punch()"); -
branches/newmole/source/mole_species.cpp
r2027 r2042 50 50 #include <functional> 51 51 52 class MoleCmp : public binary_function<const struct molecule *,const struct molecule *,bool>52 class MoleCmp : public binary_function<const molecule *,const molecule *,bool> 53 53 { 54 54 public: 55 bool operator()(const struct molecule *mol1, const struct molecule *mol2) const55 bool operator()(const molecule *mol1, const molecule *mol2) const 56 56 { 57 57 for (long nelem=LIMELM-1; nelem >= ipHYDROGEN; nelem--) 58 58 { 59 59 if (mol1->nElem[nelem] > mol2->nElem[nelem]) 60 { 60 61 return false; 62 } 61 63 else if (mol1->nElem[nelem] < mol2->nElem[nelem]) 64 { 62 65 return true; 66 } 63 67 } 64 68 return strcmp(mol1->label,mol2->label) < 0; … … 74 78 long int i, 75 79 nelem; 76 structmolecule *sp;80 molecule *sp; 77 81 static realnum one=1.0; 78 82 static bool lgmole_Init_called=false; … … 411 415 #include <string.h> 412 416 #include <ctype.h> 413 STATIC structmolecule *newspecies(417 STATIC molecule *newspecies( 414 418 const char label[7], 415 419 enum spectype type, … … 421 425 char mylab[7], thisel[3], *s; 422 426 long int i, n, nelem, nel; 423 structmolecule *mol;427 molecule *mol; 424 428 struct chem_element_s *el; 425 429 426 430 DEBUG_ENTRY("newspecies()"); 427 431 428 mol = ( struct molecule *) MALLOC(sizeof(structmolecule));432 mol = (molecule *) MALLOC(sizeof(molecule)); 429 433 430 434 for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem ) … … 568 572 return mol; 569 573 } 570 STATIC bool isactive( structmolecule *p)574 STATIC bool isactive(molecule *p) 571 575 { 572 576 DEBUG_ENTRY("isactive()"); 573 577 return p->state == MOLE_ACTIVE; 574 578 } 575 STATIC bool ispassive( structmolecule *p)579 STATIC bool ispassive(molecule *p) 576 580 { 577 581 … … 580 584 } 581 585 582 structmolecule *findspecies(const char buf[])586 molecule *findspecies(const char buf[]) 583 587 { 584 588 molecule_i p; … … 745 749 { 746 750 long int nelem; 747 struct molecule *mol1=*(struct molecule **)m1, *mol2=*(structmolecule **)m2;751 molecule *mol1=*(molecule **)m1, *mol2=*(molecule **)m2; 748 752 749 753 for (nelem=LIMELM-1; nelem >= ipHYDROGEN; nelem--) … … 844 848 return; 845 849 } 846 groupspecies = ( struct molecule **) MALLOC(mole.num_calc*sizeof(structmolecule *));850 groupspecies = (molecule **) MALLOC(mole.num_calc*sizeof(molecule *)); 847 851 for (i=0,j=0;i<mole.num_calc;i++) 848 852 { … … 862 866 } 863 867 mole.num_compacted = j; 864 groupspecies = ( structmolecule **) REALLOC((void *)groupspecies,865 mole.num_calc*sizeof( structmolecule *));868 groupspecies = (molecule **) REALLOC((void *)groupspecies, 869 mole.num_calc*sizeof(molecule *)); 866 870 867 871 for (i=0;i<mole.num_calc;i++) -
branches/newmole/source/nemala2.cpp
r2023 r2042 43 43 if( lgSpeciesMolecule[i] ) 44 44 { 45 structmolecule *SpeciesCurrent;45 molecule *SpeciesCurrent; 46 46 /** \todo 0 this pointer should be cached one time, and the species 47 47 * removed from the list if it is not computed */
