00001
00008 #include <math.h>
00009 #include <iostream.h>
00010 #include <fstream.h>
00011 #include <iomanip.h>
00012 #include <string>
00013 #include "ReactorConstants.hh"
00014 #include "ReactorFortran.hh"
00015 #include "MyCfSource.hh"
00016
00017 MyCfSource::MyCfSource(int newIsotope,
00018 int newRmaxgen){
00019
00020 Isotope = newIsotope;
00021 Rmaxgen = newRmaxgen;
00022
00023
00024
00025
00026
00027 if(Isotope == 252){
00028
00029
00030 bool static first=1;
00031 float static fspace[200];
00032
00033 if(first){
00034 float xlo = 0.;
00035 float xhi = 50.;
00036 funlxp_(Cf252NeutronSpectrum,fspace,xlo,xhi);
00037 first = 0;
00038 }
00039
00040
00041 fstream cf252_position("data/cf252_position.txt", ios::in);
00042
00043
00044 Nsources = 0;
00045 char paramLine[256];
00046 string dummy;
00047 bool done = false;
00048 bool numSet = false;
00049 int positionNum = 0;
00050
00051 while(!done){
00052
00053
00054 if(cf252_position.peek() == '#'){
00055
00056 cf252_position.getline(paramLine, 256);
00057 continue;
00058 }
00059
00060
00061 if(cf252_position.peek() == 'e' || cf252_position.peek() == 'E'){
00062
00063 if(Nsources == 0) cout << " Cf252 ERROR: "
00064 << "number of cf252 sources = 0" << endl;
00065 done = true;
00066 continue;
00067 }
00068
00069
00070 if(cf252_position.peek() == 'n' || cf252_position.peek() == 'N'){
00071
00072 if(numSet){
00073
00074 cf252_position.getline( paramLine, 256 );
00075 continue;
00076 }
00077 cf252_position >> dummy;
00078 while(cf252_position.peek() == ' ' || cf252_position.peek() == '=')
00079 cf252_position.ignore(1);
00080
00081 cf252_position >> Nsources;
00082 if(Nsources == 0){
00083 cout << " Cf252 ERROR: number of cf252 sources = 0" << endl;
00084 done = true;
00085 continue;
00086 }
00087
00088 numSet = true;
00089 continue;
00090 }
00091
00092
00093 if(cf252_position.peek() == 'p' || cf252_position.peek() == 'P'){
00094
00095 if(Nsources == 0 || positionNum >= Nsources){
00096
00097 cout << " Cf252 ERROR: too many positions " << positionNum+1
00098 << " given for the number of sources " << Nsources << endl;
00099 cf252_position.getline( paramLine, 256 );
00100 positionNum++;
00101 continue;
00102 }
00103 cf252_position >> dummy;
00104 while(cf252_position.peek() == ' ' || cf252_position.peek() == '=')
00105 cf252_position.ignore(1);
00106
00107 cf252_position >> R[positionNum] >> zR[positionNum]
00108 >> phiR[positionNum];
00109
00110
00111 if(R[positionNum] > Rmaxgen){
00112 cout << " Cf252 ERROR: R[" << positionNum << "] of "
00113 << R[positionNum] << " > Rmaxgen" << endl;
00114 done = true;
00115 continue;
00116 }
00117 if(zR[positionNum] < -1. || zR[positionNum] > 1.){
00118 cout << " Cf252 ERROR: CosTheta["
00119 << positionNum << "] of " << zR[positionNum] << endl;
00120 done = true;
00121 continue;
00122 }
00123 if(phiR[positionNum] > 2*k.pi){
00124 cout << " Cf252 ERROR: Phi[" << positionNum << "] of "
00125 << phiR[positionNum] << " > 2*pi" << endl;
00126 done = true;
00127 continue;
00128 }
00129
00130 positionNum++;
00131 continue;
00132 }
00133
00134
00135 if(cf252_position.peek() == ' ' || cf252_position.peek() == '\n'){
00136
00137 cf252_position.ignore(1);
00138 continue;
00139 }
00140 }
00141
00142 if(positionNum < Nsources){
00143 cout << " Cf252 ERROR: not enough positions " << positionNum
00144 << " given for the number of sources " << Nsources << endl;
00145 }
00146
00147 for(int n=0;n<Nsources;n++){
00148
00149
00150
00151
00152 int len = 1;
00153 funlux_(fspace,neutronE[n],len);
00154
00155
00156 }
00157
00158
00159 for(int n=Nsources;n<k.Ndim;n++){
00160 neutronE[n] = 0.;
00161 R[n] = 0.;
00162 zR[n] = 0.;
00163 phiR[n] = 0.;
00164 }
00165
00166 }
00167
00168 if(Isotope == 255){
00169
00170 Nsources = 0;
00171 for(int n=Nsources;n<k.Ndim;n++){
00172
00173 neutronE[n] = 0.;
00174 R[n] = 0.;
00175 zR[n] = 0.;
00176 phiR[n] = 0.;
00177 }
00178 }
00179
00180 }
00181
00182 MyCfSource::~MyCfSource(){
00183 ;
00184 }
00185
00186 MyCfSource::MyCfSource(const MyCfSource& CfSource){
00187
00188 Isotope = CfSource.Isotope;
00189 Rmaxgen = CfSource.Rmaxgen;
00190
00191 for(int n=0;n<Sdim;n++){
00192 neutronEnergy[n] = CfSource.neutronEnergy[n];
00193 neutronProb[n] = CfSource.neutronProb[n];
00194 }
00195
00196 Nsources = CfSource.Nsources;
00197
00198 for(int n=0;n<k.Ndim;n++){
00199 R[n] = CfSource.R[n];
00200 zR[n] = CfSource.zR[n];
00201 phiR[n] = CfSource.phiR[n];
00202 neutronE[n] = CfSource.neutronE[n];
00203 }
00204 }
00205
00206 MyCfSource& MyCfSource::operator=(const MyCfSource& rhs){
00207
00208 if(this == &rhs)return *this;
00209
00210 Isotope = rhs.Isotope;
00211 Rmaxgen = rhs.Rmaxgen;
00212
00213 for(int n=0;n<Sdim;n++){
00214 neutronEnergy[n] = rhs.neutronEnergy[n];
00215 neutronProb[n] = rhs.neutronProb[n];
00216 }
00217
00218 Nsources = rhs.Nsources;
00219
00220 for(int n=0;n<k.Ndim;n++){
00221 R[n] = rhs.R[n];
00222 zR[n] = rhs.zR[n];
00223 phiR[n] = rhs.phiR[n];
00224 neutronE[n] = rhs.neutronE[n];
00225 }
00226
00227 return *this;
00228
00229 }
00230
00231 float MyCfSource::Cf252NeutronSpectrum(const float& x){
00232
00233
00234 float N = 0.;
00235
00236 float scale = 1/(2*k.pi*0.359);
00237
00238
00239 float fminus = exp(-(sqrt(x)-sqrt(0.359))*(sqrt(x)-sqrt(0.359))/1.175);
00240 float fplus = exp(-(sqrt(x)+sqrt(0.359))*(sqrt(x)+sqrt(0.359))/1.175);
00241
00242 N = scale*(fminus-fplus);
00243
00244
00245 return N;
00246 }