cloudy  trunk
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
iso_error.cpp
Go to the documentation of this file.
1 /* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2  * others. For conditions of distribution and use see copyright notice in license.txt */
3 /*HeLikeError fills uncertainty arrays */
4 #include "cddefines.h"
5 #include "iso.h"
6 
7 /* This routine handles errors when that option is turned on (via the command
8  * "atom he-like error generation" */
9 void iso_put_error(long int ipISO,
10  long int nelem,
11  long int ipHi,
12  long int ipLo,
13  long int whichData,
14  realnum errorToPut)
15 {
16 
17  DEBUG_ENTRY( "iso_put_error()" );
18 
19  if( iso.lgRandErrGen[ipISO] )
20  {
21  /* whichData is either IPRAD, IPCOLLIS, or IPENERGY */
22  ASSERT( whichData <= 2 );
23  ASSERT( ipISO <= NISO );
24  ASSERT( nelem < LIMELM );
25  ASSERT( ipHi <= iso.numLevels_max[ipISO][nelem] );
26  ASSERT( ipLo <= iso.numLevels_max[ipISO][nelem] );
27  ASSERT( errorToPut >= 0. );
28 
29  iso.Error[ipISO][nelem][ipHi][ipLo][whichData] = errorToPut;
30  }
31  return;
32 }
33 
34 void iso_error_generation( long ipISO, long nelem )
35 {
36 
37  long ipHi, ipLo, typeOfRate;
38  realnum ErrorToPut;
39 
40  DEBUG_ENTRY( "iso_error_generation()" );
41 
42  /* put recombination errors into iso.Error[ipISO] array */
43  for( ipHi=0; ipHi<iso.numLevels_max[ipISO][nelem]; ipHi++ )
44  {
45  if( N_(ipHi)<=5 )
46  {
47  ErrorToPut = 0.02f;
48  }
49  else if( N_(ipHi)>iso.n_HighestResolved_max[ipISO][nelem] )
50  {
51  ErrorToPut = 0.02f;
52  }
53  else if( L_(ipHi)>=3 )
54  {
55  ErrorToPut = 0.005f;
56  }
57  else if( L_(ipHi)==2 )
58  {
59  ErrorToPut = 0.01f;
60  }
61  else if( L_(ipHi)==1 )
62  {
63  ErrorToPut = 0.025f;
64  }
65  else
66  {
67  ErrorToPut = 0.05f;
68  }
69  iso_put_error(ipISO,nelem,iso.numLevels_max[ipISO][nelem],ipHi,IPRAD,ErrorToPut);
70  }
71  /* Error for total recombination */
72  iso_put_error(ipISO,nelem,iso.numLevels_max[ipISO][nelem],iso.numLevels_max[ipISO][nelem],IPRAD,0.02f);
73 
74  for( ipHi=1; ipHi<= iso.numLevels_max[ipISO][nelem]; ipHi++ )
75  {
76  /* >>chng 06 mar 15, the upper limit incorrectly went to numLevels_max */
77  for( ipLo=0; ipLo<= ipHi; ipLo++ )
78  {
79  for( typeOfRate=0; typeOfRate<=1; typeOfRate++ )
80  {
81  if( iso.Error[ipISO][nelem][ipHi][ipLo][typeOfRate] >= 0. )
82  {
83  iso.ErrorFactor[ipISO][nelem][ipHi][ipLo][typeOfRate] =
84  (realnum)MyGaussRand( iso.Error[ipISO][nelem][ipHi][ipLo][typeOfRate] );
85  ASSERT( iso.ErrorFactor[ipISO][nelem][ipHi][ipLo][typeOfRate] > 0. );
86  }
87  else
88  {
89  iso.ErrorFactor[ipISO][nelem][ipHi][ipLo][typeOfRate] = 1.0f;
90  }
91  }
92  }
93  }
94 
95  /* set flag saying that error generation has been done. */
96  iso.lgErrGenDone[ipISO][nelem] = true;
97  return;
98 }

Generated for cloudy by doxygen 1.8.4