21 const vector<genericState>& SpeciesList,
28 const vector<genericState>& SpeciesList,
42 vector<genericState> speciesList;
56 vector<genericState> v =
matchGeneric(name->c_str(),
false);
60 "use SAVE SPECIES LABELS ALL to get a list of all species."
61 "\nSorry.\n", name->c_str() );
64 speciesList.insert(speciesList.end(),v.begin(),v.end());
73 fprintf( ioPUN,
"#Species label\tDatabase\n" );
74 for(
size_t i=0; i<speciesList.size(); ++i )
77 speciesList[i].label().c_str(),
78 speciesList[i].database().c_str() );
93 size_t mostLevels = 0;
94 for (vector<genericState>::iterator sp=speciesList.begin();
95 sp != speciesList.end(); ++sp)
97 const molezone *saveSpecies = sp->sp;
99 saveSpecies->
levels != NULL )
103 ASSERT( mostLevels < 10000 );
106 const char* chJob=NULL, *chFmt=NULL;
118 chJob =
"departure coefficients";
139 chJob =
"column density";
174 const vector<genericState>& speciesList,
184 fprintf( ioPUN,
"#%sspecies %s", lgZonal ?
"depth\t":
"", chJob );
185 for(
size_t i = 0; i < maxLevels; ++i )
187 fprintf( ioPUN,
"\t%lu", (
unsigned long)i );
196 fprintf( ioPUN,
"#depth %s", chJob );
201 fprintf( ioPUN,
"#%s ", chJob );
203 for (vector<genericState>::const_iterator gs=speciesList.begin();
204 gs != speciesList.end(); ++gs)
207 fprintf( ioPUN,
"%s",gs->label().c_str() );
209 fprintf( ioPUN,
"\t%s",gs->label().c_str() );
217 const vector<genericState>& speciesList,
226 if (lgRowPerZone && lgZonal)
231 for (vector<genericState>::const_iterator gs=speciesList.begin();
232 gs != speciesList.end(); ++gs)
241 fprintf( ioPUN,
"\t%s", gs->label().c_str() );
264 fprintf( ioPUN,
"# The number of levels used in each species.\n" );
265 fprintf( ioPUN,
"# Species\tSpectrum\tUsed\tMax.\tDatabase\n" );
266 for(
size_t ipSpecies=0; ipSpecies < speciesList.size(); ++ipSpecies )
268 const molezone *this_mole = speciesList[ ipSpecies ].sp;
272 species *this_species = (*this_mole).dbase;
273 if( this_species == NULL )
276 fprintf( ioPUN,
"%-8s", speciesList[ipSpecies].label().c_str() );
278 string spectralLabel;
280 fprintf( ioPUN,
"\t%s", spectralLabel.c_str() );
282 fprintf( ioPUN,
"\t%li", (*this_species).numLevels_local );
283 fprintf( ioPUN,
"\t%li", (*this_species).numLevels_max );
284 fprintf( ioPUN,
"\t%s", speciesList[ipSpecies].database().c_str() );
291 static vector<string> saved_species;
293 vector<genericState> speciesList_local;
295 for( vector<genericState>::const_iterator spcit = speciesList.begin();
296 spcit != speciesList.end(); ++spcit )
300 for( vector<string>::const_iterator sit = saved_species.begin();
301 sit != saved_species.end(); ++sit )
303 if( *sit == spcit->label() )
312 speciesList_local.insert( speciesList_local.end(), *spcit );
313 saved_species.push_back( spcit->label() );
317 if( speciesList_local.size() == 0 )
329 fprintf( ioPUN,
"\tWavenumbers");
333 fprintf( ioPUN,
"\tWavelength");
347 fprintf( ioPUN,
"\tEinstein A");
354 fprintf( ioPUN,
"\tRate electron");
355 fprintf( ioPUN,
"\tRate proton");
357 fprintf( ioPUN,
"\tRate Alpha");
358 fprintf( ioPUN,
"\tRate Atom H");
359 fprintf( ioPUN,
"\tRate Atom He");
360 fprintf( ioPUN,
"\tRate Ortho");
368 for(
size_t ipSpecies=0; ipSpecies < speciesList_local.size(); ++ipSpecies )
370 const molezone *this_mole = speciesList_local[ ipSpecies ].sp;
373 if( (*this_mole).lines == NULL )
376 species *this_species = (*this_mole).dbase;
377 if( this_species == NULL )
381 tr != (*this_mole).lines->end(); ++tr )
383 long ipLo = tr->ipLo() +1;
384 long ipHi = tr->ipHi() +1;
385 int nelem = tr->Hi()->nelem();
392 if( ipHi >= (*this_species).numLevels_local )
397 string spectralLabel;
399 fprintf( ioPUN,
"%-8s", spectralLabel.c_str() );
403 fprintf( ioPUN,
"\t%.3e", tr->EnergyWN() );
413 fprintf( ioPUN,
"\t%i",
int( tr->Lo()->g() ) );
414 fprintf( ioPUN,
"\t%i",
int( tr->Hi()->g() ) );
418 fprintf( ioPUN,
"\t%.3e", tr->Emis().gf() );
422 fprintf( ioPUN,
"\t%.3e", tr->Emis().Aul() );
425 fprintf( ioPUN,
"\t%.3e", tr->Coll().col_str());
426 fprintf( ioPUN,
"\t%i", tr->Coll().is_gbar() );
430 for(
long intCollNo=0; intCollNo<
ipNCOLLIDER; intCollNo++)
432 fprintf( ioPUN,
"\t%.3e",tr->Coll().rate_coef_ul()[intCollNo]);
451 "#hi\tlo\tWavelength(A)\ttau\n" );
458 if( species.
sp->
lines == NULL )
461 "WARNING: Species '%s' does not have any data for 'save species optical depth'.\n",
462 species.
label().c_str() );
467 tr != (*species.
sp->
lines).end(); ++tr)
469 if( (*tr).ipCont() <= 0 )
473 "%i\t%i\t%.5e\t%.5e\n",
477 (*tr).Emis().TauIn() * SQRTPI );
490 label(label), fmt(fmt),
m_value(value)
527 void mole_save(FILE *punit,
const char speciesname[],
const char args[],
bool lgHeader,
bool lgData,
bool lgCoef,
double depth)
535 fprintf( punit,
" Species %s could not be found. Note that labels are case-sensitive in this context.\n", speciesname );
539 void (*doTask)(FILE *punit,
const Field& f);
546 doTask(punit,
Field(
"Depth",
"%.5e",depth));
554 for (
int i=0;i<rate.
nreactants && !ipthis;i++)
558 if( ( strcmp( args,
"DEST" )==0 &&
isDestroyed(rate,i) ) ||
559 ( strcmp( args,
"DFLT" )==0 &&
isDestroyed(rate,i) ) ||
561 strcmp( args,
"ALL " )==0 )
566 for(
int i=0;i<rate.
nproducts && !ipthis;i++)
570 if( ( strcmp( args,
"CREA" )==0 &&
isCreated(rate,i) ) ||
571 ( strcmp( args,
"DFLT" )==0 &&
isCreated(rate,i) ) ||
573 strcmp( args,
"ALL " )==0 )
594 doTask(punit,
Field(rate.
label.c_str(),
"%.3e",ratevi));
614 bool lgPrintReagents,
size_t NPRINT,
double fprint )
616 vector<double> snkx, srcx;
617 vector<mole_reaction *> ratesnk, ratesrc;
619 double src_total = 0.0, snk_total = 0.0;
627 double rate_tot = rk;
634 for(
size_t s=0; s<debug_list.size(); ++s)
639 if (sp == debug_list[s] && rate->
pvector[i] == NULL)
647 if (sp == debug_list[s] && rate->
rvector[i] == NULL)
655 srcx.push_back(nrate*rate_tot);
656 ratesrc.push_back(rate);
657 src_total += nrate*rate_tot;
661 snkx.push_back(-nrate*rate_tot);
662 ratesnk.push_back(rate);
663 snk_total -= nrate*rate_tot;
667 if (!ratesrc.empty())
669 vector<size_t> isrc(ratesrc.size());
670 for (
size_t i=0; i<ratesrc.size(); ++i)
672 sort(isrc.begin(),isrc.end(),
RateCmp(srcx));
674 fprintf( ioOut,
"Src %13.7g: ",src_total);
675 for (
size_t i=0; i<ratesrc.size(); ++i)
677 if (i == NPRINT || srcx[isrc[i]] < fprint*src_total)
681 fprintf( ioOut,
"%20.20s %13.7g",
682 ratesrc[isrc[i]]->label.c_str(),srcx[isrc[i]]);
686 for (
long j=0;j<ratesrc[isrc[i]]->nreactants;j++)
692 fprintf( ioOut,
"%-6.6s %13.7g",
693 ratesrc[isrc[i]]->reactants[j]->label.c_str(),
694 mole.
species[ ratesrc[isrc[i]]->reactants[j]->index ].den);
704 if (!ratesnk.empty())
706 vector<size_t> isnk(ratesnk.size());
707 for (
size_t i=0; i<ratesnk.size(); ++i)
709 sort(isnk.begin(),isnk.end(),
RateCmp(snkx));
711 fprintf( ioOut,
" Snk %13.7g: ", snk_total);
712 for (
size_t i=0; i<ratesnk.size(); ++i)
714 if (i == NPRINT || snkx[isnk[i]] < fprint*snk_total)
718 fprintf( ioOut,
"%20.20s %13.7g",
719 ratesnk[isnk[i]]->label.c_str(), snkx[isnk[i]] );
723 for (
long j=0;j<ratesnk[isnk[i]]->nreactants;j++)
729 fprintf( ioOut,
"%-6.6s %13.7g",
730 ratesnk[isnk[i]]->reactants[j]->label.c_str(),
731 mole.
species[ ratesnk[isnk[i]]->reactants[j]->index ].den);
748 if( speciesToPrint==NULL )
750 fprintf(
ioQQQ,
"\n NULL species found in mole_print_species_reactions.\n" );
756 fprintf(
ioQQQ,
"\n Reactions involving species %s:\n", speciesToPrint->
label.c_str() );
763 if(rate.
rvector[i]==NULL && sp==speciesToPrint )
777 if(rate.
pvector[i]==NULL && sp==speciesToPrint )
789 fprintf(
ioQQQ,
" End of reactions involving species %s. There were %li.\n", speciesToPrint->
label.c_str(), numReacts );
molecule * reactants[MAXREACTANTS]
t_mole_global mole_global
vector< double > reaction_rks
void prt_wl(FILE *ioOUT, realnum wl)
STATIC void PrintShortZero(FILE *ioPUN, const char *chFmt, double arg)
NORETURN void TotalInsanity(void)
double depart(const genericState &gs)
STATIC void doHeader(FILE *punit, const Field &f)
STATIC bool isCreated(const mole_reaction &rate, int i)
const vector< double > & m_stack
map< string, count_ptr< mole_reaction > > reactab
vector< genericState > matchGeneric(const char *chLabel, bool lgValidate)
void getSpecies(const string &speciesLabel, genericState &species)
STATIC bool isCatalystProduct(const mole_reaction &rate, int i)
STATIC void SaveSpeciesHeader(const vector< genericState > &SpeciesList, const char *chJob, bool lgZonal, FILE *ioPUN, size_t maxLevels)
STATIC void SaveSpeciesOne(const vector< genericState > &SpeciesList, double(*job)(const genericState &), bool lgZonal, const char *chFmt, FILE *ioPUN)
void mole_save(FILE *punit, const char speciesname[], const char args[], bool lgHeader, bool lgData, bool lgCoef, double depth)
void SaveAllSpeciesLabelsLevels(FILE *ioPUN)
RateCmp(const vector< double > &stack)
void SaveSpeciesOptDep(const long int ipPun, const string &speciesLabel)
molecule * products[MAXPRODUCTS]
STATIC bool isCatalystReactant(const mole_reaction &rate, int i)
molecule * rvector[MAXREACTANTS]
double energy(const genericState &gs)
char chSaveArgs[LIMPUN][5]
void chemical_to_spectral(const string chLabelChem, string &chLabelSpec)
map< string, count_ptr< mole_reaction > >::iterator mole_reaction_i
molecule * findspecies(const char buf[])
valarray< class molezone > species
STATIC void SaveSpeciesLines(FILE *ioPUN, const vector< genericState > &speciesList)
Field(const char *label, const char *fmt, double value)
double column(const genericState &gs)
SaveParams params[LIMPUN]
STATIC void doData(FILE *punit, const Field &f)
double levels(const genericState &gs)
void SaveHeaderDone(int ipPun)
molecule * pvector[MAXPRODUCTS]
void mole_dominant_rates(const vector< const molecule * > &debug_list, FILE *ioOut, bool lgPrintReagents, size_t NPRINT, double fprint)
double density(const genericState &gs)
#define DEBUG_ENTRY(funcname)
void SaveSpecies(FILE *ioPUN, long int ipPun)
int fprintf(const Output &stream, const char *format,...)
vector< string > chSaveSpecies[LIMPUN]
molecule * rvector_excit[MAXREACTANTS]
STATIC bool isDestroyed(const mole_reaction &rate, int i)
bool lgSaveHeader(int ipPun) const
bool operator()(size_t a, size_t b)
void mole_print_species_reactions(molecule *speciesToPrint)
molecule * pvector_excit[MAXPRODUCTS]