cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
parse_agn.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 /*ParseAgn parse parameters for the AGN continuum shape command */
4 #include "cddefines.h"
5 #include "rfield.h"
6 #include "input.h"
7 #include "optimize.h"
8 #include "parser.h"
9 
10 void ParseAgn(Parser &p)
11 {
12  double BigBump,
13  Ratio,
14  XRays,
15  xnu;
16 
17  DEBUG_ENTRY( "ParseAgn()" );
18 
19  /* this radiation field will be something like an AGN */
20  strcpy( rfield.chSpType[rfield.nShape], "AGN " );
21 
22  /* there were no numbers on the line - this could be the Kirk option,
23  * to use the numbers for the continuum in the atlas paper */
24  if( p.nMatch("KIRK") )
25  {
26  /* million degree cutoff, but in rydbergs */
27  rfield.slope[rfield.nShape] = 1e6 / TE1RYD;
28 
29  /* cutoff is second parameter is really alpha ox */
30  rfield.cutoff[rfield.nShape][0] = -1.40;
31 
32  /* bb slope is third parameter */
33  rfield.cutoff[rfield.nShape][1] = -0.50;
34 
35  /* slope of X-Ray component is last parameter */
36  rfield.cutoff[rfield.nShape][2] = -1.0;
37  }
38  else
39  {
40  /* first parameter is temperature of big bump
41  * second parameter is alpha ox */
42  /* slope is first parameter is really temperature of bump */
44  if( p.lgEOL() )
45  {
46 
47  fprintf( ioQQQ, " The big bump temperature should have been on this line. Sorry.\n" );
49  }
50 
51  if( rfield.slope[rfield.nShape] <= 0. )
52  {
53  fprintf( ioQQQ, " Non positive temperature not allowed. Sorry.\n" );
55  }
56 
57  /* temps are log if first le 10 */
58  if( rfield.slope[rfield.nShape] <= 10. )
61 
62  /* want cutoff in ryd not kelvin */
63  rfield.slope[rfield.nShape] /= TE1RYD;
64 
65  /* cutoff is second parameter is really alpha ox */
67  if( p.lgEOL() )
68  {
69  fprintf( ioQQQ, " alpha ox should have been on this line. Sorry.\n" );
71  }
72 
73  if( rfield.cutoff[rfield.nShape][0] > 3. ||
74  rfield.cutoff[rfield.nShape][0] < -3. )
75  {
76  fprintf( ioQQQ, " An alpha ox of%10.2e looks funny to me. Check Hazy to make sure its ok.\n",
77  rfield.cutoff[rfield.nShape][0] );
78  }
79 
80  if( rfield.cutoff[rfield.nShape][0] >= 0. )
81  {
82  fprintf( ioQQQ, " The sign of alpha ox is almost certainly incorrect. Check Hazy.\n" );
83  }
84 
85  /* bb slope is third parameter */
87  if( p.lgEOL() )
88  rfield.cutoff[rfield.nShape][1] = -0.5f;
89 
90  /* slope of X-Ray component is last parameter */
92  if( p.lgEOL() )
93  rfield.cutoff[rfield.nShape][2] = -1.0f;
94  }
95 
96  /* 403.3 is ratio of energies where alpha ox defined,
97  * assumed to be 2500A and 2keV */
98  Ratio = pow(403.3,rfield.cutoff[rfield.nShape][0] - 1.);
99 
100  /* following code must be kept parallel with ffun1 */
101  xnu = 0.3645;
102  BigBump = pow(xnu,-1. + rfield.cutoff[rfield.nShape][1])*
103  sexp(xnu/rfield.slope[rfield.nShape]);
104  xnu = 147.;
105 
106  /* XRays = xnu**(-2.) */
107  XRays = pow(xnu,rfield.cutoff[rfield.nShape][2] - 1.);
108  if( BigBump <= 0. )
109  {
110  fprintf( ioQQQ, " Big Bump had zero flux at .3645 Ryd.\n" );
112  }
113  realnum SaveCutoff = (realnum)rfield.cutoff[rfield.nShape][0];
114  rfield.cutoff[rfield.nShape][0] = (Ratio/(XRays/BigBump));
115 
116  /* vary option */
117  if( optimize.lgVarOn )
118  {
119  /* AGN with its four parameters */
120  strcpy( optimize.chVarFmt[optimize.nparm], "AGN LOG T=%f, a(ox)=%f a(uv)=%f a(x)=%f" );
122  // specified in K but stored in Ryd, need log of temp stored here
123  optimize.vparm[0][optimize.nparm] = (realnum)log10(rfield.slope[rfield.nShape]*TE1RYD);
124  optimize.vparm[1][optimize.nparm] = SaveCutoff;
127 
128  /* pointer to where to write */
130  /* the increment in the first steps away from the original value */
131  optimize.vincr[optimize.nparm] = 0.5f;
132  ++optimize.nparm;
133  }
134 
135 
136  /* lastly increment number of spectra and check that we still have room in the vector */
137  ++rfield.nShape;
138  if( rfield.nShape >= LIMSPC )
139  {
140  fprintf( ioQQQ, " Too many continua entered; increase LIMSPC\n" );
142  }
143  return;
144 }
bool nMatch(const char *chKey) const
Definition: parser.h:150
void ParseAgn(Parser &p)
Definition: parse_agn.cpp:10
double FFmtRead(void)
Definition: parser.cpp:472
double exp10(double x)
Definition: cddefines.h:1368
t_input input
Definition: input.cpp:12
long int nvfpnt[LIMPAR]
Definition: optimize.h:198
long int nRead
Definition: input.h:105
sys_float sexp(sys_float x)
Definition: service.cpp:999
char chVarFmt[LIMPAR][FILENAME_PATH_LENGTH_2]
Definition: optimize.h:267
FILE * ioQQQ
Definition: cddefines.cpp:7
realnum vparm[LIMEXT][LIMPAR]
Definition: optimize.h:192
Definition: parser.h:43
double cutoff[LIMSPC][3]
Definition: rfield.h:284
bool lgVarOn
Definition: optimize.h:207
const int LIMSPC
Definition: rfield.h:21
double slope[LIMSPC]
Definition: rfield.h:284
long int nparm
Definition: optimize.h:204
t_rfield rfield
Definition: rfield.cpp:9
float realnum
Definition: cddefines.h:124
#define EXIT_FAILURE
Definition: cddefines.h:168
#define cdEXIT(FAIL)
Definition: cddefines.h:482
t_optimize optimize
Definition: optimize.cpp:6
realnum vincr[LIMPAR]
Definition: optimize.h:195
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:723
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
long int nvarxt[LIMPAR]
Definition: optimize.h:198
char chSpType[LIMSPC][6]
Definition: rfield.h:335