Changeset 2112 for branches/newmole
- Timestamp:
- 06/17/08 17:10:09 (7 months ago)
- Location:
- branches/newmole/source
- Files:
-
- 16 modified
-
atmdat_adfa.cpp (modified) (1 diff)
-
cddefines.h (modified) (2 diffs)
-
container_classes.h (modified) (16 diffs)
-
grains.cpp (modified) (14 diffs)
-
grains_mie.cpp (modified) (3 diffs)
-
grains_qheat.cpp (modified) (10 diffs)
-
grainvar.h (modified) (1 diff)
-
ion_solver.cpp (modified) (2 diffs)
-
iso.h (modified) (1 diff)
-
iso_ionize_recombine.cpp (modified) (1 diff)
-
iso_level.cpp (modified) (3 diffs)
-
Makefile (modified) (6 diffs)
-
mole_species.cpp (modified) (1 diff)
-
parse_grid.cpp (modified) (1 diff)
-
parse_punch.cpp (modified) (1 diff)
-
punch_do.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/newmole/source/atmdat_adfa.cpp
r1830 r2112 236 236 ASSERT( !lgErr ); 237 237 238 /*refer HI cs Anderson, H., Ballance, C.P., Badnell, N.R., 239 *refercon & Summers, H.P 2000, J Phys B, 33, 1255 */ 238 240 const static char chFile8[] = "h_coll_str.dat"; 239 241 -
branches/newmole/source/cddefines.h
r1942 r2112 69 69 typedef float realnum; 70 70 #endif 71 72 //Compile-time assertion after Alexandrescu 73 template<bool> struct StaticAssertFailed; 74 template<> struct StaticAssertFailed<true> {}; 75 #define STATIC_ASSERT(x) (StaticAssertFailed< (x) == true >()) 71 76 72 77 typedef float sys_float; … … 1338 1343 1339 1344 /* Explicit instantiations for debugging purposes */ 1340 INSTANTIATE_MULTI_ARR( quantumState, MEM_LAYOUT_VAL,lgBOUNDSCHECKVAL );1341 INSTANTIATE_MULTI_ARR( transition, MEM_LAYOUT_VAL,lgBOUNDSCHECKVAL );1345 INSTANTIATE_MULTI_ARR( quantumState, lgBOUNDSCHECKVAL ); 1346 INSTANTIATE_MULTI_ARR( transition, lgBOUNDSCHECKVAL ); 1342 1347 1343 1348 -
branches/newmole/source/container_classes.h
r2023 r2112 32 32 //! basic_pntr - base class for generalization of normal pointers that enables bounds checking 33 33 //! it comes with the full set of operators that you would expect for a random access pointer 34 template<class T, int d, mem_layout ALLOC,bool lgBC>34 template<class T, bool lgBC> 35 35 class basic_pntr 36 36 { … … 126 126 127 127 //! pntr - interface class to replace normal pointers 128 template<class T, int d, mem_layout ALLOC,bool lgBC>129 class pntr : public basic_pntr<T, d,ALLOC,lgBC>128 template<class T, bool lgBC> 129 class pntr : public basic_pntr<T,lgBC> 130 130 { 131 131 public: 132 132 // constructors are not inherited, so define them again 133 pntr( T* p0 ) : basic_pntr<T, d,ALLOC,lgBC>( p0 ) {}134 pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T, d,ALLOC,lgBC>( p0, p1, p2 ) {}133 pntr( T* p0 ) : basic_pntr<T,lgBC>( p0 ) {} 134 pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,lgBC>( p0, p1, p2 ) {} 135 135 pntr() {} 136 136 // the increment / decrement operators need to be recast... 137 137 // otherwise expressions like p = ++q would be illegal for iterators... 138 pntr& operator++ () { return static_cast<pntr&>(basic_pntr<T, d,ALLOC,lgBC>::operator++()); }138 pntr& operator++ () { return static_cast<pntr&>(basic_pntr<T,lgBC>::operator++()); } 139 139 const pntr operator++ (int) { pntr t = *this; ++(*this); return t; } 140 pntr& operator-- () { return static_cast<pntr&>(basic_pntr<T, d,ALLOC,lgBC>::operator--()); }140 pntr& operator-- () { return static_cast<pntr&>(basic_pntr<T,lgBC>::operator--()); } 141 141 const pntr operator-- (int) { pntr t = *this; --(*this); return t; } 142 142 // define p+n, p-n, p-q … … 147 147 148 148 // this defines n+p 149 template<class T, int d, mem_layout ALLOC,bool lgBC>150 inline const pntr<T, d,ALLOC,lgBC> operator+ ( const ptrdiff_t n, const pntr<T,d,ALLOC,lgBC>& t )151 { 152 pntr<T, d,ALLOC,lgBC> s = t;149 template<class T, bool lgBC> 150 inline const pntr<T,lgBC> operator+ ( const ptrdiff_t n, const pntr<T,lgBC>& t ) 151 { 152 pntr<T,lgBC> s = t; 153 153 s += n; 154 154 return s; … … 156 156 157 157 //! const_pntr - same as pntr, except that it replaces const pointers rather than normal pointers 158 template<class T, int d, mem_layout ALLOC,bool lgBC>159 class const_pntr : public basic_pntr<T, d,ALLOC,lgBC>158 template<class T, bool lgBC> 159 class const_pntr : public basic_pntr<T,lgBC> 160 160 { 161 161 public: 162 162 // constructors are not inherited, so define them again 163 const_pntr( T* p0 ) : basic_pntr<T, d,ALLOC,lgBC>( p0 ) {}164 const_pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T, d,ALLOC,lgBC>( p0, p1, p2 ) {}163 const_pntr( T* p0 ) : basic_pntr<T,lgBC>( p0 ) {} 164 const_pntr( T* p0, T* p1, T* p2 ) : basic_pntr<T,lgBC>( p0, p1, p2 ) {} 165 165 const_pntr() {} 166 166 // make sure we can assign a pntr to a const_pntr by creating an implicit conversion to const_pntr 167 const_pntr( const pntr<T, d,ALLOC,lgBC>& t ) : basic_pntr<T,d,ALLOC,lgBC>( t ) {}167 const_pntr( const pntr<T,lgBC>& t ) : basic_pntr<T,lgBC>( t ) {} 168 168 // the increment / decrement operators need to be recast... 169 169 // otherwise expressions like *p++ = 1. would be legal for const_iterators... 170 const_pntr& operator++ () { return static_cast<const_pntr&>(basic_pntr<T, d,ALLOC,lgBC>::operator++()); }170 const_pntr& operator++ () { return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator++()); } 171 171 const const_pntr operator++ (int) { const_pntr t = *this; ++(*this); return t; } 172 const_pntr& operator-- () { return static_cast<const_pntr&>(basic_pntr<T, d,ALLOC,lgBC>::operator--()); }172 const_pntr& operator-- () { return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator--()); } 173 173 const const_pntr operator-- (int) { const_pntr t = *this; --(*this); return t; } 174 174 const_pntr& operator+= ( const ptrdiff_t n ) 175 175 { 176 return static_cast<const_pntr&>(basic_pntr<T, d,ALLOC,lgBC>::operator+=(n));176 return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator+=(n)); 177 177 } 178 178 const_pntr& operator-= ( const ptrdiff_t n ) 179 179 { 180 return static_cast<const_pntr&>(basic_pntr<T, d,ALLOC,lgBC>::operator-=(n));180 return static_cast<const_pntr&>(basic_pntr<T,lgBC>::operator-=(n)); 181 181 } 182 182 // the dereference operators need to be recast... 183 const T& operator* () const { return static_cast<const T&>(basic_pntr<T, d,ALLOC,lgBC>::operator*()); }184 const T* operator-> () const { return static_cast<const T*>(basic_pntr<T, d,ALLOC,lgBC>::operator->()); }183 const T& operator* () const { return static_cast<const T&>(basic_pntr<T,lgBC>::operator*()); } 184 const T* operator-> () const { return static_cast<const T*>(basic_pntr<T,lgBC>::operator->()); } 185 185 const T& operator[] ( const ptrdiff_t n ) const 186 186 { 187 return static_cast<const T&>(basic_pntr<T, d,ALLOC,lgBC>::operator[](n));187 return static_cast<const T&>(basic_pntr<T,lgBC>::operator[](n)); 188 188 } 189 189 // define p+n, p-n, p-q … … 194 194 195 195 // this defines n+p 196 template<class T, int d, mem_layout ALLOC,bool lgBC>197 inline const const_pntr<T, d,ALLOC,lgBC> operator+ ( const ptrdiff_t n, const const_pntr<T,d,ALLOC,lgBC>& t )198 { 199 const_pntr<T, d,ALLOC,lgBC> s = t;196 template<class T, bool lgBC> 197 inline const const_pntr<T,lgBC> operator+ ( const ptrdiff_t n, const const_pntr<T,lgBC>& t ) 198 { 199 const_pntr<T,lgBC> s = t; 200 200 s += n; 201 201 return s; … … 275 275 //! multi_geom - this class maintains all the geometry information for multi_arr 276 276 //! keeping it separate makes it easy to clone the information from one multi_arr to another 277 template<int d,mem_layout ALLOC=MEM_LAYOUT_VAL ,bool lgBC=lgBOUNDSCHECKVAL>277 template<int d,mem_layout ALLOC=MEM_LAYOUT_VAL> 278 278 class multi_geom 279 279 { … … 382 382 # pragma warning( disable : 4127 ) 383 383 #endif 384 385 STATIC_ASSERT ( ALLOC == C_TYPE || ALLOC == ARPA_TYPE ); 386 384 387 if( ALLOC == ARPA_TYPE ) 385 388 { … … 403 406 { 404 407 TotalInsanity(); 405 } 408 } 406 409 } 407 410 … … 902 905 { 903 906 // ancillary data describing the memory layout of the multi_arr 904 multi_geom<d,ALLOC ,lgBC> p_g;907 multi_geom<d,ALLOC> p_g; 905 908 T** p_psl[d-1]; // pointer arrays for ARPA structure 906 909 valarray<T> p_dsl; // this contains the actual data … … 921 924 typedef size_t size_type; 922 925 typedef ptrdiff_t difference_type; 923 typedef pntr<T, d,ALLOC,lgBC> iterator;924 typedef const_pntr<T, d,ALLOC,lgBC> const_iterator;926 typedef pntr<T,lgBC> iterator; 927 typedef const_pntr<T,lgBC> const_iterator; 925 928 926 929 private: … … 951 954 p_clear1(); 952 955 } 953 multi_arr(const multi_geom<d,ALLOC ,lgBC>& g)956 multi_arr(const multi_geom<d,ALLOC>& g) 954 957 { 955 958 p_clear1(); … … 1026 1029 # pragma warning( disable : 4127 ) 1027 1030 #endif 1031 STATIC_ASSERT ( ALLOC == C_TYPE || ALLOC == ARPA_TYPE ); 1032 1028 1033 if( ALLOC == ARPA_TYPE ) 1029 1034 { … … 1064 1069 } 1065 1070 // clone the geometry from another multi_arr 1066 void alloc(const multi_geom<d,ALLOC ,lgBC>& g)1071 void alloc(const multi_geom<d,ALLOC>& g) 1067 1072 { 1068 1073 if( &g != &p_g ) … … 1647 1652 } 1648 1653 1649 const multi_geom<d,ALLOC ,lgBC>& clone() const1654 const multi_geom<d,ALLOC>& clone() const 1650 1655 { 1651 1656 return p_g; … … 1719 1724 1720 1725 // on Mac systems these instantiations need to be extern in order to avoid duplicate symbols 1721 #define INSTANTIATE_MULTI_ARR( TYPE, LAYOUT, BC ) \ 1722 INST_EXTERN template class pntr<TYPE,2,LAYOUT,BC>; \ 1723 INST_EXTERN template class pntr<TYPE,3,LAYOUT,BC>; \ 1724 INST_EXTERN template class pntr<TYPE,4,LAYOUT,BC>; \ 1725 INST_EXTERN template class pntr<TYPE,5,LAYOUT,BC>; \ 1726 INST_EXTERN template class pntr<TYPE,6,LAYOUT,BC>; \ 1727 INST_EXTERN template class const_pntr<TYPE,2,LAYOUT,BC>; \ 1728 INST_EXTERN template class const_pntr<TYPE,3,LAYOUT,BC>; \ 1729 INST_EXTERN template class const_pntr<TYPE,4,LAYOUT,BC>; \ 1730 INST_EXTERN template class const_pntr<TYPE,5,LAYOUT,BC>; \ 1731 INST_EXTERN template class const_pntr<TYPE,6,LAYOUT,BC> 1732 1733 INSTANTIATE_MULTI_ARR( bool, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 1734 INSTANTIATE_MULTI_ARR( long, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 1735 INSTANTIATE_MULTI_ARR( realnum, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 1736 INSTANTIATE_MULTI_ARR( double, MEM_LAYOUT_VAL, lgBOUNDSCHECKVAL ); 1737 INSTANTIATE_MULTI_ARR( double, C_TYPE, lgBOUNDSCHECKVAL ); 1726 #define INSTANTIATE_MULTI_ARR( TYPE, BC ) \ 1727 INST_EXTERN template class pntr<TYPE,BC>; \ 1728 INST_EXTERN template class const_pntr<TYPE,BC>; 1729 1730 INSTANTIATE_MULTI_ARR( bool, lgBOUNDSCHECKVAL ); 1731 INSTANTIATE_MULTI_ARR( long, lgBOUNDSCHECKVAL ); 1732 INSTANTIATE_MULTI_ARR( realnum,lgBOUNDSCHECKVAL ); 1733 INSTANTIATE_MULTI_ARR( double, lgBOUNDSCHECKVAL ); 1738 1734 1739 1735 … … 1758 1754 typedef long size_type; 1759 1755 typedef ptrdiff_t difference_type; 1760 typedef pntr<T, 1,FLX_TYPE,lgBC> iterator;1761 typedef const_pntr<T, 1,FLX_TYPE,lgBC> const_iterator;1756 typedef pntr<T,lgBC> iterator; 1757 typedef const_pntr<T,lgBC> const_iterator; 1762 1758 1763 1759 private: -
branches/newmole/source/grains.cpp
r2079 r2112 33 33 inline double ASINH(double x) 34 34 { 35 if( abs(x) <= 2.3e-4 ) 36 return x - pow3(x)/6.; 37 else if( abs(x) <= 8.e-3 ) 35 if( abs(x) <= 8.e-3 ) 38 36 return ((0.075*pow2(x) - 1./6.)*pow2(x) + 1.)*x; 39 37 else if( abs(x) <= 1./sqrt(DBL_EPSILON) ) … … 47 45 { 48 46 if( x < 0. ) 49 return - log(-2.*x);47 return -(log(-x)+LN_TWO); 50 48 else 51 return log( 2.*x);49 return log(x)+LN_TWO; 52 50 } 53 51 } … … 145 143 return 1.e-7; 146 144 else 147 return 3.e-6* pow((double)gv.bin[nd]->dustp[0],-0.85)*pow(e*EVRYD*1.e-3,1.5);145 return 3.e-6*gv.bin[nd]->eec*sqrt(pow3(e*EVRYD*1.e-3)); 148 146 } 149 147 … … 192 190 STATIC void UpdatePot2(long,long); 193 191 /* Helper function to calculate primary and secondary yields and the average electron energy at infinity */ 194 STATICvoid Yfunc(long,long,double,double,double,double,double,/*@out@*/double*,/*@out@*/double*,192 inline void Yfunc(long,long,double,double,double,double,double,/*@out@*/double*,/*@out@*/double*, 195 193 /*@out@*/double*,/*@out@*/double*); 196 194 /* This calculates the y0 function for band electrons (Sect. 4.1.3/4.1.4 of WDB06) */ … … 203 201 STATIC double y1psa(long,long,double); 204 202 /* This calculates the y2 function for primary and Auger electrons (Eq. 8 of WDB06) */ 205 STATICdouble y2pa(double,double,long,double*);203 inline double y2pa(double,double,long,double*); 206 204 /* This calculates the y2 function for secondary electrons (Eq. 20-21 of WDB06) */ 207 STATICdouble y2s(double,double,long,double*);205 inline double y2s(double,double,long,double*); 208 206 /* find highest ionization stage with non-zero population */ 209 207 STATIC long HighestIonStage(void); … … 3216 3214 } 3217 3215 3216 double GrainPot = chrg2pot(Zg,nd); 3217 3218 3218 if( nfill > ipLo ) 3219 3219 { … … 3241 3241 /* calculate yield for band structure */ 3242 3242 Ehi = Ehi_band = anu[i] - ThresInfVal - Emin; 3243 Wcorr = ThresInfVal + Emin - chrg2pot(Zg,nd);3243 Wcorr = ThresInfVal + Emin - GrainPot; 3244 3244 Eel = anu[i] - DustWorkFcn; 3245 3245 yzero = y0b( nd, nz, i ); … … 3252 3252 3253 3253 /* add in yields for inner shell ionization */ 3254 for( ns=1; ns < gv.bin[nd]->nShells; ns++ ) 3254 unsigned long nsmax = gv.bin[nd]->nShells; 3255 for( ns=1; ns < nsmax; ns++ ) 3255 3256 { 3256 3257 sptr = gv.bin[nd]->sd[ns]; … … 3268 3269 3269 3270 /* add in Auger yields */ 3270 for( n=0; n < sptr->nData; n++ ) 3271 long nmax = sptr->nData; 3272 for( n=0; n < nmax; n++ ) 3271 3273 { 3272 3274 double max = sptr->AvNr[n]*sptr->p[i]; 3273 Ehi = sptr->Ener[n] - chrg2pot(Zg,nd);3275 Ehi = sptr->Ener[n] - GrainPot; 3274 3276 Eel = sptr->Ener[n]; 3275 3277 Yfunc(nd,nz,sptr->y01A[n][i],max,Elo,Ehi,Eel,&Yp1,&Ys1,&Ehp,&Ehs); … … 3432 3434 3433 3435 /* Helper function to calculate primary and secondary yields and the average electron energy at infinity */ 3434 STATICvoid Yfunc(long nd,3436 inline void Yfunc(long nd, 3435 3437 long nz, 3436 3438 double y01, … … 3472 3474 /* this is Eq. 18 of WDB06 */ 3473 3475 /* Eel may be negative near threshold -> set yield to zero */ 3474 f3 = max(Eel,0.)/(eps*elec_esc_length(Eel,nd)* (1./gv.bin[nd]->AvRadius + 1.e7));3476 f3 = max(Eel,0.)/(eps*elec_esc_length(Eel,nd)*gv.bin[nd]->eyc); 3475 3477 *Ys = y2sec*f3*min(y01,maxval); 3476 3478 } … … 3614 3616 3615 3617 /* This calculates the y2 function for primary and Auger electrons (Eq. 8 of WDB06) */ 3616 STATICdouble y2pa(double Elo,3618 inline double y2pa(double Elo, 3617 3619 double Ehi, 3618 3620 long Zg, … … 3658 3660 3659 3661 /* This calculates the y2 function for secondary electrons (Eqs. 20-21 of WDB06) */ 3660 STATICdouble y2s(double Elo,3662 inline double y2s(double Elo, 3661 3663 double Ehi, 3662 3664 long Zg, … … 3713 3715 { 3714 3716 N0 = alpha*(1./sqR0 - 1./sqRh); 3715 E0 = alpha*ETILDE*(ASINH(x ) + ASINH(yl) - yh/sqRh);3717 E0 = alpha*ETILDE*(ASINH(x*sqR0 + yl*sqRh) - yh/sqRh); 3716 3718 } 3717 3719 } -
branches/newmole/source/grains_mie.cpp
r1918 r2112 1088 1088 mie_next_data(chFile,io2,chLine,&dl); 1089 1089 mie_read_realnum(chFile,chLine,&gv.bin[nd]->dustp[0],true,dl); 1090 /* constant needed in the evaluation of the electron escape length */ 1091 gv.bin[nd]->eec = pow((double)gv.bin[nd]->dustp[0],-0.85); 1090 1092 1091 1093 /* molecular weight of grain molecule (amu) */ … … 1108 1110 mie_next_data(chFile,io2,chLine,&dl); 1109 1111 mie_read_realnum(chFile,chLine,&gv.bin[nd]->AvRadius,true,dl); 1112 gv.bin[nd]->eyc = 1./gv.bin[nd]->AvRadius + 1.e7; 1110 1113 1111 1114 /* average grain area <4pi*a^2> for entire size distr (cm^2) */ … … 1279 1282 gv.bin[nd2]->dustp[j] = gv.bin[nd]->dustp[j]; 1280 1283 } 1284 gv.bin[nd2]->eec = gv.bin[nd]->eec; 1285 gv.bin[nd2]->eyc = gv.bin[nd]->eyc; 1281 1286 gv.bin[nd2]->DustWorkFcn = gv.bin[nd]->DustWorkFcn; 1282 1287 gv.bin[nd2]->BandGap = gv.bin[nd]->BandGap; -
branches/newmole/source/grains_qheat.cpp
r2023 r2112 622 622 if( trace.lgTrace && trace.lgDustBug ) 623 623 { 624 fprintf( ioQQQ, " grain heating: %.4e, integral %.4e, total rate %.4e\n", 625 gv.bin[nd]->GrainHeat,integral,Phi[0]); 624 double Rate2 = 0.; 625 for( int nz=0; nz < gv.bin[nd]->nChrg; nz++ ) 626 Rate2 += gv.bin[nd]->chrg[nz]->FracPop*gv.bin[nd]->chrg[nz]->HeatingRate2; 627 628 fprintf( ioQQQ, " grain heating: %.4e, integral %.4e, total rate %.4e lgNegRate %c\n", 629 gv.bin[nd]->GrainHeat,integral,Phi[0],TorF(lgNegRate)); 626 630 fprintf( ioQQQ, " av grain temp %.4e av grain enthalpy (Ryd) %.4e\n", 627 631 gv.bin[nd]->tedust,Umax); 628 632 fprintf( ioQQQ, " fwhm^2/(4ln2*c2/c0): %.4e fwhm (Ryd) %.4e fwhm/Umax %.4e\n", 629 633 NumEvents,fwhm,FwhmRatio ); 630 fprintf( ioQQQ, " lgQHTooWide %d\n", gv.bin[nd]->lgQHTooWide ); 634 fprintf( ioQQQ, " HeatingRate1 %.4e HeatingRate2 %.4e lgQHTooWide %c\n", 635 gv.bin[nd]->HeatingRate1*gv.bin[nd]->cnv_H_pCM3, Rate2*gv.bin[nd]->cnv_H_pCM3, 636 TorF(gv.bin[nd]->lgQHTooWide) ); 631 637 } 632 638 … … 911 917 * energies, the reshuffling for higher energies is done in the next loop 912 918 * phiTilde has units events/H/s/cell at default depletion */ 919 920 double NegHeatingRate = 0.; 913 921 914 922 for( nz=0; nz < gv.bin[nd]->nChrg; nz++ ) … … 983 991 *check += gptr->FracPop*check1*EN1RYD*gv.bin[nd]->cnv_H_pCM3; 984 992 993 sum += gptr->FracPop*check1*EN1RYD*gv.bin[nd]->cnv_H_pCM3; 994 985 995 if( DEBUG_LOC ) 986 996 { … … 990 1000 integral += phiTilde[i]*gv.bin[nd]->cnv_H_pCM3*rfield.anu[i]*EN1RYD; 991 1001 } 992 sum += gptr->FracPop*check1*EN1RYD*gv.bin[nd]->cnv_H_pCM3;993 1002 dprintf( ioQQQ, " integral test 1: integral %.6e %.6e\n", integral, sum ); 994 1003 } … … 1007 1016 1008 1017 /* >>chng 03 nov 06, check for extremely low HeatingRate and save CPU time, pah_crash.in, PvH */ 1009 if( fabs(gptr->HeatingRate2*gv.bin[nd]->cnv_H_pCM3)> 0.05*CONSERV_TOL*gv.bin[nd]->GrainHeat )1018 if( gptr->HeatingRate2*gv.bin[nd]->cnv_H_pCM3 > 0.05*CONSERV_TOL*gv.bin[nd]->GrainHeat ) 1010 1019 { 1011 1020 double *RateArr,Sum,ESum,DSum,Delta,E_av2,Corr; … … 1076 1085 } 1077 1086 1087 sum += gptr->FracPop*gptr->HeatingRate2*gv.bin[nd]->cnv_H_pCM3; 1088 1078 1089 if( DEBUG_LOC ) 1079 1090 { … … 1083 1094 integral += phiTilde[i]*gv.bin[nd]->cnv_H_pCM3*rfield.anu[i]*EN1RYD; 1084 1095 } 1085 sum += gptr->FracPop*gptr->HeatingRate2*gv.bin[nd]->cnv_H_pCM3;1086 1096 dprintf( ioQQQ, " integral test 2: integral %.6e %.6e\n", integral, sum ); 1087 1097 } 1088 1098 1089 1099 free( RateArr ); 1100 } 1101 else 1102 { 1103 NegHeatingRate += gptr->FracPop*gptr->HeatingRate2*gv.bin[nd]->cnv_H_pCM3; 1090 1104 } 1091 1105 } … … 1109 1123 1110 1124 /* >>chng 03 nov 06, check for extremely low HeatingRate and save CPU time, PvH */ 1111 if( fabs(gv.bin[nd]->HeatingRate1*gv.bin[nd]->cnv_H_pCM3)> 0.05*CONSERV_TOL*gv.bin[nd]->GrainHeat )1125 if( gv.bin[nd]->HeatingRate1*gv.bin[nd]->cnv_H_pCM3 > 0.05*CONSERV_TOL*gv.bin[nd]->GrainHeat ) 1112 1126 { 1113 1127 /* limits for Taylor expansion of (1+x)*exp(-x) */ … … 1153 1167 ylo = yhi; 1154 1168 } 1155 } 1156 1157 if( DEBUG_LOC ) 1158 { 1159 double integral = 0.; 1169 1170 sum += gv.bin[nd]->HeatingRate1*gv.bin[nd]->cnv_H_pCM3; 1171 1172 if( DEBUG_LOC ) 1173 { 1174 double integral = 0.; 1175 for( i=0; i < gv.bin[nd]->qnflux; i++ ) 1176 { 1177 integral += phiTilde[i]*gv.bin[nd]->cnv_H_pCM3*rfield.anu[i]*EN1RYD; 1178 } 1179 dprintf( ioQQQ, " integral test 3: integral %.6e %.6e\n", integral, sum ); 1180 } 1181 } 1182 else 1183 { 1184 NegHeatingRate += gv.bin[nd]->HeatingRate1*gv.bin[nd]->cnv_H_pCM3; 1185 } 1186 1187 /* here we account for the negative heating rates, we simply do that by scaling the entire 1188 * phiTilde array down by a constant factor such that the total amount of energy is conserved 1189 * This treatment assures that phiTilde never goes negative, which avoids problems further on */ 1190 if( NegHeatingRate < 0. ) 1191 { 1192 double scale_fac = (sum+NegHeatingRate)/sum; 1160 1193 for( i=0; i < gv.bin[nd]->qnflux; i++ ) 1161 { 1162 integral += phiTilde[i]*gv.bin[nd]->cnv_H_pCM3*rfield.anu[i]*EN1RYD; 1163 } 1164 sum += gv.bin[nd]->HeatingRate1*gv.bin[nd]->cnv_H_pCM3; 1165 dprintf( ioQQQ, " integral test 3: integral %.6e %.6e\n", integral, sum ); 1166 } 1194 phiTilde[i] *= scale_fac; 1195 1196 sum += NegHeatingRate; 1197 1198 if( DEBUG_LOC ) 1199 { 1200 double integral = 0.; 1201 for( i=0; i < gv.bin[nd]->qnflux; i++ ) 1202 { 1203 integral += phiTilde[i]*gv.bin[nd]->cnv_H_pCM3*rfield.anu[i]*EN1RYD; 1204 } 1205
