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 /*EdenChange - update electron density and its dependent quantities */ 00004 #include "cddefines.h" 00005 #include "dense.h" 00006 #include "rfield.h" 00007 #include "thermal.h" 00008 #include "phycon.h" 00009 #include "conv.h" 00010 #include "rt.h" 00011 00012 void EdenChange( double EdenNew ) 00013 { 00014 static double EdenOld=-1; 00015 00016 DEBUG_ENTRY( "EdenChange()" ); 00017 00018 // init EdenOld on first sweep through this sim 00019 if( conv.nTotalIoniz==0 ) 00020 EdenOld = dense.eden; 00021 00022 // this confirms that eden is only changed in this routine 00023 ASSERT( fp_equal(dense.eden , EdenOld ) ); 00024 00025 dense.eden = EdenNew; 00026 EdenOld = EdenNew; 00027 00028 dense.EdenHCorr = dense.eden + 00029 /* dense.HCorrFac is unity by default and changed with the set HCOR command */ 00030 dense.xIonDense[ipHYDROGEN][0]*1.7e-4 * dense.HCorrFac; 00031 dense.EdenHCorr_f = (realnum)dense.EdenHCorr; 00032 dense.edensqte = dense.EdenHCorr/phycon.sqrte; 00033 dense.cdsqte = dense.edensqte*COLL_CONST; 00034 dense.SqrtEden = sqrt(dense.eden); 00035 00036 /* evaluate the plasma frequency one time per zone to avoid PF moving across 00037 * a line during convergence loops */ 00038 if( nzone != rfield.nZonePlsFrqEval || conv.lgSearch ) 00039 { 00040 rfield.nZonePlsFrqEval = nzone; 00041 rfield.plsfrq = (realnum)((ELEM_CHARGE_ESU/sqrt(PI*ELECTRON_MASS)/FR1RYD)*sqrt(dense.eden)); 00042 00043 if( rfield.ipPlasma > 0 ) 00044 { 00045 /* increase index for plasma frequency until within proper cell */ 00046 while( rfield.plsfrq > rfield.anu[rfield.ipPlasma]+rfield.widflx[rfield.ipPlasma]/2. ) 00047 ++rfield.ipPlasma; 00048 00049 /* decrease index for plasma frequency until within proper cell */ 00050 while( rfield.ipPlasma>2 && rfield.plsfrq < rfield.anu[rfield.ipPlasma]-rfield.widflx[rfield.ipPlasma]/2. ) 00051 --rfield.ipPlasma; 00052 } 00053 00054 /* also remember the largest plasma frequency we encounter */ 00055 rfield.plsfrqmax = MAX2(rfield.plsfrqmax, rfield.plsfrq); 00056 00057 /* is plasma frequency within energy grid? */ 00058 if( rfield.plsfrq > rfield.anu[0] ) 00059 { 00060 rfield.lgPlasNu = true; 00061 } 00062 } 00063 00064 // if plasma frequency has changed we need to update transitions - those 00065 // below plasma frequency do not exist - emission rate set to smallfloat 00066 // only do this in search phase since plasma frequency moving across transition 00067 // would create discontinuous changes in cooling that would present noise 00068 // to the solver. The electron density should not change by much during the 00069 // solution for a zone 00070 static double EdenEval=-1; 00071 if( conv.lgSearch && !fp_equal(EdenEval,dense.eden) ) 00072 { 00073 EdenEval = dense.eden; 00074 RT_line_all(); 00075 } 00076 00077 return; 00078 }