Changeset 2449 for branches/newmole/source
- Timestamp:
- 11/09/08 12:46:54 (2 months ago)
- Location:
- branches/newmole/source
- Files:
-
- 3 modified
- 1 copied
-
cddefines.h (modified) (2 diffs)
-
dynamics.cpp (modified) (2 diffs)
-
hydro_vs_rates.cpp (modified) (1 diff)
-
TestFpCheck.cpp (copied) (copied from trunk/source/TestFpCheck.cpp)
Legend:
- Unmodified
- Added
- Removed
-
branches/newmole/source/cddefines.h
r2441 r2449 788 788 inline bool fp_equal( sys_float x, sys_float y, int n=3 ) 789 789 { 790 # ifdef _MSC_VER791 /* disable warning that conditional expression is constant, true or false in if */792 # pragma warning( disable : 4127 )793 # endif794 790 ASSERT( n >= 1 ); 795 791 // mimic IEEE behavior … … 849 845 return ( abs( x-y ) <= tol ); 850 846 } 847 848 /** checks whether a number is within bounds */ 849 inline bool fp_bound( sys_float lo, sys_float x, sys_float hi, int n=3 ) 850 { 851 ASSERT( n >= 1 ); 852 // mimic IEEE behavior 853 if( isnan(x) || isnan(lo) || isnan(hi) ) 854 return false; 855 if( fp_equal(lo,hi,n) ) 856 return fp_equal(0.5f*(lo+hi),x,n); 857 if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -((sys_float)n+0.1f)*FLT_EPSILON ) 858 return false; 859 return true; 860 } 861 inline bool fp_bound( double lo, double x, double hi, int n=3 ) 862 { 863 ASSERT( n >= 1 ); 864 // mimic IEEE behavior 865 if( isnan(x) || isnan(lo) || isnan(hi) ) 866 return false; 867 if( fp_equal(lo,hi,n) ) 868 return fp_equal(0.5*(lo+hi),x,n); 869 if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -((double)n+0.1)*DBL_EPSILON ) 870 return false; 871 return true; 872 } 873 inline bool fp_bound_tol( sys_float lo, sys_float x, sys_float hi, sys_float tol ) 874 { 875 ASSERT( tol > 0.f ); 876 // mimic IEEE behavior 877 if( isnan(x) || isnan(lo) || isnan(hi) ) 878 return false; 879 if( fp_equal_tol(lo,hi,tol) ) 880 return fp_equal_tol(0.5f*(lo+hi),x,tol); 881 if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -tol ) 882 return false; 883 return true; 884 } 885 inline bool fp_bound_tol( double lo, double x, double hi, double tol ) 886 { 887 ASSERT( tol > 0. ); 888 // mimic IEEE behavior 889 if( isnan(x) || isnan(lo) || isnan(hi) ) 890 return false; 891 if( fp_equal_tol(lo,hi,tol) ) 892 return fp_equal_tol(0.5*(lo+hi),x,tol); 893 if( ((hi-x)/(hi-lo))*((x-lo)/(hi-lo)) < -tol ) 894 return false; 895 return true; 896 } 897 851 898 852 899 #undef POW2 -
branches/newmole/source/dynamics.cpp
r2440 r2449 827 827 828 828 /* this is index of upstream cell in structure stored from previous iteration */ 829 double upstream, dilution, dilutionleft, dilutionright, frac_next , testval;829 double upstream, dilution, dilutionleft, dilutionright, frac_next; 830 830 831 831 /* Properties for cell half as far upstream, used to converge timestep */ … … 907 907 frac_next); 908 908 909 testval = (Old_EnthalpyDensity[ipUpstream]*dilutionleft - AdvecSpecificEnthalpy) *910 (AdvecSpecificEnthalpy - Old_EnthalpyDensity[ipUpstream+1]*dilutionright);911 912 909 ASSERT( Old_depth[ipUpstream] <= upstream && upstream <= Old_depth[ipUpstream+1] ); 913 if( testval <= -SMALLFLOAT ) 914 { 915 fprintf(ioQQQ,"PROBLEM advected enthalpy density is not conserved %e\t%e\t%e\t%e\n", 916 testval , 917 Old_EnthalpyDensity[ipUpstream]*dilutionleft, 918 AdvecSpecificEnthalpy, 919 Old_EnthalpyDensity[ipUpstream+1]*dilutionright); 920 } 921 922 ASSERT( testval > -SMALLFLOAT ); 910 911 // we have a mix of realnum and double here, so make sure realnum is used for the test... 912 realnum lo = (realnum)(Old_EnthalpyDensity[ipUpstream]*dilutionleft); 913 realnum x = (realnum)AdvecSpecificEnthalpy; 914 realnum hi = (realnum)(Old_EnthalpyDensity[ipUpstream+1]*dilutionright); 915 if( ! fp_bound(lo,x,hi) ) 916 { 917 fprintf(ioQQQ,"PROBLEM advected enthalpy density is not conserved %.16e\t%.16e\t%.16e\t%e\t%e\n", 918 lo, x, hi, (hi-x)/(hi-lo), (x-lo)/(hi-lo)); 919 } 920 921 ASSERT( fp_bound(lo,x,hi) ); 922 923 923 for( nelem=ipHYDROGEN; nelem<LIMELM; ++nelem) 924 924 { -
branches/newmole/source/hydro_vs_rates.cpp
r2139 r2449 36 36 double coll_str; 37 37 38 global_ipISO = ipISO; 39 global_nelem = nelem; 40 global_ipHi = ipHi; 41 global_ipLo = ipLo; 42 global_temp = temp; 43 global_Collider = Collider; 44 global_Aul = Aul; 45 46 /* evaluate collision strength, two options, 47 * do thermal average (very slow) if set with 48 * SET COLLISION STRENGTH AVERAGE command, 49 * default just do point at kT 50 * tests show no impact on test suite, much faster */ 51 if( iso.lgCollStrenThermAver ) 52 { 53 /* do average over Maxwellian */ 54 coll_str = qg32( 0.0, 1.0, Therm_ave_coll_str_int_VS80); 55 coll_str += qg32( 1.0, 10.0, Therm_ave_coll_str_int_VS80); 56 } 57 else 58 { 59 /* the argument to the function is equivalent to evaluating the function at 60 * hnu = kT */ 61 coll_str = hydro_vs_coll_str( EVRYD*global_temp/TE1RYD ); 38 if( Collider == ipELECTRON ) 39 { 40 coll_str = hydro_vs_deexcit( ipISO, nelem, ipHi, ipLo, Aul); 41 } 42 else 43 { 44 global_ipISO = ipISO; 45 global_nelem = nelem; 46 global_ipHi = ipHi; 47 global_ipLo = ipLo; 48 global_temp = temp; 49 global_Collider = Collider; 50 global_Aul = Aul; 51 52 /* evaluate collision strength, two options, 53 * do thermal average (very slow) if set with 54 * SET COLLISION STRENGTH AVERAGE command, 55 * default just do point at kT 56 * tests show no impact on test suite, much faster */ 57 if( iso.lgCollStrenThermAver ) 58 { 59 /* do average over Maxwellian */ 60 coll_str = qg32( 0.0, 1.0, Therm_ave_coll_str_int_VS80); 61 coll_str += qg32( 1.0, 10.0, Therm_ave_coll_str_int_VS80); 62 } 63 else 64 { 65 /* the argument to the function is equivalent to evaluating the function at 66 * hnu = kT */ 67 coll_str = hydro_vs_coll_str( EVRYD*global_temp/TE1RYD ); 68 } 62 69 } 63 70
