00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "bdfls_tools.hpp"
00039 #include "convert.hpp"
00040 #include "global_params.hpp"
00041 #include "messaging.hpp"
00042
00043 extern GlobalParameterClass Global;
00044
00045
00046
00047
00048 void mass_life_link::print( )
00049 {
00050 cout << za_ << " " << mass_ << " " << lifetime_ << endl;
00051 }
00052
00053
00054
00055
00056
00057 bool mass_life_list::at(int x, mass_life_list::iterator& link)
00058 {
00059 for( link = begin();
00060 link != end();
00061 ++link )
00062 {
00063 if ( link->ZA( ) == x )
00064 {
00065 return true;
00066 }
00067 }
00068 Warning("mass_life_list::at",pastenum("could not find a match for ZA = ",x));
00069 return false;
00070 }
00071
00072 void mass_life_list::print()
00073 {
00074 for( mass_life_list::iterator link = begin();
00075 link != end();
00076 ++link)
00077 {
00078 link->print( );
00079 }
00080 }
00081
00082
00083
00084
00085 bdflsClass::bdflsClass()
00086 {
00087
00088
00089 section[0]="group";
00090 section[1]="flux";
00091 section[2]="mass";
00092 section[3]="lifetime";
00093 section[4]="nuclear constant";
00094 section[5]="temperature set";
00095 section[6]="subshell designator";
00096
00097 nsection_max=7;
00098 nsection=0;
00099 lastsection=-1;
00100 nc_index=0;
00101
00102 }
00103
00104
00105 bdflsClass ::~bdflsClass()
00106 {
00107 }
00108
00109
00110 void bdflsClass::read( )
00111 {
00112 char* bdfls_filename="./bdfls";
00113
00114 if (getenv("BDFLSPATH")!=0)
00115 {
00116 bdfls_filename=getenv("BDFLSPATH");
00117 }
00118
00119 string infostring("Opening bdfls file: ");
00120 infostring+=bdfls_filename;
00121
00122 Info("",infostring );
00123
00124 bdflsFile.open(bdfls_filename,ios::in);
00125
00126 if ( !bdflsFile.is_open() )
00127 {
00128 FatalError("bdflsClass::read","Error opening bdlfs file.");
00129 }
00130
00131 read_sections();
00132
00133 Info("","Closing bdfls file ...");
00134 bdflsFile.close();
00135 }
00136
00137
00138 void bdflsClass::read_sections( )
00139 {
00140
00141 string small_string;
00142 double mass, life;
00143 int za;
00144 mass_life_link XYdata;
00145 mass_life_list::iterator XYptr;
00146 bool mass_done = false;
00147 bool life_done = false;
00148 vector<string> split_line;
00149
00150 while( nsection < nsection_max )
00151 {
00152 if ( nsection != lastsection )
00153 {
00154 Info("bdflsClass::read_sections","Reading "+section[nsection]+" information...");
00155 lastsection=nsection;
00156 }
00157
00158
00159
00160 switch( nsection )
00161 {
00162
00163 case 0:
00164 if ( !EndofSection() )
00165 {
00166 }
00167 else
00168 { ++nsection;}
00169 break;
00170
00171 case 1:
00172 if ( !EndofSection() )
00173 {
00174 }
00175 else
00176 { ++nsection;}
00177 break;
00178
00179 case 2:
00180 if ( !EndofSection() )
00181 {
00182 split_line = split(stringbuff);
00183 za = stoi(split_line[0]);
00184 mass = stod(split_line[1]);
00185
00186
00187
00188
00189
00190
00191
00192 if(life_done && Mass_Life.at(za, XYptr))
00193 {
00194 XYptr->Mass() = mass;
00195 }
00196 else
00197 {
00198 XYdata.ZA() = za;
00199 XYdata.Mass() = mass;
00200 XYdata.LifeTime() = 1.0e50;
00201 Mass_Life.insert(Mass_Life.end(), XYdata);
00202 }
00203 }
00204 else
00205 {
00206 ++nsection;
00207 mass_done = true;
00208 }
00209 break;
00210
00211 case 3:
00212 if ( !EndofSection() )
00213 {
00214 small_string = stringbuff.substr(0,10);
00215 za = stoi(small_string);
00216 if ( stringbuff.length() < 11 )
00217 {
00218
00219 if( Mass_Life.at(za, XYptr))
00220 {
00221 XYptr->LifeTime() = 1.e50;
00222 }
00223 }
00224 else
00225 {
00226 small_string = stringbuff.substr(11,21);
00227 small_string = remove_all_blanks( small_string);
00228 if ( small_string.length() == 0 )
00229 {
00230 life = 1.e50;
00231 }
00232 else
00233 {
00234 life = stod(small_string);
00235 }
00236
00237 if(mass_done && Mass_Life.at(za, XYptr))
00238 {
00239 XYptr->LifeTime() = life;
00240 }
00241 else
00242 {
00243 XYdata.ZA() = za;
00244 XYdata.Mass() = -1.0;
00245 XYdata.LifeTime() = life;
00246 Mass_Life.insert(Mass_Life.end(), XYdata);
00247 }
00248 }
00249 }
00250 else
00251 { ++nsection;}
00252 break;
00253
00254 case 4:
00255 if ( !EndofSection() )
00256 {
00257 if ( nc_index > 0 )
00258 {
00259 small_string=stringbuff.substr(0,16);
00260 nuclear_constants[nc_index]=stod(small_string);
00261 }
00262 nc_index=nc_index+1;
00263 }
00264 else
00265 { ++nsection;}
00266 break;
00267
00268 case 5:
00269 if ( !EndofSection() )
00270 {
00271 }
00272 else
00273 { ++nsection;}
00274 break;
00275
00276 case 6:
00277 if ( !EndofSection() )
00278 {
00279 }
00280 else
00281 { ++nsection;}
00282 break;
00283 }
00284 }
00285 }
00286
00287
00288
00289
00290 bool bdflsClass::EndofSection( )
00291 {
00292
00293
00294
00295
00296
00297 getline( bdflsFile, stringbuff );
00298
00299 if ( stringbuff.length() >= 73 && stringbuff[72]=='1' )
00300 {
00301 return true;
00302 }
00303 else
00304 {
00305 return false;
00306 }
00307 }
00308
00309