cloudy  trunk
 All Data Structures Namespaces 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-2022 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 "cosmology.h"
6 #include "radius.h"
7 #include "rfield.h"
8 #include "parser.h"
9 
11 {
12  double a,
13  fac,
14  rlogl,
15  z;
16 
17  DEBUG_ENTRY( "ParseBackgrd()" );
18 
19  /* check that stack of shape and luminosity specifications
20  * is parallel, stop if not - this happens is background comes
21  * BETWEEN another set of shape and luminosity commands */
22  if( rfield.nShape != p.m_nqh )
23  {
24  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" );
25  fprintf( ioQQQ, " Sorry.\n" );
27  }
28 
29  /* diffuse x-ray background from
30  * >>refer cosmic background Ostriker and Ikeuchi ApJL 268, L63.
31  * parameter on cmnd is redshift, followed by optional J21
32  * >>refer cosmic background Ikeuchi, S.; Ostriker, J. P., 1986, ApJ 301, 522 */
33 
34  /* >>chng 02 aug 12, do not try to enter bare powerlaw, use table power law default instead */
35  {
36  // There must be a neater way than this to extract the
37  // functionality from ParseTable...
38  p.set_point(0);
39  string cmdSave = p.getRawTail();
40  p.setline("TABLE POWERLAW ");
41  ParseTable( p );
42  p.setline(cmdSave.c_str());
43  p.set_point(4);
44  }
45 
46  /* now generate equivalent of luminosity command
47  * enter phi(h), the number of h-ionizing photons/cm2 */
48 
49  strcpy( rfield.chRSpec[p.m_nqh], "SQCM" );
50  strcpy( rfield.chSpNorm[p.m_nqh], "FLUX" );
51  /* this is an isotropic radiation field */
52  rfield.lgBeamed[p.m_nqh] = false;
54 
55  /* this will be the redshift */
56  z = p.FFmtRead();
57  if( p.lgEOL() )
58  z = 0.;
59 
60  /* optional scale factor */
61  fac = p.FFmtRead();
62  if( p.lgEOL() )
63  fac = 1.0;
64 
65  /* this equation from Ostriker and Ikeuchi Ap.J.L 268, L63.
66  * this should be J_nu into 4\pi sr
67  * >>chng 96 jul 23, from ostriker to vedel, et al mnras 271, 743. */
68  rfield.totpow[p.m_nqh] = (log10(PI4*fac*1.e-21/
69  (1.+powi(5./(1.+z),4))));
70 
71  /* this is at 1 ryd for H
72  * range(nqh,1) = 1.
73  *>>chgn 96 dec 18, to H ioniz pot from 1 ryd */
74  rfield.range[p.m_nqh][0] = HIONPOT;
75 
76  ++p.m_nqh;
77  if( p.m_nqh >= LIMSPC )
78  {
79  fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
81  }
82 
83  /* add fireball unless NO FIREBALL or NO CMP in */
84  if( !(p.nMatch("NO FI") || p.nMatch("NO CM") ) )
85  {
86 
87  /* put in a black body */
88  strcpy( rfield.chSpType[rfield.nShape], "BLACK" );
89  /* >>chng 03 may 23, CMB temp from 2.756 to 2.725 */
90  rfield.slope[rfield.nShape] = (CMB_TEMP*(1. + z));
91  rfield.cutoff[rfield.nShape][0] = 0.;
92  rfield.cutoff[rfield.nShape][1] = 0.;
93  strcpy( rfield.chSpNorm[p.m_nqh], "LUMI" );
94  a = log10(rfield.slope[rfield.nShape]);
95  rlogl = log10(4.*STEFAN_BOLTZ) + 4.*a;
96  strcpy( rfield.chRSpec[p.m_nqh], "SQCM" );
97  rfield.range[p.m_nqh][0] = rfield.emm();
98  rfield.range[p.m_nqh][1] = rfield.egamry();
99  rfield.totpow[p.m_nqh] = rlogl;
100 
101  /* this flag says that CMB has been set */
102  rfield.lgCMB_set = true;
103 
104  ++rfield.nShape;
105  ++p.m_nqh;
106  if( p.m_nqh >= LIMSPC )
107  {
108  fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
110  }
111  }
112 }
double emm() const
Definition: mesh.h:93
bool nMatch(const char *chKey) const
Definition: parser.h:150
bool lgBeamed[LIMSPC]
Definition: rfield.h:294
double FFmtRead(void)
Definition: parser.cpp:472
void setline(const char *const card)
Definition: parser.h:82
void ParseBackgrd(Parser &p)
long int m_nqh
Definition: parser.h:54
double totpow[LIMSPC]
Definition: rfield.h:284
char chRSpec[LIMSPC][5]
Definition: rfield.h:335
void ParseTable(Parser &p)
Definition: parse_table.cpp:94
FILE * ioQQQ
Definition: cddefines.cpp:7
Definition: parser.h:43
double cutoff[LIMSPC][3]
Definition: rfield.h:284
double range[LIMSPC][2]
Definition: rfield.h:331
const int LIMSPC
Definition: rfield.h:21
double slope[LIMSPC]
Definition: rfield.h:284
string getRawTail()
Definition: parser.h:217
void set_point(long int ipnt)
Definition: parser.h:95
bool lgCMB_set
Definition: rfield.h:106
t_rfield rfield
Definition: rfield.cpp:9
#define EXIT_FAILURE
Definition: cddefines.h:168
Illuminate::IlluminationType Illumination[LIMSPC]
Definition: rfield.h:300
#define cdEXIT(FAIL)
Definition: cddefines.h:482
double powi(double, long int)
Definition: service.cpp:594
char chSpNorm[LIMSPC][5]
Definition: rfield.h:335
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
double egamry() const
Definition: mesh.h:97
#define CMB_TEMP
Definition: cosmology.h:10
bool lgEOL(void) const
Definition: parser.h:113
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1121
long int nShape
Definition: rfield.h:306
char chSpType[LIMSPC][6]
Definition: rfield.h:335