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 /*RT_line_one_tau_reset computes average of old and new optical depths for new scale at end of iter, 00004 * called by update, also FeIILevelPops */ 00005 #include "cddefines.h" 00006 #include "opacity.h" 00007 #include "geometry.h" 00008 #include "lines_service.h" 00009 #include "prt.h" 00010 #include "rt.h" 00011 00012 void RT_line_one_tau_reset(transition * t, 00013 double WeightNew) 00014 { 00015 char chSave[11]; 00016 00017 DEBUG_ENTRY( "RT_line_one_tau_reset()" ); 00018 00019 if( t->ipCont <= 0 ) 00020 { 00021 return; 00022 } 00023 00024 /* option to print masing lines, set with print maser */ 00025 if( prt.lgPrtMaser && 00026 ( t->Emis->TauTot < -0.01 || t->Emis->TauIn < -0.01) ) 00027 { 00028 strcpy( chSave, chLineLbl(t) ); 00029 fprintf( ioQQQ, " Masing line:%10.10s t(in, out)=%10.2e%10.2e\n", 00030 chSave, t->Emis->TauIn, t->Emis->TauTot ); 00031 } 00032 00033 /* iteration is 1 when this routine is called at end of first iteration 00034 * lgStatic is false by default, set true with command sphere SPHERE STATIC */ 00035 if( iteration == 1 && (!geometry.lgStatic) ) 00036 { 00037 /* end of first iteration, first estimate of total optical depth 00038 * is now the inward optical depth - set T(ipLnTauTot) to T(1) 00039 * DoubleTau normally 1, set to 2 by DoubleTau command in order 00040 * to simulate two-sided photoionization */ 00041 t->Emis->TauTot = t->Emis->TauIn*rt.DoubleTau; 00042 t->Emis->TauIn = MIN2(opac.taumin,t->Emis->TauTot/2.f); 00043 } 00044 else if( geometry.lgSphere && geometry.lgStatic ) 00045 { 00046 /* static sphere, both sides interact */ 00047 if( iteration == 1 ) 00048 { 00049 /* on first iteration TauIn was 0 for first zone */ 00050 t->Emis->TauTot = 2.f*t->Emis->TauIn; 00051 } 00052 else 00053 { 00054 t->Emis->TauTot = (realnum)(t->Emis->TauIn*WeightNew + t->Emis->TauTot* 00055 (1. - WeightNew)); 00056 } 00057 t->Emis->TauIn = t->Emis->TauTot/2.f; 00058 } 00059 else 00060 { 00061 /* take some sort of mean of old and new limiting optical depths */ 00062 if( t->Emis->TauIn > 0. && t->Emis->TauTot > 0. ) 00063 { 00064 /* this is case where no maser occurs */ 00065 /* >>chng 03 nov 06, try taking linear average */ 00066 t->Emis->TauTot = (realnum)(t->Emis->TauTot*(1. - WeightNew) + 00067 t->Emis->TauIn*rt.DoubleTau*WeightNew); 00068 t->Emis->TauIn = MIN2(opac.taumin,t->Emis->TauTot/ 2.f); 00069 } 00070 else 00071 { 00072 /* case where maser did occr */ 00073 t->Emis->TauTot = (t->Emis->TauIn*rt.DoubleTau + t->Emis->TauTot)/2.f; 00074 t->Emis->TauIn = MIN2(opac.taumin,t->Emis->TauTot/2.f); 00075 } 00076 } 00077 00078 /* this is escape prob */ 00079 t->Emis->Pesc = 0.5f*(1.f + 1.f/MAX2(1.f,t->Emis->TauTot)); 00080 00081 /* this is fraction inward */ 00082 t->Emis->FracInwd = MIN2(1.f,1.5f-t->Emis->Pesc); 00083 00084 /* this is destruction probability 00085 * >>chng 96 sep 4, was not here, needed to add since now taking 00086 * mean of old and new dest prob */ 00087 t->Emis->Pdest = 0.; 00088 t->Emis->Pelec_esc = 0.; 00089 00090 /* optical depth to the continuum source */ 00091 t->Emis->TauCon = opac.taumin; 00092 00093 /* >>chng 01 sep 01, zero out some pops and energies */ 00094 t->Lo->Pop = 0.; 00095 /* >>chng 97 jul 21, added following zero 00096 * population of upper level */ 00097 t->Hi->Pop = 0.; 00098 /* population of lower level with correction for stim emission */ 00099 t->Emis->PopOpc = 0.; 00100 /* following two heat exchange excitation, deexcitation */ 00101 t->Coll.cool = 0.; 00102 t->Coll.heat = 0.; 00103 /* intensity of line */ 00104 t->Emis->xIntensity = 0.; 00105 /* number of photons emitted in line */ 00106 t->Emis->phots = 0.; 00107 return; 00108 }