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