cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
save_species.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2017 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*SaveSpecies generate output for the save species command */
4 #include "cddefines.h"
5 #include "taulines.h"
6 #include "radius.h"
7 #include "save.h"
8 #include "mole.h"
9 #include "mole_priv.h"
10 #include "generic_state.h"
11 #include "iterations.h"
12 #include "dense.h"
13 #include "prt.h"
14 
15 
16 
17 STATIC void SaveSpeciesLines( FILE *ioPUN, const vector<genericState> &speciesList );
18 
19 /* save results for one particular species */
21  const vector<genericState>& SpeciesList,
22  double (*job)(const genericState&),
23  bool lgZonal,
24  const char* chFmt,
25  FILE *ioPUN );
26 
28  const vector<genericState>& SpeciesList,
29  const char *chJob,
30  bool lgZonal,
31  FILE *ioPUN,
32  size_t maxLevels );
33 
34 /*SaveSpecies generate output for the save species command */
36  FILE* ioPUN,
37  long int ipPun)
38 {
39  DEBUG_ENTRY( "SaveSpecies()" );
40 
41  /* first branch; save results for all species if list is empty */
42  vector<genericState> speciesList;
43  if( save.chSaveSpecies[ipPun].size() == 0 )
44  {
45  // loop over species
46  for( size_t i=0; i<mole_global.list.size(); ++i )
47  {
48  speciesList.push_back( genericState(&(mole.species[i])) );
49  }
50  }
51  else
52  {
53  for (vector<string>::iterator name=save.chSaveSpecies[ipPun].begin();
54  name != save.chSaveSpecies[ipPun].end(); ++name)
55  {
56  vector<genericState> v = matchGeneric(name->c_str(),false);
57  if( v.size() == 0 )
58  {
59  fprintf( ioQQQ,"Could not match species '%s', "
60  "use SAVE SPECIES LABELS ALL to get a list of all species."
61  "\nSorry.\n", name->c_str() );
63  }
64  speciesList.insert(speciesList.end(),v.begin(),v.end());
65  }
66  }
67 
68  if( strcmp( save.chSaveArgs[ipPun], "LABE" )==0 )
69  {
70  if( save.lgSaveHeader(ipPun) )
71  {
72  /* save list of species labels */
73  fprintf( ioPUN, "#Species label\tDatabase\n" );
74  for( size_t i=0; i<speciesList.size(); ++i )
75  {
76  fprintf( ioPUN, "%s\t%s\n",
77  speciesList[i].label().c_str(),
78  speciesList[i].database().c_str() );
79  }
80  save.SaveHeaderDone(ipPun);
81  }
82  return;
83  }
84 
85  if( strcmp( save.chSaveArgs[ipPun], "DATA" ) == 0 )
86  {
87  SaveSpeciesLines( ioPUN, speciesList );
88  return;
89  }
90 
91  /* remaining options are column densities, densities, and energies */
92  // max number of levels, for header print
93  size_t mostLevels = 0;
94  for (vector<genericState>::iterator sp=speciesList.begin();
95  sp != speciesList.end(); ++sp)
96  {
97  const molezone *saveSpecies = sp->sp;
98  if( saveSpecies != NULL && saveSpecies != null_molezone &&
99  saveSpecies->levels != NULL )
100  mostLevels = MAX2(mostLevels, saveSpecies->levels->size() );
101  }
102 
103  ASSERT( mostLevels < 10000 );
104 
105  bool lgZonal = true;
106  const char* chJob=NULL, *chFmt=NULL;
107  double (*job)(const genericState&)=NULL;
108  if( strcmp( save.chSaveArgs[ipPun], "ENER" )==0 )
109  {
110  lgZonal = false;
111  chJob = "energies";
112  job = energy;
113  chFmt = "%.5e";
114  }
115  else if( strcmp( save.chSaveArgs[ipPun], "DEPA" )==0 )
116  {
117  lgZonal = true;
118  chJob = "departure coefficients";
119  job = depart;
120  chFmt = "%.5e";
121  }
122  else if( strcmp( save.chSaveArgs[ipPun], "DENS" )==0 )
123  {
124  lgZonal = true;
125  chJob = "densities";
126  chFmt = "%.5e";
127  job = density;
128  }
129  else if( strcmp( save.chSaveArgs[ipPun], "LEVL" )==0 )
130  {
131  lgZonal = true;
132  chJob = "levels";
133  chFmt = "%4.0f";
134  job = levels;
135  }
136  else if( strcmp( save.chSaveArgs[ipPun], "COLU" )==0 )
137  {
138  lgZonal = false;
139  chJob = "column density";
140  chFmt = "%.5e";
141  job = column;
142  }
143  else
144  {
145  fprintf(ioQQQ,"PROBLEM, save species job type \"%s\" not known\n",save.chSaveArgs[ipPun]);
146  TotalInsanity();
147  }
148 
149  if( save.lgSaveHeader(ipPun) )
150  {
151  SaveSpeciesHeader( speciesList, chJob, lgZonal, ioPUN, mostLevels );
152  save.SaveHeaderDone(ipPun);
153  }
154  SaveSpeciesOne( speciesList, job, lgZonal, chFmt, ioPUN );
155 
156  return;
157 }
158 
159 /* print 0.000e+00 as simply 0 */
160 STATIC void PrintShortZero( FILE *ioPUN , const char* chFmt, double arg )
161 {
162  DEBUG_ENTRY( "PrintShortZero()" );
163  if( arg==0. )
164  fprintf(ioPUN,"0");
165  else
166  fprintf(ioPUN,chFmt, arg);
167 
168 }
169 
170 // Switch from initial format to single row per zone
171 const bool lgRowPerZone = true;
172 /* save results for one particular species */
174  const vector<genericState>& speciesList,
175  const char *chJob,
176  bool lgZonal,
177  FILE *ioPUN,
178  size_t maxLevels )
179 {
180  DEBUG_ENTRY( "SaveSpeciesHeader()" );
181 
182  if (!lgRowPerZone)
183  {
184  fprintf( ioPUN, "#%sspecies %s", lgZonal ? "depth\t":"", chJob );
185  for( size_t i = 0; i < maxLevels; ++i )
186  {
187  fprintf( ioPUN, "\t%lu", (unsigned long)i );
188  }
189  fprintf( ioPUN, "\n");
190  }
191  else
192  {
193  int col=0;
194  if (lgZonal)
195  {
196  fprintf( ioPUN, "#depth %s", chJob );
197  ++col;
198  }
199  else
200  {
201  fprintf( ioPUN, "#%s ", chJob );
202  }
203  for (vector<genericState>::const_iterator gs=speciesList.begin();
204  gs != speciesList.end(); ++gs)
205  {
206  if (col == 0)
207  fprintf( ioPUN, "%s",gs->label().c_str() );
208  else
209  fprintf( ioPUN, "\t%s",gs->label().c_str() );
210  ++col;
211  }
212  fprintf( ioPUN,"\n" );
213  }
214 }
215 
217  const vector<genericState>& speciesList,
218  double (*job)(const genericState&),
219  bool lgZonal,
220  const char* chFmt,
221  FILE *ioPUN)
222 {
223  DEBUG_ENTRY( "SaveSpeciesOne()" );
224 
225  int col = 0;
226  if (lgRowPerZone && lgZonal)
227  {
228  fprintf( ioPUN, "%.5e", radius.depth_mid_zone );
229  ++col;
230  }
231  for (vector<genericState>::const_iterator gs=speciesList.begin();
232  gs != speciesList.end(); ++gs)
233  {
234  if (!lgRowPerZone)
235  {
236  if (lgZonal)
237  {
238  fprintf( ioPUN, "%.5e", radius.depth_mid_zone );
239  ++col;
240  }
241  fprintf( ioPUN, "\t%s", gs->label().c_str() );
242  ++col;
243  }
244  if (col > 0)
245  fprintf(ioPUN,"\t");
246  PrintShortZero( ioPUN, chFmt, job(*gs) );
247  ++col;
248  if (!lgRowPerZone)
249  {
250  fprintf(ioPUN,"\n");
251  col = 0;
252  }
253  }
254 
255  if (lgRowPerZone)
256  fprintf(ioPUN,"\n");
257  return;
258 }
259 
261 STATIC void SaveAllSpeciesLabelsLevels( FILE *ioPUN, const vector<genericState> &speciesList )
262 {
263  //Print out number of levels used
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 )
267  {
268  const molezone *this_mole = speciesList[ ipSpecies ].sp;
269  if( this_mole == NULL || this_mole == null_molezone )
270  continue;
271 
272  species *this_species = (*this_mole).dbase;
273  if( this_species == NULL )
274  continue;
275 
276  fprintf( ioPUN, "%-8s", speciesList[ipSpecies].label().c_str() );
277 
278  string spectralLabel;
279  chemical_to_spectral( speciesList[ ipSpecies ].label(), spectralLabel );
280  fprintf( ioPUN, "\t%s", spectralLabel.c_str() );
281 
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() );
285  fprintf( ioPUN, "\n" );
286  }
287 }
288 
289 STATIC void SaveSpeciesLines( FILE *ioPUN, const vector<genericState> &speciesList )
290 {
291  static bool lgRunOnce = true;
292  if( lgRunOnce )
293  {
294  lgRunOnce = false;
295 
296  SaveAllSpeciesLabelsLevels( ioPUN, speciesList );
297 
298  fprintf( ioPUN,"\n\n");
299 
300  //Species ipLo ipHi gLo gHi wavelen EinA CS Rates
301  fprintf( ioPUN,"Spectrum");
302 
303  if( save.lgSaveDataWn )
304  {
305  fprintf( ioPUN,"\tWavenumbers");
306  }
307  else
308  {
309  fprintf( ioPUN,"\tWavelength");
310  }
311 
312  fprintf( ioPUN,"\tLo");
313  fprintf( ioPUN,"\tHi");
314  fprintf( ioPUN,"\tgLo");
315  fprintf( ioPUN,"\tgHi");
316 
317  if( save.lgSaveDataGf )
318  {
319  fprintf( ioPUN,"\t gf ");
320  }
321  else
322  {
323  fprintf( ioPUN,"\tEinstein A");
324  }
325  fprintf( ioPUN,"\tColl_Str");
326  fprintf( ioPUN,"\tgbar");
327 
328  if( save.lgSaveDataRates )
329  {
330  fprintf( ioPUN,"\tRate electron");
331  fprintf( ioPUN,"\tRate proton");
332  fprintf( ioPUN,"\tRate He+ ");
333  fprintf( ioPUN,"\tRate Alpha");
334  fprintf( ioPUN,"\tRate Atom H");
335  fprintf( ioPUN,"\tRate Atom He");
336  fprintf( ioPUN,"\tRate Ortho");
337  fprintf( ioPUN,"\tRate Para");
338  fprintf( ioPUN,"\tRate H2");
339  }
340 
341  fprintf( ioPUN,"\n");
342 
343 
344  for( size_t ipSpecies=0; ipSpecies < speciesList.size(); ++ipSpecies )
345  {
346  const molezone *this_mole = speciesList[ ipSpecies ].sp;
347  if( this_mole == NULL || this_mole == null_molezone )
348  continue;
349  if( (*this_mole).lines == NULL )
350  continue;
351 
352  species *this_species = (*this_mole).dbase;
353  if( this_species == NULL )
354  continue;
355 
356  for (TransitionList::iterator tr = (*this_mole).lines->begin();
357  tr != (*this_mole).lines->end(); ++tr )
358  {
359  long ipLo = tr->ipLo() +1;
360  long ipHi = tr->ipHi() +1;
361  int nelem = tr->Hi()->nelem();
362 
363  if( nelem != -1 && !dense.lgElmtOn[nelem-1] )
364  {
365  continue;
366  }
367 
368  if( ipHi >= (*this_species).numLevels_local )
369  {
370  continue;
371  }
372 
373  string spectralLabel;
374  chemical_to_spectral( speciesList[ ipSpecies ].label(), spectralLabel );
375  fprintf( ioPUN,"%-8s", spectralLabel.c_str() );
376 
377  if( save.lgSaveDataWn )
378  {
379  fprintf( ioPUN,"\t%.3e", tr->EnergyWN() );
380  }
381  else
382  {
383  fprintf( ioPUN, "\t" );
384  prt_wl( ioPUN, realnum( tr->WLAng() ) );
385  }
386 
387  fprintf( ioPUN,"\t%li", ipLo);
388  fprintf( ioPUN,"\t%li", ipHi);
389  fprintf( ioPUN,"\t%i", int( tr->Lo()->g() ) );
390  fprintf( ioPUN,"\t%i", int( tr->Hi()->g() ) );
391 
392  if( save.lgSaveDataGf )
393  {
394  fprintf( ioPUN,"\t%.3e", tr->Emis().gf() );
395  }
396  else
397  {
398  fprintf( ioPUN,"\t%.3e", tr->Emis().Aul() );
399  }
400 
401  fprintf( ioPUN,"\t%.3e", tr->Coll().col_str());
402  fprintf( ioPUN,"\t%i", tr->Coll().is_gbar() );
403 
404  if( save.lgSaveDataRates )
405  {
406  for( long intCollNo=0; intCollNo<ipNCOLLIDER; intCollNo++)
407  {
408  fprintf( ioPUN,"\t%.3e",tr->Coll().rate_coef_ul()[intCollNo]);
409  }
410  }
411 
412  fprintf( ioPUN,"\n");
413  }
414  }
415  }
416 }
417 
418 void SaveSpeciesOptDep( const long int ipPun, const string &speciesLabel )
419 {
420  DEBUG_ENTRY( "SaveSpeciesOptDep()" );
421 
422  if( ! iterations.lgLastIt )
423  return;
424 
425  if( save.lgSaveHeader(ipPun) )
426  {
427  fprintf( save.params[ipPun].ipPnunit,
428  "#hi\tlo\tWavelength(A)\ttau\n" );
429  save.SaveHeaderDone( ipPun );
430  }
431 
433  getSpecies( speciesLabel, species );
434 
435  if( species.sp->lines == NULL )
436  {
437  fprintf( ioQQQ,
438  "WARNING: Species '%s' does not have any data for 'save species optical depth'.\n",
439  species.label().c_str() );
440  return;
441  }
442 
443  for( TransitionList::iterator tr = (*species.sp->lines).begin();
444  tr != (*species.sp->lines).end(); ++tr)
445  {
446  if( (*tr).ipCont() <= 0 )
447  continue;
448 
449  fprintf( save.params[ipPun].ipPnunit,
450  "%i\t%i\t%.5e\t%.5e\n",
451  (*tr).ipHi()+1,
452  (*tr).ipLo()+1,
453  (*tr).WLAng(),
454  (*tr).Emis().TauIn() * SQRTPI );
455  }
456 }
457 
458 class Field
459 {
460 public:
461  const char* label;
462  const char* fmt;
463 private:
464  double m_value;
465 public:
466  Field(const char* label, const char* fmt, double value) :
467  label(label), fmt(fmt), m_value(value)
468  {}
469  double value() const
470  {
471  return m_value;
472  }
473 };
474 
475 STATIC void doHeader(FILE *punit, const Field& f)
476 {
477  DEBUG_ENTRY( "doHeader()" );
478  fprintf(punit,"%s",f.label);
479 }
480 STATIC void doData(FILE *punit, const Field& f)
481 {
482  DEBUG_ENTRY( "doData()" );
483  fprintf(punit,f.fmt,f.value());
484 }
485 
486 STATIC inline bool isCatalystReactant(const mole_reaction& rate, int i)
487 {
488  return rate.rvector[i]!=NULL;
489 }
490 STATIC inline bool isCatalystProduct(const mole_reaction& rate, int i)
491 {
492  return rate.pvector[i]!=NULL;
493 }
494 STATIC inline bool isDestroyed(const mole_reaction& rate, int i)
495 {
496  return !isCatalystReactant(rate,i) && rate.rvector_excit[i]==NULL;
497 }
498 STATIC inline bool isCreated(const mole_reaction& rate, int i)
499 {
500  return !isCatalystProduct(rate,i) && rate.pvector_excit[i]==NULL;
501 }
502 
503 /* Save all rates involving specified species */
504 void mole_save(FILE *punit, const char speciesname[], const char args[], bool lgHeader, bool lgData, bool lgCoef, double depth)
505 {
506  DEBUG_ENTRY( "mole_save()" );
507 
508  molecule *sp = findspecies(speciesname);
509 
510  if( sp == null_mole )
511  {
512  fprintf( punit, " Species %s could not be found. Note that labels are case-sensitive in this context.\n", speciesname );
513  return;
514  }
515 
516  void (*doTask)(FILE *punit, const Field& f);
517 
518  if (lgHeader)
519  doTask=doHeader;
520  else
521  doTask=doData;
522 
523  doTask(punit,Field("Depth","%.5e",depth));
524 
525  for (mole_reaction_i p
526  =mole_priv::reactab.begin(); p != mole_priv::reactab.end(); ++p)
527  {
528  const mole_reaction &rate = *p->second;
529  bool ipthis = false;
530 
531  for (int i=0;i<rate.nreactants && !ipthis;i++)
532  {
533  if( rate.reactants[i] == sp )
534  {
535  if( ( strcmp( args, "DEST" )==0 && isDestroyed(rate,i) ) ||
536  ( strcmp( args, "DFLT" )==0 && isDestroyed(rate,i) ) ||
537  ( strcmp( args, "CATA" )==0 && isCatalystReactant(rate,i) ) ||
538  strcmp( args, "ALL " )==0 )
539  ipthis = true;
540  }
541  }
542 
543  for(int i=0;i<rate.nproducts && !ipthis;i++)
544  {
545  if( rate.products[i] == sp )
546  {
547  if( ( strcmp( args, "CREA" )==0 && isCreated(rate,i) ) ||
548  ( strcmp( args, "DFLT" )==0 && isCreated(rate,i) ) ||
549  ( strcmp( args, "CATA" )==0 && isCatalystProduct(rate,i) ) ||
550  strcmp( args, "ALL " )==0 )
551  ipthis = true;
552  }
553  }
554 
555  if(ipthis)
556  {
557  double ratevi=0.0;
558  if (lgData)
559  {
560  ratevi = mole.reaction_rks[ rate.index ];
561  if( !lgCoef )
562  {
563  for(int i=0;i<rate.nreactants;i++)
564  {
565  ratevi *= mole.species[ rate.reactants[i]->index ].den;
566  }
567  }
568  }
569  fprintf(punit,"\t");
570 
571  doTask(punit,Field(rate.label.c_str(),"%.3e",ratevi));
572  }
573  }
574  fprintf(punit,"\n");
575 }
576 
577 // Helper class for sorting rates
578 class RateCmp
579 {
580  const vector<double>& m_stack;
581 public:
582  RateCmp(const vector<double>& stack) : m_stack(stack) {}
583  bool operator()(size_t a, size_t b)
584  {
585  return m_stack[a] > m_stack[b];
586  }
587 };
588 
589 void mole_dominant_rates( const vector<const molecule*>& debug_list,
590  FILE *ioOut,
591  bool lgPrintReagents, size_t NPRINT, double fprint )
592 {
593  vector<double> snkx, srcx;
594  vector<mole_reaction *> ratesnk, ratesrc;
595 
596  double src_total = 0.0, snk_total = 0.0;
597 
598  for(mole_reaction_i p=mole_priv::reactab.begin();
599  p != mole_priv::reactab.end(); ++p)
600  {
601  mole_reaction *rate = &(*p->second);
602  double rk = mole.reaction_rks[ rate->index ];
603 
604  double rate_tot = rk;
605  for(long i=0;i<rate->nreactants;i++)
606  {
607  rate_tot *= mole.species[ rate->reactants[i]->index ].den;
608  }
609 
610  int nrate=0;
611  for(size_t s=0; s<debug_list.size(); ++s)
612  {
613  for(long i=0;i<rate->nproducts;++i)
614  {
615  molecule *sp = rate->products[i];
616  if (sp == debug_list[s] && rate->pvector[i] == NULL)
617  {
618  ++nrate;
619  }
620  }
621  for(long i=0;i<rate->nreactants;++i)
622  {
623  molecule *sp = rate->reactants[i];
624  if (sp == debug_list[s] && rate->rvector[i] == NULL)
625  {
626  --nrate;
627  }
628  }
629  }
630  if (nrate > 0)
631  {
632  srcx.push_back(nrate*rate_tot);
633  ratesrc.push_back(rate);
634  src_total += nrate*rate_tot;
635  }
636  else if (nrate < 0)
637  {
638  snkx.push_back(-nrate*rate_tot);
639  ratesnk.push_back(rate);
640  snk_total -= nrate*rate_tot;
641  }
642  }
643 
644  if (!ratesrc.empty())
645  {
646  vector<size_t> isrc(ratesrc.size());
647  for (size_t i=0; i<ratesrc.size(); ++i)
648  isrc[i] = i;
649  sort(isrc.begin(),isrc.end(),RateCmp(srcx));
650 
651  fprintf( ioOut, "Src %13.7g: ",src_total);
652  for (size_t i=0; i<ratesrc.size(); ++i)
653  {
654  if (i == NPRINT || srcx[isrc[i]] < fprint*src_total)
655  {
656  break;
657  }
658  fprintf( ioOut, "%20.20s %13.7g",
659  ratesrc[isrc[i]]->label.c_str(),srcx[isrc[i]]);
660  if (lgPrintReagents)
661  {
662  fprintf( ioOut, " [");
663  for (long j=0;j<ratesrc[isrc[i]]->nreactants;j++)
664  {
665  if (j)
666  {
667  fprintf( ioOut, "," );
668  }
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);
672  }
673  fprintf( ioOut, "]" );
674  }
675  else
676  {
677  fprintf( ioOut, ";" );
678  }
679  }
680  }
681  if (!ratesnk.empty())
682  {
683  vector<size_t> isnk(ratesnk.size());
684  for (size_t i=0; i<ratesnk.size(); ++i)
685  isnk[i] = i;
686  sort(isnk.begin(),isnk.end(),RateCmp(snkx));
687 
688  fprintf( ioOut, " Snk %13.7g: ", snk_total);
689  for (size_t i=0; i<ratesnk.size(); ++i)
690  {
691  if (i == NPRINT || snkx[isnk[i]] < fprint*snk_total)
692  {
693  break;
694  }
695  fprintf( ioOut, "%20.20s %13.7g",
696  ratesnk[isnk[i]]->label.c_str(), snkx[isnk[i]] );
697  if (lgPrintReagents)
698  {
699  fprintf( ioOut, " [" );
700  for (long j=0;j<ratesnk[isnk[i]]->nreactants;j++)
701  {
702  if (j)
703  {
704  fprintf( ioOut, "," );
705  }
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);
709  }
710  fprintf( ioOut, "]" );
711  }
712  else
713  {
714  fprintf( ioOut, ";" );
715  }
716  }
717  }
718  fprintf( ioOut, "\n" );
719 
720  return;
721 }
722 
723 void mole_print_species_reactions( molecule *speciesToPrint )
724 {
725  if( speciesToPrint==NULL )
726  {
727  fprintf( ioQQQ,"\n NULL species found in mole_print_species_reactions.\n" );
728  return;
729  }
730 
731  long numReacts = 0;
732 
733  fprintf( ioQQQ,"\n Reactions involving species %s:\n", speciesToPrint->label.c_str() );
734  for( mole_reaction_i p=mole_priv::reactab.begin(); p!=mole_priv::reactab.end(); ++p )
735  {
736  mole_reaction &rate = *p->second;
737  for( long i=0; i<rate.nreactants; i++ )
738  {
739  molecule *sp = rate.reactants[i];
740  if(rate.rvector[i]==NULL && sp==speciesToPrint )
741  {
742  double drate = mole.reaction_rks[ rate.index ];
743  for (long j=0; j<rate.nreactants; ++j)
744  {
745  drate *= mole.species[ rate.reactants[j]->index ].den;
746  }
747  fprintf( ioQQQ,"%s rate = %g\n", rate.label.c_str(), drate );
748  numReacts++;
749  }
750  }
751  for( long i=0; i<rate.nproducts; i++ )
752  {
753  molecule *sp = rate.products[i];
754  if(rate.pvector[i]==NULL && sp==speciesToPrint )
755  {
756  double drate = mole.reaction_rks[ rate.index ];
757  for (long j=0; j<rate.nreactants; ++j)
758  {
759  drate *= mole.species[ rate.reactants[j]->index ].den;
760  }
761  fprintf( ioQQQ,"%s rate = %g\n", rate.label.c_str(), drate );
762  numReacts++;
763  }
764  }
765  }
766  fprintf( ioQQQ," End of reactions involving species %s. There were %li.\n", speciesToPrint->label.c_str(), numReacts );
767 
768  return;
769 }
molecule * reactants[MAXREACTANTS]
Definition: mole_priv.h:53
t_mole_global mole_global
Definition: mole.cpp:7
vector< double > reaction_rks
Definition: mole.h:470
void prt_wl(FILE *ioOUT, realnum wl)
Definition: prt.cpp:44
STATIC void PrintShortZero(FILE *ioPUN, const char *chFmt, double arg)
STATIC long int ipPun
Definition: save_do.cpp:721
molecule * null_mole
NORETURN void TotalInsanity(void)
Definition: service.cpp:1067
double depart(const genericState &gs)
STATIC void doHeader(FILE *punit, const Field &f)
STATIC bool isCreated(const mole_reaction &rate, int i)
double value() const
int nreactants
Definition: mole_priv.h:52
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)
TransitionList * lines
Definition: mole.h:418
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)
FILE * ioQQQ
Definition: cddefines.cpp:7
FILE * ipPnunit
Definition: save.h:188
Definition: mole.h:378
Definition: mole.h:142
STATIC void SaveSpeciesOne(const vector< genericState > &SpeciesList, double(*job)(const genericState &), bool lgZonal, const char *chFmt, FILE *ioPUN)
double m_value
const char * label
void mole_save(FILE *punit, const char speciesname[], const char args[], bool lgHeader, bool lgData, bool lgCoef, double depth)
t_dense dense
Definition: global.cpp:15
void SaveAllSpeciesLabelsLevels(FILE *ioPUN)
RateCmp(const vector< double > &stack)
void SaveSpeciesOptDep(const long int ipPun, const string &speciesLabel)
molecule * products[MAXPRODUCTS]
Definition: mole_priv.h:56
const char * fmt
qList * levels
Definition: mole.h:417
string label
Definition: mole_priv.h:51
STATIC bool isCatalystReactant(const mole_reaction &rate, int i)
molecule * rvector[MAXREACTANTS]
Definition: mole_priv.h:54
double energy(const genericState &gs)
#define STATIC
Definition: cddefines.h:118
char chSaveArgs[LIMPUN][5]
Definition: save.h:368
void chemical_to_spectral(const string chLabelChem, string &chLabelSpec)
Definition: species.cpp:981
t_mole_local mole
Definition: mole.cpp:8
map< string, count_ptr< mole_reaction > >::iterator mole_reaction_i
Definition: mole_priv.h:38
molecule * findspecies(const char buf[])
float realnum
Definition: cddefines.h:124
valarray< class molezone > species
Definition: mole.h:468
#define EXIT_FAILURE
Definition: cddefines.h:168
STATIC void SaveSpeciesLines(FILE *ioPUN, const vector< genericState > &speciesList)
bool lgSaveDataRates
Definition: save.h:488
size_t size() const
Definition: quantumstate.h:131
#define cdEXIT(FAIL)
Definition: cddefines.h:484
int index
Definition: mole.h:194
Field(const char *label, const char *fmt, double value)
double depth_mid_zone
Definition: radius.h:31
t_iterations iterations
Definition: iterations.cpp:6
double column(const genericState &gs)
const molezone * sp
Definition: generic_state.h:19
t_radius radius
Definition: radius.cpp:5
SaveParams params[LIMPUN]
Definition: save.h:269
bool lgElmtOn[LIMELM]
Definition: dense.h:160
STATIC void doData(FILE *punit, const Field &f)
double levels(const genericState &gs)
void SaveHeaderDone(int ipPun)
Definition: save.h:349
#define ASSERT(exp)
Definition: cddefines.h:617
bool lgLastIt
Definition: iterations.h:47
molecule * pvector[MAXPRODUCTS]
Definition: mole_priv.h:57
void mole_dominant_rates(const vector< const molecule * > &debug_list, FILE *ioOut, bool lgPrintReagents, size_t NPRINT, double fprint)
double density(const genericState &gs)
bool lgSaveDataGf
Definition: save.h:488
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:729
const bool lgRowPerZone
string label
Definition: mole.h:156
void SaveSpecies(FILE *ioPUN, long int ipPun)
#define MAX2(a, b)
Definition: cddefines.h:828
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1217
MoleculeList list
Definition: mole.h:365
vector< string > chSaveSpecies[LIMPUN]
Definition: save.h:370
molecule * rvector_excit[MAXREACTANTS]
Definition: mole_priv.h:55
string label() const
bool lgSaveDataWn
Definition: save.h:488
t_save save
Definition: save.cpp:5
STATIC bool isDestroyed(const mole_reaction &rate, int i)
bool lgSaveHeader(int ipPun) const
Definition: save.h:345
molezone * null_molezone
bool operator()(size_t a, size_t b)
void mole_print_species_reactions(molecule *speciesToPrint)
molecule * pvector_excit[MAXPRODUCTS]
Definition: mole_priv.h:58