cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
molcol.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 /*molcol generate and print molecular column densities */
4 #include "cddefines.h"
5 #include "molcol.h"
6 #include "radius.h"
7 #include "h2.h"
8 #include "mole.h"
9 #include "prt.h"
10 
11 void molcol(
12  const char *chLabel,
13  /* file for printout */
14  FILE *ioMEAN )
15 {
16  long int i;
17 
18  DEBUG_ENTRY( "molcol()" );
19 
20  // Call column density routines for individual diatom models
21  for( diatom_iter diatom = diatoms.begin(); diatom != diatoms.end(); ++diatom )
22  (*diatom)->H2_Colden( chLabel );
23 
24  if( strcmp(chLabel,"ZERO") == 0 )
25  {
26  /* zero out the column densities */
27  for( i=0; i < mole_global.num_calc; i++ )
28  {
29  mole.species[i].column = 0.;
30  }
31  }
32 
33  else if( strcmp(chLabel,"ADD ") == 0 )
34  {
35  /* add together column densities */
36  for( i=0; i < mole_global.num_calc; i++ )
37  {
38  mole.species[i].column += (realnum)(mole.species[i].den*radius.drad_x_fillfac);
39  }
40  }
41 
42  else if( strcmp(chLabel,"PRIN") == 0 )
43  {
44  bool lgFirstPrint = true;
45  /* print the molecular column densities */
46  int j=0;
47  chem_nuclide *heavyAtom = null_nuclide;
48  for( i=0; i < mole_global.num_calc; i++ )
49  {
50  if(mole.species[i].location == NULL && ( !mole_global.list[i]->isMonatomic() || !mole_global.list[i]->lgGas_Phase ) && mole.species[i].global()->n_react > 0 )
51  {
52  chem_nuclide* lastHeavyAtom = heavyAtom;
53  heavyAtom = mole_global.list[i]->heavyAtom();
54  int len = 11+CHARS_SPECIES;
55  if(j+len > NCOLMAX || heavyAtom != lastHeavyAtom)
56  {
57  fprintf( ioMEAN, "\n" );
58  if (heavyAtom != lastHeavyAtom)
59  {
60  fprintf ( ioMEAN, "==== %-*.*s compounds ====",
61  CHARS_ISOTOPE_SYM, CHARS_ISOTOPE_SYM, heavyAtom->label().c_str() );
62  if( lgFirstPrint )
63  {
64  fprintf ( ioMEAN, " Log10 column densities [cm^-2]");
65  lgFirstPrint = false;
66  }
67  fprintf(ioMEAN, "\n");
68  }
69  j = 0;
70  }
71  fprintf( ioMEAN, " %-*.*s:", CHARS_SPECIES, CHARS_SPECIES, mole_global.list[i]->label.c_str() );
72  fprintf( ioMEAN, "%7.3f",log10(MAX2(SMALLFLOAT,mole.species[i].column )));
73  j+=len;
74  }
75  }
76  if (j != 0)
77  fprintf( ioMEAN, "\n" );
78  }
79 
80  else
81  {
82  fprintf( ioMEAN, " molcol does not understand the label %4.4s\n",
83  chLabel );
85  }
86  return;
87 
88 }
t_mole_global mole_global
Definition: mole.cpp:7
const long NCOLMAX
Definition: prt.h:13
int num_calc
Definition: mole.h:362
const realnum SMALLFLOAT
Definition: cpu.h:246
chem_nuclide * null_nuclide
t_mole_local mole
Definition: mole.cpp:8
float realnum
Definition: cddefines.h:124
valarray< class molezone > species
Definition: mole.h:468
#define EXIT_FAILURE
Definition: cddefines.h:168
vector< diatomics * > diatoms
Definition: h2.cpp:8
#define cdEXIT(FAIL)
Definition: cddefines.h:484
void molcol(const char *chLabel, FILE *ioMEAN)
Definition: molcol.cpp:11
t_radius radius
Definition: radius.cpp:5
double drad_x_fillfac
Definition: radius.h:76
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:729
#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
string label(void) const
Definition: mole.h:66
vector< diatomics * >::iterator diatom_iter
Definition: h2.h:13