cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_backgrd.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*ParseBackgrd parse options for the BACKGROUND command - this actually enters two continua*/
4 #include "cddefines.h"
5 #include "physconst.h"
6 #include "radius.h"
7 #include "rfield.h"
8 #include "parse.h"
9 
10 void ParseBackgrd(long int *nqh,
11  char *chCard,
12  realnum *ar1)
13 {
14  bool lgEOL;
15  long int i;
16  double a,
17  fac,
18  rlogl,
19  z;
20  char chLocal[INPUT_LINE_LENGTH];
21 
22  DEBUG_ENTRY( "ParseBackgrd()" );
23 
24  /* check that stack of shape and luminosity specifications
25  * is parallel, stop if not - this happens is background comes
26  * BETWEEN another set of shape and luminosity commands */
27  if( rfield.nspec != *nqh )
28  {
29  fprintf( ioQQQ, " This command has come between a previous ordered pair of continuum shape and luminosity commands.\n Reorder the commands to complete each continuum specification before starting another.\n" );
30  fprintf( ioQQQ, " Sorry.\n" );
31  cdEXIT(EXIT_FAILURE);
32  }
33 
34  /* diffuse x-ray background from
35  * >>refer cosmic background Ostriker and Ikeuchi ApJL 268, L63.
36  * parameter on cmnd is redshift, followed by optional J21
37  * >>refer cosmic background Ikeuchi, S.; Ostriker, J. P., 1986, ApJ 301, 522 */
38 
39  /* >>chng 02 aug 12, do not try to enter bare powerlaw, use table power law default instead */
40  strcpy( chLocal, "TABLE POWERLAW " );
41  ParseTable( nqh, chLocal , ar1);
42 
43  /* now generate equivalent of luminosity command
44  * enter phi(h), the number of h-ionizing photons/cm2 */
45 
46  strcpy( rfield.chRSpec[*nqh], "SQCM" );
47  strcpy( rfield.chSpNorm[*nqh], "FLUX" );
48  /* this is an isotropic radiation field */
49  rfield.lgBeamed[*nqh] = false;
50 
51  i = 5;
52  /* this will be the redshift */
53  z = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
54  if( lgEOL )
55  {
56  z = 0.;
57  }
58 
59  /* optional scale factor */
60  fac = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL);
61  if( lgEOL )
62  {
63  fac = 1.0;
64  }
65 
66  /* this equation from Ostriker and Ikeuchi Ap.J.L 268, L63.
67  * this should be J_nu into 4\pi sr
68  * >>chng 96 jul 23, from ostriker to vedel, et al mnras 271, 743. */
69  rfield.totpow[*nqh] = (log10(PI4*fac*1.e-21/
70  (1.+powi(5./(1.+z),4))));
71 
72  /* this is at 1 ryd for H
73  * range(nqh,1) = 1.
74  *>>chgn 96 dec 18, to H ioniz pot from 1 ryd */
75  rfield.range[*nqh][0] = HIONPOT;
76 
77  /* >>chng 02 aug 12, call table power law routine rather than try to enter spec here,
78  * so no longer increment nspec */
79  /* increment continuum indices
80  ++rfield.nspec;
81  if( rfield.nspec >= LIMSPC )
82  {
83  fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
84  cdEXIT(EXIT_FAILURE);
85  } */
86  ++*nqh;
87  if( *nqh >= LIMSPC )
88  {
89  fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
90  cdEXIT(EXIT_FAILURE);
91  }
92 
93  /* add fireball unless NO FIREBALL or NO CMP in */
94  if( !(nMatch("O FI",chCard) || nMatch("O CM",chCard) ) )
95  {
96 
97  /* put in a black body */
98  strcpy( rfield.chSpType[rfield.nspec], "BLACK" );
99  /* >>chng 03 may 23, CMB temp from 2.756 to 2.725 */
100  rfield.slope[rfield.nspec] = (CMB_TEMP*(1. + z));
101  rfield.cutoff[rfield.nspec][0] = 0.;
102  rfield.cutoff[rfield.nspec][1] = 0.;
103  strcpy( rfield.chSpNorm[*nqh], "LUMI" );
104  a = log10(rfield.slope[rfield.nspec]);
105  rlogl = log10(4.*STEFAN_BOLTZ) + 4.*a;
106  strcpy( rfield.chRSpec[*nqh], "SQCM" );
107  rfield.range[*nqh][0] = rfield.emm;
108  rfield.range[*nqh][1] = rfield.egamry;
109  rfield.totpow[*nqh] = rlogl;
110 
111  /* this flag says that CMB has been set */
112  rfield.lgCMB_set = true;
113 
114  ++rfield.nspec;
115  ++*nqh;
116  if( *nqh >= LIMSPC )
117  {
118  fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
119  cdEXIT(EXIT_FAILURE);
120  }
121  }
122 
123  /* set radius to very large value if not already set */
124  /* >>chng 01 jul 24, from Radius == 0 to this, as per PvH comments */
125  if( !radius.lgRadiusKnown )
126  {
127  *ar1 = (realnum)radius.rdfalt;
128  radius.Radius = pow(10.,radius.rdfalt);
129  }
130  return;
131 }

Generated for cloudy by doxygen 1.8.4