cloudy trunk
Loading...
Searching...
No Matches
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
13void 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;
19 thermal.lgTemperatureConstant = true;
20 thermal.lgTemperatureConstantCommandParsed = 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();
101 dense.fhden[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 */
136 optimize.nvfpnt[optimize.nparm] = input.nRead;
137 for( j=0; j<LIMEXT; ++j )
138 {
139 optimize.vparm[j][optimize.nparm] = (realnum)dense.DensityLaw[j];
140 }
141 optimize.vincr[optimize.nparm] = 0.5;
142 optimize.nvarxt[optimize.nparm] = LIMEXT;
143 ++optimize.nparm;
144 }
145 }
146# endif
147 return;
148}
FILE * ioQQQ
Definition cddefines.cpp:7
#define EXIT_FAILURE
Definition cddefines.h:140
#define cdEXIT(FAIL)
Definition cddefines.h:434
float realnum
Definition cddefines.h:103
#define DEBUG_ENTRY(funcname)
Definition cddefines.h:684
bool getline(void)
Definition parser.cpp:164
double FFmtRead(void)
Definition parser.cpp:353
bool nMatch(const char *chKey) const
Definition parser.h:135
int strcmp(const char *s2)
Definition parser.h:177
bool lgEOL(void) const
Definition parser.h:98
bool m_lgEOF
Definition parser.h:42
t_dense dense
Definition dense.cpp:24
const int LIMTABDLAW
Definition dense.h:26
t_input input
Definition input.cpp:12
t_optimize optimize
Definition optimize.cpp:5
const long LIMEXT
Definition optimize.h:60
void ParseTLaw(Parser &p)
void TempChange(double TempNew, bool lgForceUpdate)
t_thermal thermal
Definition thermal.cpp:5