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 bool lgRunOnce =
true;
305 fprintf( ioPUN,
"\tWavenumbers");
309 fprintf( ioPUN,
"\tWavelength");
323 fprintf( ioPUN,
"\tEinstein A");
330 fprintf( ioPUN,
"\tRate electron");
331 fprintf( ioPUN,
"\tRate proton");
333 fprintf( ioPUN,
"\tRate Alpha");
334 fprintf( ioPUN,
"\tRate Atom H");
335 fprintf( ioPUN,
"\tRate Atom He");
336 fprintf( ioPUN,
"\tRate Ortho");
344 for(
size_t ipSpecies=0; ipSpecies < speciesList.size(); ++ipSpecies )
346 const molezone *this_mole = speciesList[ ipSpecies ].sp;
349 if( (*this_mole).lines == NULL )
352 species *this_species = (*this_mole).dbase;
353 if( this_species == NULL )
357 tr != (*this_mole).lines->end(); ++tr )
359 long ipLo = tr->ipLo() +1;
360 long ipHi = tr->ipHi() +1;
361 int nelem = tr->Hi()->nelem();
368 if( ipHi >= (*this_species).numLevels_local )
373 string spectralLabel;
375 fprintf( ioPUN,
"%-8s", spectralLabel.c_str() );
379 fprintf( ioPUN,
"\t%.3e", tr->EnergyWN() );
389 fprintf( ioPUN,
"\t%i",
int( tr->Lo()->g() ) );
390 fprintf( ioPUN,
"\t%i",
int( tr->Hi()->g() ) );
394 fprintf( ioPUN,
"\t%.3e", tr->Emis().gf() );
398 fprintf( ioPUN,
"\t%.3e", tr->Emis().Aul() );
401 fprintf( ioPUN,
"\t%.3e", tr->Coll().col_str());
402 fprintf( ioPUN,
"\t%i", tr->Coll().is_gbar() );
406 for(
long intCollNo=0; intCollNo<
ipNCOLLIDER; intCollNo++)
408 fprintf( ioPUN,
"\t%.3e",tr->Coll().rate_coef_ul()[intCollNo]);
428 "#hi\tlo\tWavelength(A)\ttau\n" );
435 if( species.
sp->
lines == NULL )
438 "WARNING: Species '%s' does not have any data for 'save species optical depth'.\n",
439 species.
label().c_str() );
444 tr != (*species.
sp->
lines).end(); ++tr)
446 if( (*tr).ipCont() <= 0 )
450 "%i\t%i\t%.5e\t%.5e\n",
454 (*tr).Emis().TauIn() * SQRTPI );
467 label(label), fmt(fmt),
m_value(value)
504 void mole_save(FILE *punit,
const char speciesname[],
const char args[],
bool lgHeader,
bool lgData,
bool lgCoef,
double depth)
512 fprintf( punit,
" Species %s could not be found. Note that labels are case-sensitive in this context.\n", speciesname );
516 void (*doTask)(FILE *punit,
const Field& f);
523 doTask(punit,
Field(
"Depth",
"%.5e",depth));
531 for (
int i=0;i<rate.
nreactants && !ipthis;i++)
535 if( ( strcmp( args,
"DEST" )==0 &&
isDestroyed(rate,i) ) ||
536 ( strcmp( args,
"DFLT" )==0 &&
isDestroyed(rate,i) ) ||
538 strcmp( args,
"ALL " )==0 )
543 for(
int i=0;i<rate.
nproducts && !ipthis;i++)
547 if( ( strcmp( args,
"CREA" )==0 &&
isCreated(rate,i) ) ||
548 ( strcmp( args,
"DFLT" )==0 &&
isCreated(rate,i) ) ||
550 strcmp( args,
"ALL " )==0 )
571 doTask(punit,
Field(rate.
label.c_str(),
"%.3e",ratevi));
591 bool lgPrintReagents,
size_t NPRINT,
double fprint )
593 vector<double> snkx, srcx;
594 vector<mole_reaction *> ratesnk, ratesrc;
596 double src_total = 0.0, snk_total = 0.0;
604 double rate_tot = rk;
611 for(
size_t s=0; s<debug_list.size(); ++s)
616 if (sp == debug_list[s] && rate->
pvector[i] == NULL)
624 if (sp == debug_list[s] && rate->
rvector[i] == NULL)
632 srcx.push_back(nrate*rate_tot);
633 ratesrc.push_back(rate);
634 src_total += nrate*rate_tot;
638 snkx.push_back(-nrate*rate_tot);
639 ratesnk.push_back(rate);
640 snk_total -= nrate*rate_tot;
644 if (!ratesrc.empty())
646 vector<size_t> isrc(ratesrc.size());
647 for (
size_t i=0; i<ratesrc.size(); ++i)
649 sort(isrc.begin(),isrc.end(),
RateCmp(srcx));
651 fprintf( ioOut,
"Src %13.7g: ",src_total);
652 for (
size_t i=0; i<ratesrc.size(); ++i)
654 if (i == NPRINT || srcx[isrc[i]] < fprint*src_total)
658 fprintf( ioOut,
"%20.20s %13.7g",
659 ratesrc[isrc[i]]->label.c_str(),srcx[isrc[i]]);
663 for (
long j=0;j<ratesrc[isrc[i]]->nreactants;j++)
669 fprintf( ioOut,
"%-6.6s %13.7g",
670 ratesrc[isrc[i]]->reactants[j]->label.c_str(),
671 mole.
species[ ratesrc[isrc[i]]->reactants[j]->index ].den);
681 if (!ratesnk.empty())
683 vector<size_t> isnk(ratesnk.size());
684 for (
size_t i=0; i<ratesnk.size(); ++i)
686 sort(isnk.begin(),isnk.end(),
RateCmp(snkx));
688 fprintf( ioOut,
" Snk %13.7g: ", snk_total);
689 for (
size_t i=0; i<ratesnk.size(); ++i)
691 if (i == NPRINT || snkx[isnk[i]] < fprint*snk_total)
695 fprintf( ioOut,
"%20.20s %13.7g",
696 ratesnk[isnk[i]]->label.c_str(), snkx[isnk[i]] );
700 for (
long j=0;j<ratesnk[isnk[i]]->nreactants;j++)
706 fprintf( ioOut,
"%-6.6s %13.7g",
707 ratesnk[isnk[i]]->reactants[j]->label.c_str(),
708 mole.
species[ ratesnk[isnk[i]]->reactants[j]->index ].den);
725 if( speciesToPrint==NULL )
727 fprintf(
ioQQQ,
"\n NULL species found in mole_print_species_reactions.\n" );
733 fprintf(
ioQQQ,
"\n Reactions involving species %s:\n", speciesToPrint->
label.c_str() );
740 if(rate.
rvector[i]==NULL && sp==speciesToPrint )
754 if(rate.
pvector[i]==NULL && sp==speciesToPrint )
766 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]