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 /*PrtMeanIon print mean ionization fractions or temperatures for all elements */ 00004 #include "cddefines.h" 00005 #include "geometry.h" 00006 #include "dense.h" 00007 #include "mean.h" 00008 #include "elementnames.h" 00009 #include "prt.h" 00010 00011 void PrtMeanIon( 00012 /* this is either 't' or 'i', for mean ionization or temperature */ 00013 char chType , 00014 /* true include density, false do not */ 00015 bool lgDensity , 00016 /* this is stream used for io, is stdout when called by final, 00017 * is punch unit when punch output generated */ 00018 FILE *ioMEAN ) 00019 { 00020 long int i, 00021 limit, 00022 n, 00023 nelem; 00024 /* >>chng 04 dec 31, had been static, not possible to ever set false if 00025 * ever true, rm static */ 00026 bool lgPrtLots=false; 00027 00028 realnum aa[64]; 00029 00030 DEBUG_ENTRY( "PrtMeanIon()" ); 00031 00032 /* print mean ionization or temperature?? */ 00033 /* chType must be i for ionization, or t for temperature */ 00034 ASSERT( chType == 'i' || chType == 't' ); 00035 00036 /* print mean ionization or temperature for the computed model 00037 * the means are relative to the total atoms and ions and does not include molecules or grains */ 00038 00039 /* only print sphereical if not plane parallel */ 00040 /* >>>chng 99 may 01, test included one for sphere being set, 00041 * so no printout when not set. now print even when sphere not 00042 * set but geo is not plane parallel */ 00043 if( /*sphere.lgSphere &&*/ (!geometry.lgGeoPP) ) 00044 { 00045 00046 /* get means for hydrogen and helium, MeanIonVolume is in mean.c */ 00047 MeanIonVolume(chType,ipHYDROGEN,&n,aa,lgDensity); 00048 /*MeanIonVolume(chType,2,&n,c ,lgDensity);*/ 00049 00050 /* now print hydrogen, special since part of title goes here */ 00051 fprintf( ioMEAN, "\n Hydrogen " ); 00052 for( i=0; i < 3; i++ ) 00053 { 00054 fprintf( ioMEAN, "%7.3f", aa[i] ); 00055 } 00056 fprintf(ioMEAN," (H2)"); 00057 if( chType=='i' && lgDensity ) 00058 { 00059 fprintf( ioMEAN, 00060 " Log10 Mean Ionisation (over volume*electron density)\n" ); 00061 } 00062 else if( chType=='i' ) 00063 { 00064 fprintf( ioMEAN, 00065 " Log10 Mean Ionisation (over volume)\n" ); 00066 } 00067 else if( chType=='t' && lgDensity ) 00068 { 00069 fprintf( ioMEAN, 00070 " Log10 Mean Temperature (over volume*electron density)\n" ); 00071 } 00072 else if( chType=='t' ) 00073 { 00074 fprintf( ioMEAN, 00075 " Log10 Mean Temperature (over volume)\n" ); 00076 } 00077 else 00078 { 00079 fprintf(ioQQQ,"PrtMeanIon called with insane job\n"); 00080 } 00081 00082 /* ionization fractions for remaining elements */ 00083 for( nelem=ipHELIUM; nelem < LIMELM; nelem++ ) 00084 { 00085 if( dense.lgElmtOn[nelem] ) 00086 { 00087 MeanIonVolume(chType,nelem,&n,aa,lgDensity); 00088 limit = MIN2(17,n); 00089 fprintf( ioMEAN, " %10.10s", elementnames.chElementName[nelem] ); 00090 00091 for( i=0; i < limit; i++ ) 00092 { 00093 fprintf( ioMEAN, "%7.3f", aa[i] ); 00094 } 00095 fprintf( ioMEAN, "\n" ); 00096 00097 if( n > 17 ) 00098 { 00099 lgPrtLots = true; 00100 fprintf( ioMEAN, " " ); 00101 for( i=17; i < n; i++ ) 00102 { 00103 fprintf( ioMEAN, "%7.3f", aa[i] ); 00104 } 00105 fprintf( ioMEAN, "\n" ); 00106 } 00107 } 00108 } 00109 } 00110 00111 fprintf( ioMEAN, "\n " ); 00112 for( i=1; i <= 17; i++ ) 00113 { 00114 fprintf( ioMEAN, "%7ld", i ); 00115 } 00116 fprintf( ioMEAN, "\n" ); 00117 if( lgPrtLots ) 00118 { 00119 fprintf( ioMEAN, " " ); 00120 for( i=18; i <= LIMELM; i++ ) 00121 { 00122 fprintf( ioMEAN, "%7ld", i ); 00123 } 00124 fprintf( ioMEAN, "\n" ); 00125 } 00126 00127 /* get hydrogen ionization fractions */ 00128 MeanIonRadius(chType,ipHYDROGEN,&n,aa,lgDensity); 00129 00130 /* get helium ionization fractions 00131 MeanIonRadius(chType,ipHELIUM,&n,c,lgDensity);*/ 00132 00133 fprintf( ioMEAN, "\n Hydrogen " ); 00134 00135 for( i=0; i < 3; i++ ) 00136 { 00137 /* print hydrogen fractions */ 00138 fprintf( ioMEAN, "%7.3f", aa[i] ); 00139 } 00140 fprintf(ioMEAN," (H2)"); 00141 if( chType=='i' && lgDensity ) 00142 { 00143 fprintf( ioMEAN, 00144 " Log10 Mean Ionisation (over radius*electron density)\n" ); 00145 } 00146 else if( chType=='i' ) 00147 { 00148 fprintf( ioMEAN, 00149 " Log10 Mean Ionisation (over radius)\n" ); 00150 } 00151 else if( chType=='t' && lgDensity ) 00152 { 00153 fprintf( ioMEAN, 00154 " Log10 Mean Temperature (over radius*electron density)\n" ); 00155 } 00156 else if( chType=='t' ) 00157 { 00158 fprintf( ioMEAN, 00159 " Log10 Mean Temperature (over radius)\n" ); 00160 } 00161 else 00162 { 00163 fprintf(ioQQQ,"PrtMeanIon called with insane job\n"); 00164 } 00165 00166 /* now the remaining elements, he on up */ 00167 for( nelem=ipHELIUM; nelem < LIMELM; nelem++ ) 00168 { 00169 if( dense.lgElmtOn[nelem] ) 00170 { 00171 MeanIonRadius(chType,nelem,&n,aa,lgDensity); 00172 limit = MIN2(17,n); 00173 fprintf( ioMEAN, " %10.10s", 00174 elementnames.chElementName[nelem] ); 00175 for( i=0; i < limit; i++ ) 00176 { 00177 fprintf( ioMEAN, "%7.3f", aa[i] ); 00178 } 00179 fprintf( ioMEAN, "\n" ); 00180 00181 if( n > 17 ) 00182 { 00183 lgPrtLots = true; 00184 fprintf( ioMEAN, " " ); 00185 00186 for( i=17; i < n; i++ ) 00187 { 00188 fprintf( ioMEAN, "%7.3f", aa[i] ); 00189 } 00190 fprintf( ioMEAN, "\n" ); 00191 } 00192 } 00193 } 00194 return; 00195 }