41 map <string,count_ptr<molecule> >
spectab;
42 map <string,count_ptr<mole_reaction> >
reactab;
43 map <string,count_ptr<chem_element> >
elemtab;
44 map <string,count_ptr<mole_reaction> >
functab;
61 class MoleCmp :
public binary_function<const count_ptr<molecule>,
62 const count_ptr<molecule>,bool>
68 return mol1->
compare(*mol2) < 0;
72 return mol1->
compare(*mol2) < 0;
78 t_mole_global::MoleculeList::iterator end)
80 std::sort(start,end,MoleCmp());
84 std::sort(start,end,MoleCmp());
91 for(
int ielm = 0; ielm <
LIMELM; ielm++ )
100 if( (
unsigned)Z <= lgResolveNelem.size() && lgResolveNelem[Z] )
121 null_molezone->
den = 0.;
144 for(
long nelem=0; nelem<
LIMELM; ++nelem )
164 null_mole->
index = -1;
210 for( ChemNuclideList::iterator atom =
nuclide_list.begin();
213 if ( !(*atom)->lgHasLinkedIon() )
215 unsigned long int nelem = (*atom)->el->Z-1;
217 for(
unsigned long ion=0; ion<=nelem+1; ion++ )
224 sprintf( temp,
"+" );
226 sprintf( temp,
"+%ld", ion );
229 sprintf( str,
"%s%s", (*atom)->label().c_str(), temp );
233 fixit(
"populate these in a local update");
302 atom->ipMl[sp->
charge] = i;
319 while( getline( ioDATA,line ) )
325 istringstream iss( line );
327 double formation_enthalpy;
329 iss >> formation_enthalpy;
341 vector< int >& numNuclides,
344 string embellishments,
345 vector<string>& newLabels )
349 fixit(
"make sure atom_new and atom_old are isotopes");
350 fixit(
"make sure atom_new is not already present");
353 for(
unsigned position = 0; position < atoms.size(); ++position )
357 if( !newLabel.empty() )
358 newLabels.push_back( newLabel );
367 vector< int >& numNuclides,
370 string embellishments,
373 DEBUG_ENTRY(
"create_isotopologues_one_position()" );
376 if( atoms[position]->label() == atom_old )
378 for(
unsigned i=0; i<position; ++i )
380 str << atoms[i]->label();
381 if( numNuclides[i]>1 )
382 str << numNuclides[i];
385 if( numNuclides[position] > 1 )
388 if( numNuclides[position] > 2 )
389 str << numNuclides[position]-1;
392 if( position+1 == atoms.size() )
395 for(
unsigned i=position+1; i<atoms.size(); ++i )
400 if( atom_new == atoms[i]->label() )
402 str << atoms[i]->label();
403 ASSERT( numNuclides[i] + 1 > 1 );
404 str << numNuclides[i] + 1;
409 str << atoms[i]->label();
410 if( numNuclides[i] > 1 )
411 str << numNuclides[i];
416 str << atoms[i]->label();
417 if( numNuclides[i] > 1 )
418 str << numNuclides[i];
423 str << embellishments;
425 newLabel = str.str();
440 int len = strlen(label)+1;
442 char *mylab = mylab_v.
data();
443 strncpy(mylab,label,len);
444 s = strchr(mylab,
' ');
465 ASSERT( massNumberA < 3 *
LIMELM && ( massNumberA > 0 || massNumberA == -1 ) );
466 ASSERT( mass_amu < 3. * LIMELM && mass_amu > 0. );
467 ASSERT( frac <= 1. + FLT_EPSILON && frac >= 0. );
470 isotope->
A = massNumberA;
473 isotope->
ipMl.resize(el->
Z+1);
475 for (
long int ion = 0; ion < el->
Z+1; ion++)
476 isotope->
ipMl[ion] = -1;
482 el->
isotopes[massNumberA] = isotope;
493 realnum averageMass = 0., fracsum = 0.;
496 fracsum += it->second->frac;
497 averageMass += it->second->mass_amu * it->second->frac;
510 return newspecies( label, type, state, form_enthalpy,
true);
519 bool lgCreateIsotopologues )
525 vector< int > numNuclides;
526 string embellishments;
542 int len = strlen(label)+1;
544 char *mylab = mylab_v.
data();
545 strncpy(mylab,label,len);
546 s = strchr(mylab,
' ');
556 for(
unsigned i = 0; i < nuclidesLeftToRight.size(); ++i )
558 mol->
nNuclide[ nuclidesLeftToRight[i] ] += numNuclides[i];
559 mol->
mole_mass += numNuclides[i] * nuclidesLeftToRight[i]->mass_amu * (
realnum)ATOMIC_MASS_UNIT;
570 fprintf(
ioQQQ,
"No species %s as molecules off\n",label);
582 fprintf(
ioQQQ,
"No species %s as heavy molecules off\n",label);
598 fprintf(
ioQQQ,
"Warning: duplicate species %s - using first one\n",
599 mol->
label.c_str() );
615 if( lgCreateIsotopologues && type==
MOLECULE && mol->
label.compare(
"CO")==0 )
627 it2 != it1->first->el->isotopes.end(); ++it2 )
630 if( it1->first->el->Z-1 ==
ipHYDROGEN && it2->second->A != 2 )
634 if( it2->second->lgMeanAbundance() )
636 vector<string> isoLabs;
637 create_isotopologues( nuclidesLeftToRight, numNuclides, it1->first->label(), it2->second->label(), embellishments, isoLabs );
642 for( vector<string>::iterator newLabel = isoLabs.begin(); newLabel != isoLabs.end(); ++newLabel )
646 if( sp!=NULL && it2->second->A != 2 )
657 bool lgExcit, lgGas_Phase;
659 bool lgOK =
parse_species_label( label, nuclidesLeftToRight, numNuclides, embellishments, lgExcit, charge, lgGas_Phase );
663 bool &lgExcit,
int &charge,
bool &lgGas_Phase )
665 long int i, n, ipAtom;
669 int iend = strlen(label);
672 s = strpbrk(label,
"*");
681 s = strpbrk(label,
"+-");
692 embellishments = s + embellishments;
696 s = strstr(label,
"grn");
700 embellishments = s + embellishments;
712 while (i < iend && label[i] !=
' ' && label[i] !=
'*')
719 thisAtom[ipAtom++] = label[i++];
720 ASSERT( isdigit(label[i]) );
721 thisAtom[ipAtom++] = label[i++];
722 if(isdigit(label[i]))
724 thisAtom[ipAtom++] = label[i++];
728 thisAtom[ipAtom++] = label[i++];
729 if( i<iend && islower(label[i]))
731 thisAtom[ipAtom++] = label[i++];
733 thisAtom[ipAtom] =
'\0';
739 fprintf(stderr,
"Did not recognize atom at %s in \"%s \"[%ld]\n",thisAtom,label,i);
749 if(i < iend && isdigit(label[i]))
753 n = 10*n+(
long int)(label[i]-
'0');
755 }
while (i < iend && isdigit(label[i]));
761 nuclidesLeftToRight.push_back( atom );
762 numNuclides.push_back( n );
795 for (
const char *pb = buf; *pb && *pb !=
' '; ++pb)
803 return &(*p->second);
814 for (
const char *pb = buf; *pb && *pb !=
' '; ++pb)
822 return &(*p->second);
825 fprintf(
ioQQQ,
" PROBLEM specified species, '%s', is not valid or disabled.\n", s.c_str() );
826 fprintf(
ioQQQ,
" The SAVE SPECIES LABELS command will generate a list of species. Species names are case sensitive.\n");
869 double den_times_area, den_grains, adsorbed_density;
873 enum { DEBUG_MOLE =
false };
886 den_times_area = den_grains = 0.0;
887 for(
size_t nd=0; nd <
gv.
bin.size(); nd++ )
890 den_times_area +=
gv.
bin[nd]->IntArea/4.*
gv.
bin[nd]->cnv_H_pCM3;
891 den_grains +=
gv.
bin[nd]->cnv_GR_pCM3;
894 adsorbed_density = 0.0;
904 double mole_cs = 1e-15;
905 if (4*den_times_area <= mole_cs*adsorbed_density)
986 return ncpt>0 ? sqrt(delta/ncpt) : 0.f;
991 DEBUG_ENTRY(
"t_mole_local::set_isotope_abundances()" );
996 if ( !(*atom)->lgMeanAbundance() )
1000 for(
isotopes_i it = (*atom)->el->isotopes.begin(); it != (*atom)->el->isotopes.end(); ++it )
1003 if( it->second->lgMeanAbundance() )
1007 for(
unsigned long ion=0; ion<it->second->ipMl.size(); ++ion )
1009 if( it->second->ipMl[ion] != -1 &&
1010 (
species[ it->second->ipMl[ion] ].location == NULL ) && (*atom)->ipMl[ion] != -1 )
1012 species[ it->second->ipMl[ion] ].den =
species[ (*atom)->ipMl[ion] ].den * it->second->frac;
1023 DEBUG_ENTRY(
"t_mole_local::set_ion_locations()" );
1025 for( ChemNuclideList::iterator atom =
nuclide_list.begin();
1028 if ( !(*atom)->lgHasLinkedIon() )
1030 long nelem = (*atom)->el->Z-1;
1031 for(
long ion=0; ion<nelem+2; ++ion )
1033 long mole_index = (*atom)->ipMl[ion];
1035 if( mole_index != -1 )
1064 for( molecule::nNucsMap::iterator atom=
mole_global.
list[i]->nNuclide.begin();
1067 long int nelem = atom->first->el->Z-1;
1068 if( nelem==0 && atom->first->A==2 )
1093 for( molecule::nNucsMap::iterator atom=
mole_global.
list[i]->nNuclide.begin();
1096 ASSERT( atom->second > 0 );
1097 long int nelem = atom->first->el->Z-1;
1098 if( atom->first->lgMeanAbundance() )
1178 ASSERT( it->second > 0 );
map< string, size_t >::iterator chem_nuclide_i
t_mole_global mole_global
static void sort(MoleculeList::iterator start, MoleculeList::iterator end)
FILE * open_data(const char *fname, const char *mode, access_scheme scheme)
const double ENERGY_H2_STAR
molecule::nNucsMap::iterator nNucs_i
realnum getMass(int Anum)
vector< bool > lgTreatIsotopes
NORETURN void TotalInsanity(void)
realnum total_molecules(void)
map< int, count_ptr< chem_nuclide > >::iterator isotopes_i
void total_molecule_deut(realnum &total)
map< string, count_ptr< molecule > >::iterator molecule_i
bool lgLeiden_Keep_ipMH2s
void mole_make_list(void)
map< string, count_ptr< mole_reaction > > reactab
STATIC molecule * newspecies(const char label[], enum spectype type, enum mole_state state, realnum form_enthalpy)
molezone * ionMole[LIMELM][LIMELM+1]
bool speciesOff(const string &label)
vector< count_ptr< chem_element > > ChemElementList
map< string, size_t > nuclidetab
molezone * findspecieslocal(const char buf[])
void InitDeuteriumIonization()
ChemNuclideList nuclide_list
bool parse_species_label(const char label[], ChemNuclideList &atomsLeftToRight, vector< int > &numAtoms, string &embellishments)
molezone * findspecieslocal_validate(const char buf[])
t_elementnames elementnames
ChemElementList element_list
double xIonDense[LIMELM][LIMELM+1]
element_type * data() const
bool fp_equal(sys_float x, sys_float y, int n=3)
STATIC realnum MeanMassOfElement(const count_ptr< chem_element > &el)
molecule::nNucsMap::reverse_iterator nNucs_ri
const ios_base::openmode mode_r
map< int, count_ptr< chem_nuclide > > isotopes
STATIC bool isactive(const molecule &mol)
map< string, count_ptr< chem_element > > elemtab
STATIC void read_species_file(string filename, bool lgCreateIsotopologues=true)
chem_nuclide * null_nuclide
molecule * findspecies(const char buf[])
void create_isotopologues_one_position(unsigned position, ChemNuclideList &atoms, vector< int > &numAtoms, string atom_old, string atom_new, string embellishments, string &newLabel)
valarray< class molezone > species
count_ptr< chem_nuclide > findnuclide(const char buf[])
STATIC void SetIsotopeFractions(const vector< bool > &lgResolveNelem)
realnum total_molecules_gasphase(void)
map< string, count_ptr< mole_reaction > > functab
STATIC void newelement(const char label[], int ipion)
realnum mole_return_cached_species(const GroupMap &MoleMap)
diatomics h2("h2", 4100.,&hmi.H2_total, Yan_H2_CS)
bool exists(const molecule *m)
void SetDeuteriumFractionation(const realnum &frac)
void SetGasPhaseDeuterium(const realnum &Hdensity)
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
int compare(const molecule &mol2) const
realnum gas_phase[LIMELM]
vector< count_ptr< chem_nuclide > > ChemNuclideList
realnum AtomicWeight[LIMELM]
void set_isotope_abundances(void)
STATIC void start(long, realnum[], realnum[], long, long[], realnum *, int *)
bool isMonatomic(void) const
#define DEBUG_ENTRY(funcname)
STATIC void newisotope(const count_ptr< chem_element > &el, int massNumberA, realnum mass_amu, double frac)
bool lgGrain_mole_deplete
bool lgDifferByExcitation(const molecule &mol1, const molecule &mol2)
void mole_update_species_cache(void)
STATIC bool ispassive(const molecule &mol)
int fprintf(const Output &stream, const char *format,...)
vector< molecule * > groupspecies
sys_float SDIV(sys_float x)
bool lgElemsConserved(void)
void mole_make_groups(void)
map< string, count_ptr< molecule > > spectab
chem_element * null_element
void total_molecule_elems(realnum total[LIMELM])
molecule * findspecies_validate(const char buf[])
void create_isotopologues(ChemNuclideList &atoms, vector< int > &numAtoms, string atom_old, string atom_new, string embellishments, vector< string > &newLabels)