cloudy trunk
Loading...
Searching...
No Matches
parse_backgrd.cpp
Go to the documentation of this file.
1/* This file is part of Cloudy and is copyright (C)1978-2013 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 "physconst.h"
7#include "radius.h"
8#include "rfield.h"
9#include "parser.h"
10
12{
13 double a,
14 fac,
15 rlogl,
16 z;
17
18 DEBUG_ENTRY( "ParseBackgrd()" );
19
20 /* check that stack of shape and luminosity specifications
21 * is parallel, stop if not - this happens is background comes
22 * BETWEEN another set of shape and luminosity commands */
23 if( rfield.nShape != p.m_nqh )
24 {
25 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" );
26 fprintf( ioQQQ, " Sorry.\n" );
28 }
29
30 /* diffuse x-ray background from
31 * >>refer cosmic background Ostriker and Ikeuchi ApJL 268, L63.
32 * parameter on cmnd is redshift, followed by optional J21
33 * >>refer cosmic background Ikeuchi, S.; Ostriker, J. P., 1986, ApJ 301, 522 */
34
35 /* >>chng 02 aug 12, do not try to enter bare powerlaw, use table power law default instead */
36 {
37 // There must be a neater way than this to extract the
38 // functionality from ParseTable...
39 p.set_point(0);
40 string cmdSave = p.getRawTail();
41 p.setline("TABLE POWERLAW ");
42 ParseTable( p );
43 p.setline(cmdSave.c_str());
44 p.set_point(4);
45 }
46
47 /* now generate equivalent of luminosity command
48 * enter phi(h), the number of h-ionizing photons/cm2 */
49
50 strcpy( rfield.chRSpec[p.m_nqh], "SQCM" );
51 strcpy( rfield.chSpNorm[p.m_nqh], "FLUX" );
52 /* this is an isotropic radiation field */
53 rfield.lgBeamed[p.m_nqh] = false;
54 rfield.Illumination[p.m_nqh] = Illuminate::SYMMETRIC;
55
56 /* this will be the redshift */
57 z = p.FFmtRead();
58 if( p.lgEOL() )
59 z = 0.;
60
61 /* optional scale factor */
62 fac = p.FFmtRead();
63 if( p.lgEOL() )
64 fac = 1.0;
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[p.m_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[p.m_nqh][0] = HIONPOT;
76
77 ++p.m_nqh;
78 if( p.m_nqh >= LIMSPC )
79 {
80 fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
82 }
83
84 /* add fireball unless NO FIREBALL or NO CMP in */
85 if( !(p.nMatch("NO FI") || p.nMatch("NO CM") ) )
86 {
87
88 /* put in a black body */
89 strcpy( rfield.chSpType[rfield.nShape], "BLACK" );
90 /* >>chng 03 may 23, CMB temp from 2.756 to 2.725 */
91 rfield.slope[rfield.nShape] = (CMB_TEMP*(1. + z));
92 rfield.cutoff[rfield.nShape][0] = 0.;
93 rfield.cutoff[rfield.nShape][1] = 0.;
94 strcpy( rfield.chSpNorm[p.m_nqh], "LUMI" );
95 a = log10(rfield.slope[rfield.nShape]);
96 rlogl = log10(4.*STEFAN_BOLTZ) + 4.*a;
97 strcpy( rfield.chRSpec[p.m_nqh], "SQCM" );
98 rfield.range[p.m_nqh][0] = rfield.emm;
99 rfield.range[p.m_nqh][1] = rfield.egamry;
100 rfield.totpow[p.m_nqh] = rlogl;
101
102 /* this flag says that CMB has been set */
103 rfield.lgCMB_set = true;
104
105 ++rfield.nShape;
106 ++p.m_nqh;
107 if( p.m_nqh >= LIMSPC )
108 {
109 fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
111 }
112 }
113
114 /* set radius to very large value if not already set */
115 /* >>chng 01 jul 24, from Radius == 0 to this, as per PvH comments */
116 if( !radius.lgRadiusKnown )
117 {
118 radius.Radius = pow(10.,radius.rdfalt);
119 }
120 return;
121}
FILE * ioQQQ
Definition cddefines.cpp:7
#define EXIT_FAILURE
Definition cddefines.h:140
#define cdEXIT(FAIL)
Definition cddefines.h:434
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
double powi(double, long int)
Definition service.cpp:604
double FFmtRead(void)
Definition parser.cpp:353
bool nMatch(const char *chKey) const
Definition parser.h:135
void setline(const char *const card)
Definition parser.h:69
void set_point(long int ipnt)
Definition parser.h:77
bool lgEOL(void) const
Definition parser.h:98
long int m_nqh
Definition parser.h:41
string getRawTail()
Definition parser.h:220
#define CMB_TEMP
Definition cosmology.h:10
@ SYMMETRIC
Definition rfield.h:30
void ParseBackgrd(Parser &p)
void ParseTable(Parser &p)
UNUSED const double STEFAN_BOLTZ
Definition physconst.h:210
UNUSED const double PI4
Definition physconst.h:35
UNUSED const double HIONPOT
Definition physconst.h:119
t_radius radius
Definition radius.cpp:5
t_rfield rfield
Definition rfield.cpp:8
const int LIMSPC
Definition rfield.h:18