00001 /* This file is part of Cloudy and is copyright (C)1978-2013 by Gary J. Ferland and 00002 * others. For conditions of distribution and use see copyright notice in license.txt */ 00003 /*ParseTLaw parse parameters on the tlaw command to set temperature as function of depth, 00004 * currently only does Bertoldi & Draine simple T law */ 00005 00006 /* Despite outward appearances, this routine has no connection whatsoever with 00007 Bassetlaw (http://www.bassetlawmuseum.org.uk/) */ 00008 00009 #include "cddefines.h" 00010 #include "thermal.h" 00011 #include "parser.h" 00012 00013 void ParseTLaw( Parser &p ) 00014 { 00015 DEBUG_ENTRY( "ParseTLaw()" ); 00016 00017 /* this says that some type of temperature law has been specified */ 00018 thermal.lgTLaw = true; 00019 thermal.lgTemperatureConstant = true; 00020 thermal.lgTemperatureConstantCommandParsed = true; 00021 00022 if( p.nMatch("DB96") ) 00023 { 00024 /* this is to simulate the temperature law given by equation 41 in 00025 * >>refer H2 temperature law Draine, B.T., & Bertoldi, Frank, 1996, ApJ, 468, 269-289 */ 00026 thermal.lgTeBD96 = true; 00027 00028 /* this is the initial temperature for the BD96 temperature law */ 00029 thermal.T0BD96 = 500.f; 00030 TempChange(thermal.T0BD96 , false); 00031 00032 /* the coefficient on column density for temp dropoff */ 00033 thermal.SigmaBD96 = 6e-22f; 00034 } 00035 else if( p.nMatch("SN99") ) 00036 { 00037 /* this is to simulate the temperature law given by equation 16 in 00038 * >>refer H2 temperature law Sternberg, A., & Neufeld, D.A. 1999, ApJ, 516, 371-380 */ 00039 thermal.lgTeSN99 = true; 00040 00041 /* this is the inital temperature for the BD96 temperature law */ 00042 thermal.T0SN99 = 500.f; 00043 TempChange(thermal.T0SN99 , false); 00044 } 00045 else 00046 { 00047 fprintf(ioQQQ," There must be a keyword on this command. The one I know about is BD96\n"); 00048 cdEXIT(EXIT_FAILURE); 00049 } 00050 00051 #if 0 00052 #include "dense.h" 00053 #include "optimize.h" 00054 #include "input.h" 00055 bool lgEnd; 00056 long int j; 00057 /* all remainder is currently dead code, a copy of DLAW command, 00058 * which could be activated if needs arose */ 00059 /* call fcn dense_fabden(RADIUS) which uses the ten parameters 00060 * N.B.; existing version of dense_fabden must be deleted 00061 * >>chng 96 nov 29, added table option */ 00062 if( p.nMatch("TABL") ) 00063 { 00064 /* when called, read in densities from input stream */ 00065 strcpy( dense.chDenseLaw, "DLW2" ); 00066 if( p.nMatch("DEPT") ) 00067 { 00068 dense.lgDLWDepth = true; 00069 } 00070 else 00071 { 00072 dense.lgDLWDepth = false; 00073 } 00074 00075 p.getline(); 00076 dense.frad[0] = (realnum)p.FFmtRead(); 00077 dense.fhden[0] = (realnum)p.FFmtRead(); 00078 if( p.lgEOL() ) 00079 { 00080 fprintf( ioQQQ, " No pairs entered - can\'t interpolate.\n Sorry.\n" ); 00081 cdEXIT(EXIT_FAILURE); 00082 } 00083 00084 dense.nvals = 2; 00085 lgEnd = false; 00086 00087 /* read pairs of numbers until we find line starting with END */ 00088 while( !lgEnd && dense.nvals < LIMTABDLAW ) 00089 { 00090 p.getline(); 00091 lgEnd = p.m_lgEOF; 00092 if( !lgEnd ) 00093 { 00094 if( p.strcmp("END") == 0 ) 00095 lgEnd = true; 00096 } 00097 00098 if( !lgEnd ) 00099 { 00100 dense.frad[dense.nvals-1] = (realnum)p.FFmtRead(); 00101 dense.fhden[dense.nvals-1] = (realnum)p.FFmtRead(); 00102 dense.nvals += 1; 00103 } 00104 } 00105 --dense.nvals; 00106 00107 for( i=1; i < dense.nvals; i++ ) 00108 { 00109 /* the radius values are assumed to be strictly increasing */ 00110 if( dense.frad[i] <= dense.frad[i-1] ) 00111 { 00112 fprintf( ioQQQ, " density.in radii must be in increasing order\n" ); 00113 cdEXIT(EXIT_FAILURE); 00114 } 00115 } 00116 } 00117 else 00118 { 00119 /* this is usual case, call dense_fabden to get density */ 00120 for( j=0; j < 10; j++ ) 00121 { 00122 dense.DensityLaw[j] = p.FFmtRead(); 00123 } 00124 00125 /* set flag so we know which law to use later */ 00126 strcpy( dense.chDenseLaw, "DLW1" ); 00127 00128 /* vary option */ 00129 if( optimize.lgVarOn ) 00130 { 00131 /* NB - there are 5 = LIMEXT numbers on this line - if LIMEXT ever changes, 00132 * chnage this too */ 00133 strcpy( optimize.chVarFmt[optimize.nparm], "DLAW %f %f %f %f %f " ); 00134 00135 /* index for where to write */ 00136 optimize.nvfpnt[optimize.nparm] = input.nRead; 00137 for( j=0; j<LIMEXT; ++j ) 00138 { 00139 optimize.vparm[j][optimize.nparm] = (realnum)dense.DensityLaw[j]; 00140 } 00141 optimize.vincr[optimize.nparm] = 0.5; 00142 optimize.nvarxt[optimize.nparm] = LIMEXT; 00143 ++optimize.nparm; 00144 } 00145 } 00146 # endif 00147 return; 00148 }