cloudy  trunk
parse_tlaw.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 /*ParseTLaw parse parameters on the tlaw command to set temperature as function of depth,
4  * currently only does Bertoldi & Draine simple T law */
5 
6 /* Despite outward appearances, this routine has no connection whatsoever with
7  Bassetlaw (http://www.bassetlawmuseum.org.uk/) */
8 
9 #include "cddefines.h"
10 #include "thermal.h"
11 #include "parser.h"
12 
13 void ParseTLaw( Parser &p )
14 {
15  DEBUG_ENTRY( "ParseTLaw()" );
16 
17  /* this says that some type of temperature law has been specified */
18  thermal.lgTLaw = true;
21 
22  if( p.nMatch("DB96") )
23  {
24  /* this is to simulate the temperature law given by equation 41 in
25  * >>refer H2 temperature law Draine, B.T., & Bertoldi, Frank, 1996, ApJ, 468, 269-289 */
26  thermal.lgTeBD96 = true;
27 
28  /* this is the initial temperature for the BD96 temperature law */
29  thermal.T0BD96 = 500.f;
30  TempChange(thermal.T0BD96 , false);
31 
32  /* the coefficient on column density for temp dropoff */
33  thermal.SigmaBD96 = 6e-22f;
34  }
35  else if( p.nMatch("SN99") )
36  {
37  /* this is to simulate the temperature law given by equation 16 in
38  * >>refer H2 temperature law Sternberg, A., & Neufeld, D.A. 1999, ApJ, 516, 371-380 */
39  thermal.lgTeSN99 = true;
40 
41  /* this is the inital temperature for the BD96 temperature law */
42  thermal.T0SN99 = 500.f;
43  TempChange(thermal.T0SN99 , false);
44  }
45  else
46  {
47  fprintf(ioQQQ," There must be a keyword on this command. The one I know about is BD96\n");
49  }
50 
51 #if 0
52 #include "dense.h"
53 #include "optimize.h"
54 #include "input.h"
55  bool lgEnd;
56  long int j;
57  /* all remainder is currently dead code, a copy of DLAW command,
58  * which could be activated if needs arose */
59  /* call fcn dense_fabden(RADIUS) which uses the ten parameters
60  * N.B.; existing version of dense_fabden must be deleted
61  * >>chng 96 nov 29, added table option */
62  if( p.nMatch("TABL") )
63  {
64  /* when called, read in densities from input stream */
65  strcpy( dense.chDenseLaw, "DLW2" );
66  if( p.nMatch("DEPT") )
67  {
68  dense.lgDLWDepth = true;
69  }
70  else
71  {
72  dense.lgDLWDepth = false;
73  }
74 
75  p.getline();
76  dense.frad[0] = (realnum)p.FFmtRead();
77  dense.fhden[0] = (realnum)p.FFmtRead();
78  if( p.lgEOL() )
79  {
80  fprintf( ioQQQ, " No pairs entered - can\'t interpolate.\n Sorry.\n" );
82  }
83 
84  dense.nvals = 2;
85  lgEnd = false;
86 
87  /* read pairs of numbers until we find line starting with END */
88  while( !lgEnd && dense.nvals < LIMTABDLAW )
89  {
90  p.getline();
91  lgEnd = p.m_lgEOF;
92  if( !lgEnd )
93  {
94  if( p.strcmp("END") == 0 )
95  lgEnd = true;
96  }
97 
98  if( !lgEnd )
99  {
100  dense.frad[dense.nvals-1] = (realnum)p.FFmtRead();
102  dense.nvals += 1;
103  }
104  }
105  --dense.nvals;
106 
107  for( i=1; i < dense.nvals; i++ )
108  {
109  /* the radius values are assumed to be strictly increasing */
110  if( dense.frad[i] <= dense.frad[i-1] )
111  {
112  fprintf( ioQQQ, " density.in radii must be in increasing order\n" );
114  }
115  }
116  }
117  else
118  {
119  /* this is usual case, call dense_fabden to get density */
120  for( j=0; j < 10; j++ )
121  {
122  dense.DensityLaw[j] = p.FFmtRead();
123  }
124 
125  /* set flag so we know which law to use later */
126  strcpy( dense.chDenseLaw, "DLW1" );
127 
128  /* vary option */
129  if( optimize.lgVarOn )
130  {
131  /* NB - there are 5 = LIMEXT numbers on this line - if LIMEXT ever changes,
132  * chnage this too */
133  strcpy( optimize.chVarFmt[optimize.nparm], "DLAW %f %f %f %f %f " );
134 
135  /* index for where to write */
137  for( j=0; j<LIMEXT; ++j )
138  {
140  }
141  optimize.vincr[optimize.nparm] = 0.5;
143  ++optimize.nparm;
144  }
145  }
146 # endif
147  return;
148 }
thermal.h
Parser::nMatch
bool nMatch(const char *chKey) const
Definition: parser.h:135
t_optimize::vincr
realnum vincr[LIMPAR]
Definition: optimize.h:191
Parser::FFmtRead
double FFmtRead(void)
Definition: parser.cpp:353
t_dense::chDenseLaw
char chDenseLaw[5]
Definition: dense.h:158
dense
t_dense dense
Definition: dense.cpp:24
t_optimize::nparm
long int nparm
Definition: optimize.h:201
t_input::nRead
long int nRead
Definition: input.h:49
ioQQQ
FILE * ioQQQ
Definition: cddefines.cpp:7
TempChange
void TempChange(double TempNew, bool lgForceUpdate)
Definition: temp_change.cpp:51
realnum
float realnum
Definition: cddefines.h:103
t_optimize::lgVarOn
bool lgVarOn
Definition: optimize.h:203
Parser::m_lgEOF
bool m_lgEOF
Definition: parser.h:42
LIMEXT
const long LIMEXT
Definition: optimize.h:60
input
t_input input
Definition: input.cpp:12
t_dense::fhden
realnum fhden[LIMTABDLAW]
Definition: dense.h:181
t_thermal::lgTemperatureConstant
bool lgTemperatureConstant
Definition: thermal.h:32
optimize
t_optimize optimize
Definition: optimize.cpp:5
t_optimize::vparm
realnum vparm[LIMEXT][LIMPAR]
Definition: optimize.h:188
t_optimize::chVarFmt
char chVarFmt[LIMPAR][FILENAME_PATH_LENGTH_2]
Definition: optimize.h:263
EXIT_FAILURE
#define EXIT_FAILURE
Definition: cddefines.h:140
t_thermal::T0SN99
realnum T0SN99
Definition: thermal.h:79
Parser
Definition: parser.h:31
dense.h
t_dense::frad
realnum frad[LIMTABDLAW]
Definition: dense.h:180
Parser::getline
bool getline(void)
Definition: parser.cpp:164
cddefines.h
t_thermal::lgTLaw
bool lgTLaw
Definition: thermal.h:68
thermal
t_thermal thermal
Definition: thermal.cpp:5
optimize.h
ParseTLaw
void ParseTLaw(Parser &p)
Definition: parse_tlaw.cpp:13
t_optimize::nvarxt
long int nvarxt[LIMPAR]
Definition: optimize.h:194
t_thermal::lgTeSN99
bool lgTeSN99
Definition: thermal.h:80
t_thermal::T0BD96
realnum T0BD96
Definition: thermal.h:74
t_dense::nvals
long int nvals
Definition: dense.h:184
cdEXIT
#define cdEXIT(FAIL)
Definition: cddefines.h:434
Parser::lgEOL
bool lgEOL(void) const
Definition: parser.h:98
t_thermal::SigmaBD96
realnum SigmaBD96
Definition: thermal.h:76
parser.h
t_optimize::nvfpnt
long int nvfpnt[LIMPAR]
Definition: optimize.h:195
t_dense::lgDLWDepth
bool lgDLWDepth
Definition: dense.h:187
t_thermal::lgTemperatureConstantCommandParsed
bool lgTemperatureConstantCommandParsed
Definition: thermal.h:38
t_dense::DensityLaw
double DensityLaw[10]
Definition: dense.h:173
Parser::strcmp
int strcmp(const char *s2)
Definition: parser.h:177
LIMTABDLAW
const int LIMTABDLAW
Definition: dense.h:26
input.h
DEBUG_ENTRY
#define DEBUG_ENTRY(funcname)
Definition: cddefines.h:684
t_thermal::lgTeBD96
bool lgTeBD96
Definition: thermal.h:72