cloudy
trunk
|
00001 /* This file is part of Cloudy and is copyright (C)1978-2008 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 #include "cddefines.h" 00006 #include "thermal.h" 00007 #include "parse.h" 00008 00009 void ParseTLaw(char *chCard ) 00010 { 00011 00012 DEBUG_ENTRY( "ParseTLaw()" ); 00013 00014 /* this says that some type of temperature law has been specified */ 00015 thermal.lgTLaw = true; 00016 thermal.lgTemperatureConstant = true; 00017 thermal.lgTemperatureConstantCommandParsed = true; 00018 00019 if( nMatch("DB96",chCard) ) 00020 { 00021 /* this is to simulate the temperature law given by equation 41 in 00022 * >>refer H2 temperature law Draine, B.T., & Bertoldi, Frank, 1996, ApJ, 468, 269-289 */ 00023 thermal.lgTeBD96 = true; 00024 00025 /* this is the initial temperature for the BD96 temperature law */ 00026 thermal.T0BD96 = 500.f; 00027 TempChange(thermal.T0BD96 , false); 00028 00029 /* the coefficient on column density for temp dropoff */ 00030 thermal.SigmaBD96 = 6e-22f; 00031 } 00032 else if( nMatch("SN99",chCard) ) 00033 { 00034 /* this is to simulate the temperature law given by equation 16 in 00035 * >>refer H2 temperature law Sternberg, A., & Neufeld, D.A. 1999, ApJ, 516, 371-380 */ 00036 thermal.lgTeSN99 = true; 00037 00038 /* this is the inital temperature for the BD96 temperature law */ 00039 thermal.T0SN99 = 500.f; 00040 TempChange(thermal.T0SN99 , false); 00041 } 00042 else 00043 { 00044 fprintf(ioQQQ," There must be a keyword on this command. The one I know about is BD96\n"); 00045 cdEXIT(EXIT_FAILURE); 00046 } 00047 00048 #if 0 00049 #include "dense.h" 00050 #include "optimize.h" 00051 #include "input.h" 00052 bool lgEOL, 00053 lgEnd; 00054 long int i, 00055 j; 00056 char chCAP[5]; 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( nMatch("TABL",chCard) ) 00063 { 00064 /* when called, read in densities from input stream */ 00065 strcpy( dense.chDenseLaw, "DLW2" ); 00066 if( nMatch("DEPT",chCard) ) 00067 { 00068 dense.lgDLWDepth = true; 00069 } 00070 else 00071 { 00072 dense.lgDLWDepth = false; 00073 } 00074 00075 input_readarray(chCard,&lgEnd); 00076 i = 1; 00077 dense.frad[0] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00078 dense.fhden[0] = (realnum)FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00079 if( lgEOL ) 00080 { 00081 fprintf( ioQQQ, " No pairs entered - can\'t interpolate.\n Sorry.\n" ); 00082 cdEXIT(EXIT_FAILURE); 00083 } 00084 00085 dense.nvals = 2; 00086 lgEnd = false; 00087 00088 /* read pairs of numbers until we find line starting with END */ 00089 while( !lgEnd && dense.nvals < LIMTABDLAW ) 00090 { 00091 input_readarray(chCard,&lgEnd); 00092 if( !lgEnd ) 00093 { 00094 cap4(chCAP , chCard); 00095 if( strncmp(chCAP , "END" , 3 ) == 0 ) 00096 lgEnd = true; 00097 } 00098 00099 if( !lgEnd ) 00100 { 00101 i = 1; 00102 dense.frad[dense.nvals-1] = (realnum)FFmtRead(chCard 00103 ,&i,INPUT_LINE_LENGTH,&lgEOL); 00104 dense.fhden[dense.nvals-1] = (realnum)FFmtRead(chCard 00105 ,&i,INPUT_LINE_LENGTH,&lgEOL); 00106 dense.nvals += 1; 00107 } 00108 } 00109 --dense.nvals; 00110 00111 for( i=1; i < dense.nvals; i++ ) 00112 { 00113 /* the radius values are assumed to be strictly increasing */ 00114 if( dense.frad[i] <= dense.frad[i-1] ) 00115 { 00116 fprintf( ioQQQ, " density.in radii must be in increasing order\n" ); 00117 cdEXIT(EXIT_FAILURE); 00118 } 00119 } 00120 } 00121 else 00122 { 00123 /* this is usual case, call dense_fabden to get density */ 00124 i = 4; 00125 for( j=0; j < 10; j++ ) 00126 { 00127 dense.DensityLaw[j] = FFmtRead(chCard,&i,INPUT_LINE_LENGTH,&lgEOL); 00128 } 00129 00130 /* set flag so we know which law to use later */ 00131 strcpy( dense.chDenseLaw, "DLW1" ); 00132 00133 /* vary option */ 00134 if( optimize.lgVarOn ) 00135 { 00136 /* NB - there are 5 = LIMEXT numbers on this line - if LIMEXT ever changes, 00137 * chnage this too */ 00138 strcpy( optimize.chVarFmt[optimize.nparm], "DLAW %f %f %f %f %f " ); 00139 00140 /* index for where to write */ 00141 optimize.nvfpnt[optimize.nparm] = input.nRead; 00142 for( j=0; j<LIMEXT; ++j ) 00143 { 00144 optimize.vparm[j][optimize.nparm] = (realnum)dense.DensityLaw[j]; 00145 } 00146 optimize.vincr[optimize.nparm] = 0.5; 00147 optimize.nvarxt[optimize.nparm] = LIMEXT; 00148 ++optimize.nparm; 00149 } 00150 } 00151 # endif 00152 return; 00153 }