00001 /* This file is part of Cloudy and is copyright (C)1978-2010 by Gary J. Ferland and 00002 * others. For conditions of distribution and use see copyright notice in license.txt */ 00003 /*HeLikeError fills uncertainty arrays */ 00004 #include "cddefines.h" 00005 #include "iso.h" 00006 00007 /* This routine handles errors when that option is turned on (via the command 00008 * "atom he-like error generation" */ 00009 void iso_put_error(long int ipISO, 00010 long int nelem, 00011 long int ipHi, 00012 long int ipLo, 00013 long int whichData, 00014 realnum errorOpt, 00015 realnum errorPess) 00016 { 00017 00018 DEBUG_ENTRY( "iso_put_error()" ); 00019 00020 if( iso.lgRandErrGen[ipISO] ) 00021 { 00022 /* whichData is either IPRAD, IPCOLLIS, or IPENERGY */ 00023 ASSERT( whichData <= 2 ); 00024 ASSERT( ipISO < NISO ); 00025 ASSERT( nelem < LIMELM ); 00026 ASSERT( ipHi <= iso.numLevels_max[ipISO][nelem] ); 00027 ASSERT( ipLo <= iso.numLevels_max[ipISO][nelem] ); 00028 ASSERT( errorOpt >= 0. ); 00029 ASSERT( errorPess >= 0. ); 00030 00031 if( !iso.lgPessimisticErrors ) 00032 iso.Error[ipISO][nelem][ipHi][ipLo][whichData] = errorOpt; 00033 else 00034 iso.Error[ipISO][nelem][ipHi][ipLo][whichData] = errorPess; 00035 } 00036 return; 00037 } 00038 00039 void iso_error_generation( long ipISO, long nelem ) 00040 { 00041 long ipHi, ipLo, typeOfRate; 00042 00043 DEBUG_ENTRY( "iso_error_generation()" ); 00044 00045 iso.ErrorFactor[ipISO][nelem][iso.numLevels_max[ipISO][nelem]][iso.numLevels_max[ipISO][nelem]][IPRAD] = 00046 (realnum)MyGaussRand( iso.Error[ipISO][nelem][iso.numLevels_max[ipISO][nelem]][iso.numLevels_max[ipISO][nelem]][IPRAD] ); 00047 00048 for( ipHi=1; ipHi<= iso.numLevels_max[ipISO][nelem]; ipHi++ ) 00049 { 00050 /* >>chng 06 mar 15, the upper limit incorrectly went to numLevels_max */ 00051 for( ipLo=0; ipLo< ipHi; ipLo++ ) 00052 { 00053 for( typeOfRate=0; typeOfRate<=1; typeOfRate++ ) 00054 { 00055 if( iso.Error[ipISO][nelem][ipHi][ipLo][typeOfRate] >= 0. ) 00056 { 00057 iso.ErrorFactor[ipISO][nelem][ipHi][ipLo][typeOfRate] = 00058 (realnum)MyGaussRand( iso.Error[ipISO][nelem][ipHi][ipLo][typeOfRate] ); 00059 ASSERT( iso.ErrorFactor[ipISO][nelem][ipHi][ipLo][typeOfRate] > 0. ); 00060 } 00061 else 00062 { 00063 iso.ErrorFactor[ipISO][nelem][ipHi][ipLo][typeOfRate] = 1.0f; 00064 } 00065 } 00066 } 00067 } 00068 00069 /* set flag saying that error generation has been done. */ 00070 iso.lgErrGenDone[ipISO][nelem] = true; 00071 return; 00072 }