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 "mf4classes.hpp"
00039 #include "endl_formats.hpp"
00040 #include "global_params.hpp"
00041
00042 extern ENDLClass ENDL;
00043 extern GlobalParameterClass Global;
00044
00045
00046
00047 void two_d_isotropic::expand_data(int MT)
00048
00049 {
00050 double e_in;
00051
00052 one_d_isotropic new_link;
00053
00054 if(MT > 0)
00055 {
00056
00057 e_in = ENDL.threshold;
00058 }
00059 else
00060 {
00061
00062 e_in = 0.0;
00063 }
00064
00065 double min_e_in = Global.Value( "Min_n_energy" );
00066 if ( e_in < min_e_in ) e_in = min_e_in;
00067
00068
00069 insert(end(), new_link);
00070 two_d_isotropic::iterator this_ein = end();
00071 --this_ein;
00072 this_ein->initiate(e_in);
00073
00074
00075 e_in = ENDL.Max_E_in;
00076 insert(end(), new_link);
00077 this_ein = end();
00078 --this_ein;
00079 this_ein->initiate(e_in);
00080 }
00081
00082
00083
00084 void two_d_Legendre::expand_data(mf4_file& inFile, int NE, int MF)
00085
00086
00087 {
00088 bool done = false;
00089
00090 for (int iNE=0; iNE < NE; iNE++ )
00091 {
00092 one_E_in( inFile, MF, &done );
00093 }
00094
00095
00096 if ( ( INT.size() > 1 ) || ( INT[ 0 ] != 2 ) )
00097 {
00098 expand_interp();
00099 }
00100 }
00101
00102 void two_d_Legendre::one_E_in( mf4_file& inFile, int MF, bool *done )
00103
00104
00105 {
00106 double ZERO;
00107 double E_1;
00108 int iZERO;
00109 int nLC;
00110
00111 string linebuff;
00112 string strbuff;
00113 two_d_Legendre::iterator this_link;
00114
00115 if ( MF == 6 )
00116 {
00117 int ND;
00118 int NA;
00119 int NW;
00120 int NEP;
00121
00122 getline( inFile, linebuff );
00123 read_ddiiii(&linebuff, &ZERO,
00124 &E_1,
00125 &ND,
00126 &NA,
00127 &NW,
00128 &NEP);
00129
00130 nLC=NW;
00131 if(ND > 0)
00132 {
00133 Unimplemented("two_d_Legendre::one_E_in",
00134 "Implement discrete energies for Legendre");
00135 }
00136 }
00137 else if ( MF==4 )
00138 {
00139 double dT;
00140 int iLT;
00141 int NL;
00142
00143 getline( inFile, linebuff );
00144 read_ddiiii(&linebuff, &dT,
00145 &E_1,
00146 &iLT,
00147 &iZERO,
00148 &NL,
00149 &iZERO);
00150
00151 nLC=NL;
00152 if(dT != 0.0)
00153 {
00154 Warning("two_d_Legendre::one_E_in",
00155 pastenum("Non-zero temperature (",dT)+
00156 " eV) in Legendre data, zeroing it."
00157 );
00158 }
00159 }
00160 else
00161 {
00162 Unimplemented("two_d_Legendre::one_E_in",
00163 pastenum("No code written for Legendre in MF = ",MF));
00164 }
00165
00166
00167 one_d_Legendre new_link;
00168
00169 if( !(*done) )
00170 {
00171
00172 insert(end(), new_link);
00173 this_link = end();
00174 --this_link;
00175
00176
00177 this_link->E_in() = E_1 * ENDL.eV2MeV;
00178
00179
00180 this_link->coef.get_space( nLC + 1 );
00181 this_link->coef.at(0) = 1.0;
00182 }
00183
00184
00185 for ( int iNR=0; iNR < nLC; ++iNR )
00186 {
00187 double next_coef;
00188 int iR = iNR % 6;
00189 if ( iR == 0 ) getline( inFile, linebuff);
00190 if( !*(done) )
00191 {
00192 strbuff = linebuff.substr(iR*11, 11);
00193 read_d( &strbuff, &next_coef );
00194 this_link->coef.at( iNR + 1 ) = next_coef;
00195 }
00196 }
00197
00198
00199 if( ( this_link->E_in() > ENDL.Max_E_in ) && !(*done) )
00200 {
00201 set_interp( );
00202 chop_highE( ENDL.Max_E_in );
00203 *done = true;
00204 }
00205 else if( !(*done) )
00206 {
00207
00208 this_link->expand();
00209
00210 double dE = ENDL_EPSILON( ENDL.Max_E_in );
00211 if( this_link->E_in() > ENDL.Max_E_in - dE )
00212 {
00213 *done = true;
00214 }
00215 }
00216 }
00217
00218
00219 void two_d_Legendre::expand_interp()
00220
00221
00222 {
00223 if( INT[0] == -7 )
00224 {
00225 SevereError("two_d_Legendre::expand_interp","expand_interp called twice");
00226 }
00227
00228
00229 set_interp();
00230
00231
00232 for( two_d_Legendre::iterator this_link = begin();
00233 this_link != end(); ++this_link )
00234 {
00235 this_link->get_bins();
00236 }
00237
00238 thicken();
00239
00240
00241 INT[0] = -7;
00242 }
00243
00244
00245
00246 void mf4_table::master( mf4_file& inFile )
00247 {
00248 int NE;
00249 int NR;
00250
00251
00252 inFile.read_line3( &NR, &NE );
00253 inFile.get_regions(NR, NBT, INT);
00254
00255 read_data(inFile, NE );
00256
00257 widen_jumps();
00258
00259
00260
00261 renorm();
00262
00263 if (ENDL.write_file)
00264 {
00265 write_endl( 1 );
00266
00267 if ( ( ENDL.T == 2 ) && ( ENDL.res_za <= 2004 ) )
00268 {
00269 ENDL.outgoing_particle = 10 + ENDL.za_to_yo( ENDL.res_za );
00270 mirror( );
00271 write_endl( 1 );
00272 }
00273 }
00274 }
00275
00276 void mf4_table::read_data(mf4_file& inFile, int NE)
00277
00278
00279 {
00280
00281 for (int iNE=0; iNE < NE; iNE++ )
00282 {
00283 one_E_in(inFile);
00284 }
00285 }
00286
00287 void mf4_table::one_E_in(mf4_file& inFile)
00288
00289 {
00290 int iZERO;
00291
00292 string linebuff;
00293 string strbuff;
00294
00295 double T;
00296 double E_1;
00297 int LT;
00298 int NR;
00299 int NP;
00300
00301 getline( inFile, linebuff );
00302 read_ddiiii(&linebuff, &T,
00303 &E_1,
00304 <,
00305 &iZERO,
00306 &NR ,
00307 &NP);
00308
00309 if( T != 0.0)
00310 {
00311 SevereError("mf4_table::one_E_in",
00312 pastenum("Non-zero temperature for tabulated data ",T));
00313 }
00314 if( NR != 1 )
00315 {
00316 SevereError("mf4_table::one_E_in",
00317 "Unwritten code! Expected single region ");
00318 }
00319 if( NP < 1 )
00320 {
00321 SevereError("mf4_table::one_E_in",
00322 pastenum("Negative number of data points ",NP));
00323 }
00324
00325
00326 inFile.get_regions(NR, NBT, INT);
00327
00328
00329 one_d_table new_link;
00330
00331
00332 insert(end(), new_link);
00333 mf4_table::iterator this_link = end();
00334 --this_link;
00335
00336
00337 this_link->E_in() = E_1 * ENDL.eV2MeV;
00338
00339
00340 for( int iNP=0; iNP < NP; iNP++ )
00341 {
00342 int iP=iNP % 3;
00343 if ( iP == 0 ) getline( inFile, linebuff);
00344 for( int i=0+iP*22; i<22+iP*22; i=i+22 )
00345 strbuff = linebuff.substr(iP*22, 22);
00346 double X,Y;
00347 read_dd(&strbuff, &X, &Y );
00348 if ( X==-999. || Y==-999. )
00349 {
00350 SevereError("mf4_table::one_E_in","read_PAIR fucked up!");
00351 }
00352 else
00353 {
00354 dd_link XYdata(X, Y);
00355 this_link->insert(this_link->end(), XYdata);
00356 }
00357 }
00358
00359 }
00360
00361
00362
00363 void mixed_mf4::master( mf4_file& inFile )
00364
00365 {
00366 int NE;
00367 int NR;
00368
00369
00370 inFile.read_line3( &NR, &NE );
00371 inFile.get_regions( NR, NBT, INT );
00372
00373
00374 expand_data( inFile, NE, ENDL.F );
00375
00376
00377 inFile.read_line3( &NR, &NE );
00378 inFile.get_regions(NR, table_data.NBT, table_data.INT);
00379
00380 table_data.read_data( inFile, NE );
00381
00382
00383 mixed_mf4::iterator last_Legendre = end( );
00384 --last_Legendre;
00385 double last_L_Ein = last_Legendre->E_in( );
00386
00387 mf4_table::iterator first_table = table_data.begin( );
00388 double first_T_Ein = first_table->E_in( );
00389
00390
00391 double local_eps = ENDL_EPSILON( last_L_Ein );
00392
00393 if( first_T_Ein < last_L_Ein + local_eps )
00394 {
00395
00396 mixed_mf4::iterator prev_link = last_Legendre;
00397 --prev_link;
00398 if( prev_link->E_in( ) <= last_L_Ein - 2*local_eps )
00399 {
00400 last_Legendre->E_in( ) -= local_eps;
00401 }
00402 else
00403 {
00404
00405 erase( last_Legendre );
00406 }
00407
00408
00409 mf4_table::iterator next_link = first_table;
00410 ++next_link;
00411 if( next_link->E_in( ) >= first_T_Ein + 2*local_eps )
00412 {
00413 first_table->E_in( ) += local_eps;
00414 }
00415 else
00416 {
00417
00418 table_data.erase( first_table );
00419 }
00420 }
00421
00422 unique();
00423 widen_jumps();
00424 table_data.widen_jumps();
00425
00426
00427
00428 table_data.renorm();
00429
00430 if ( ENDL.write_file )
00431 {
00432 fstream endl_file;
00433
00434 set_up_endl( 1, endl_file );
00435
00436
00437 out_data( 1, endl_file, 0.0 );
00438
00439
00440 table_data.out_data( 1, endl_file, 0.0 );
00441
00442
00443 close_file( endl_file );
00444
00445
00446 if ( ( ENDL.T == 2 ) && ( ENDL.res_za <= 2004 ) )
00447 {
00448 Unimplemented("mixed_mf4::master", " mixed_mf4 data for light targets");
00449 }
00450 }
00451 }
00452
00453
00454
00455 void gen_mf4::master( mf6_file& inFile )
00456
00457 {
00458 int NR;
00459 int NE;
00460 inFile.mf4_line1(&NR, &NE);
00461 inFile.get_regions(NR, NBT, INT);
00462 if ( (NR > 1) || (INT[0] != 2) )
00463 {
00464 Unimplemented("gen_mf4::master",
00465 "Implement interpolation between incident energies for gen_mf4");
00466 }
00467
00468
00469 int LANG;
00470 int NW;
00471 int NL;
00472 double e_in;
00473 for ( int count = 0; count < NE; ++count)
00474 {
00475 inFile.mf4_line2(&e_in, &LANG, &NW, &NL);
00476 if ( LANG == 0 )
00477 {
00478
00479 one_legendre( inFile, e_in, NL );
00480 }
00481 else if ( LANG == 12 )
00482 {
00483
00484 one_table( inFile, e_in, NL );
00485 }
00486 else if ( LANG == 14 )
00487 {
00488
00489 one_table( inFile, e_in, NL );
00490
00491
00492 gen_mf4::iterator this_link = end();
00493 --this_link;
00494 this_link->NBT.push_back( NL );
00495 this_link->INT.push_back( 4 );
00496 this_link->expand_interp( ENDL.Max_E_out );
00497 }
00498 else
00499 {
00500 Unimplemented("gen_mf4::master",pastenum(" Implement LANG = ",LANG));
00501 }
00502 }
00503 write_endl(1);
00504 }
00505
00506 void gen_mf4::one_legendre( mf6_file& inFile, double e_in, int NL )
00507
00508 {
00509
00510 one_d_Legendre Legendre;
00511
00512
00513 string linebuff;
00514 string strbuff;
00515 Legendre.coef.get_space( NL + 1 );
00516 Legendre.coef.at( 0 ) = 1.0;
00517 for ( int iNR=0; iNR < NL; ++iNR )
00518 {
00519 double next_coef;
00520 int iR = iNR % 6;
00521 if ( iR == 0 ) getline( inFile, linebuff);
00522 strbuff = linebuff.substr(iR*11, 11);
00523 read_d( &strbuff, &next_coef );
00524 Legendre.coef.at( iNR + 1 ) = next_coef;
00525 }
00526
00527 Legendre.expand();
00528
00529
00530
00531 one_d_table new_link;
00532
00533
00534 insert(end(), new_link);
00535 gen_mf4::iterator this_link = end();
00536 --this_link;
00537
00538
00539 this_link->E_in() = e_in * ENDL.eV2MeV;
00540
00541
00542 dd_link XYdata;
00543 for( one_d_Legendre::iterator from_link = Legendre.begin();
00544 from_link != Legendre.end(); ++from_link )
00545 {
00546 XYdata.x = from_link->x;
00547 XYdata.y = from_link->y;
00548 this_link->insert(this_link->end(), XYdata);
00549 }
00550 }
00551
00552 void gen_mf4::one_table( mf6_file& inFile, double e_in, int NL )
00553
00554 {
00555
00556 one_d_table new_link;
00557
00558
00559 insert(end(), new_link);
00560 gen_mf4::iterator this_link = end();
00561 --this_link;
00562
00563
00564 this_link->E_in() = e_in * ENDL.eV2MeV;
00565
00566
00567 string linebuff;
00568 string strbuff;
00569 dd_link XYdata;
00570 for( int count = 0; count < NL; ++count )
00571 {
00572 int iP=count % 3;
00573 if ( iP == 0 ) getline( inFile, linebuff);
00574 strbuff = linebuff.substr(iP*22, 22);
00575 read_dd(&strbuff, &XYdata.x, &XYdata.y);
00576 this_link->insert(this_link->end(), XYdata);
00577 }
00578 }