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 "endl_formats.hpp"
00039 #include "mf4classes.hpp"
00040 #include "mf14classes.hpp"
00041 #include "global_params.hpp"
00042 #include "messaging.hpp"
00043 #include "endl_precision.hpp"
00044
00045 extern ENDLClass ENDL;
00046 extern GlobalParameterClass Global;
00047
00048 using namespace std;
00049
00050
00051
00052 MF14_list::MF14_list( int NI, int NK, int order, mf12_file *InFile,
00053 mf14_file *Angle_File )
00054 {
00055 inFile = InFile;
00056 angle_file = Angle_File;
00057
00058 mf14_NI = NI;
00059 mf14_NK = NK;
00060 num_aniso = NK - NI;
00061 aniso_count = 0;
00062
00063
00064 order_ = order;
00065 coefs_.reserve( order + 1 );
00066 coefs_.resize( order + 1 );
00067 coefs_[0].inFile = inFile;
00068 }
00069
00070 MF14_list::~MF14_list()
00071 {
00072 }
00073
00074 void MF14_list::master( int mf12_nk )
00075
00076
00077
00078
00079 {
00080 int ZA;
00081 int mf14_LI, mf14_LTT;
00082
00083 mf12_NK = mf12_nk;
00084
00085
00086 angle_file->first_line(
00087 &ZA,
00088 &AWR,
00089 &mf14_LI,
00090 &mf14_LTT,
00091 &mf14_NK,
00092 &mf14_NI
00093 );
00094
00095 angle_file->skip_iso( mf14_NI );
00096
00097
00098 contin_file.open( 15, ENDL.T );
00099 with_mf15 = ( contin_file )? true : false;
00100
00101 if(mf14_NK > 1)
00102 {
00103
00104
00105 coefs_[0].read_mult( multiple );
00106
00107
00108 for( int L_count = 0; L_count <= order_; ++L_count )
00109 {
00110 dd_list::iterator mult_ptr = multiple.begin();
00111 for( int count = 0; count < multiple.size();
00112 ++count, ++mult_ptr )
00113 {
00114 one_d_table new_link;
00115 new_link.E_in() = mult_ptr->E_in();
00116 coefs_[ L_count ].insert( coefs_[ L_count ].end(), new_link );
00117 }
00118 }
00119
00120
00121 read_data( );
00122
00123
00124 if( with_mf15 )
00125 {
00126 add_lists( );
00127 }
00128 else
00129 {
00130
00131 widen_delta();
00132 }
00133
00134
00135
00136 strip_zero_multiplicity( );
00137
00138
00139 ENDL.set_yo(7);
00140 write_endl( );
00141
00142
00143 ENDL.set_yo(7);
00144 if ( ENDL.C == 55 )
00145 {
00146 if ( ENDL.T == 12 )
00147 {
00148
00149 multiple.scale_by_xs();
00150 }
00151 ENDL.set_yo(0);
00152 multiple.write_endl(0);
00153 }
00154 else
00155 {
00156 if ( ENDL.T == 13 )
00157 {
00158
00159 multiple.divide_by_xs();
00160 }
00161 multiple.write_endl(9);
00162 }
00163 }
00164 }
00165
00166 void MF14_list::read_data( )
00167
00168
00169 {
00170
00171 angle_file->read_EG( &mf14_EG, &mf14_NR, &mf14_NE );
00172 mf14_EG *= ENDL.eV2MeV;
00173 if( mf14_EG == 0.0 )
00174 {
00175 SevereError("MF14_list::read_data",
00176 "Implement Legendre expansion of the continuum");
00177 }
00178 ++aniso_count;
00179
00180 double EG;
00181 double ES;
00182 int LP;
00183
00184 int LF;
00185 int NR;
00186 int NP;
00187 bool do_shift;
00188 double prev_E_in;
00189
00190
00191 for(int count = 0; count < mf12_NK; ++count)
00192 {
00193
00194 prev_E_in = -1.0;
00195
00196 inFile->gamma_line1(&EG,
00197 &ES,
00198 &LP,
00199 &LF,
00200 &NR,
00201 &NP);
00202
00203
00204 EG *= ENDL.eV2MeV;
00205 if(LP == 2)
00206 {
00207
00208 do_shift = true;
00209 }
00210 else
00211 {
00212 do_shift = false;
00213 }
00214
00215 if(LF == 1)
00216 {
00217
00218 continuum( NR, NP );
00219 }
00220 else
00221 {
00222 one_line( EG, &prev_E_in, NR, NP, do_shift );
00223 }
00224 }
00225
00226
00227 if ( with_mf15 )
00228 {
00229 for( int L_count = 0; L_count <= order_; ++L_count )
00230 {
00231 for( MF12_base::iterator e_in_link = coefs_[ L_count ].begin( );
00232 e_in_link != coefs_[ L_count ].end( ); ++e_in_link )
00233 {
00234 double E_in = e_in_link->E_in( );
00235 double scale_by = multiple.evaluate( E_in );
00236 (*e_in_link) *= 1.0/scale_by;
00237 }
00238 }
00239 }
00240 }
00241
00242 void MF14_list::one_line( double EG, double *prev_E_in, int NR,
00243 int NP, bool do_shift )
00244
00245 {
00246 MF12_base::iterator e_in_link;
00247 dd_link XYdata;
00248 dd_link prev_XY;
00249 one_d_table new_link;
00250 string linebuff;
00251 string strbuff;
00252 double E_in;
00253 double use_E_in;
00254 double how_many;
00255 int L_count;
00256 const double EPS = Global.Value( "mf5_tol" );
00257 double *coef_buff;
00258 double **Coef_ptrs;
00259 bool alloc_coef = false;
00260 bool done = false;
00261 double dE = ENDL_EPSILON( ENDL.Max_E_in );
00262
00263
00264 inFile->get_regions(NR, coefs_[0].NBT, coefs_[0].INT);
00265 if( (NR > 1) || ( (coefs_[0].INT[0] != 1) && (coefs_[0].INT[0] != 2) ) )
00266 {
00267 Unimplemented("MF14_list::one_line","Implement interpolation");
00268 }
00269
00270
00271 if( abs( EG - mf14_EG ) <= EPS * EG )
00272 {
00273
00274 coef_buff = new double[ mf14_NE * ( order_ + 1 ) ];
00275 Coef_ptrs = new double* [ mf14_NE ];
00276 alloc_coef = true;
00277 read_Legendre( coef_buff, Coef_ptrs );
00278 }
00279
00280
00281 for( int iNP=0; iNP < NP; iNP++ )
00282 {
00283 int iP=iNP % 3;
00284 if ( iP == 0 )
00285 {
00286 getline( *inFile, linebuff );
00287 }
00288 strbuff = linebuff.substr( iP*22, 22 );
00289 read_dd( &strbuff, &E_in, &how_many );
00290 if ( E_in==-999.0 || how_many==-999.0 )
00291 {
00292 SevereError( "MF14_list::one_line", "read_dd failed!" );
00293 }
00294 E_in *= ENDL.eV2MeV;
00295
00296
00297 if( done )
00298 {
00299 e_in_link = coefs_[ 0 ].end();
00300 }
00301 else if( E_in <= ENDL.Max_E_in )
00302 {
00303 use_E_in = E_in;
00304 if(mf12_NK > 1)
00305 {
00306
00307 e_in_link = coefs_[ 0 ].find_link( E_in, EG );
00308 }
00309 else
00310 {
00311
00312 new_link.E_in() = E_in;
00313 coefs_[ 0 ].insert(coefs_[ 0 ].end(), new_link);
00314 e_in_link = coefs_[ 0 ].end();
00315 --e_in_link;
00316 }
00317 }
00318 else
00319 {
00320
00321 use_E_in = ENDL.Max_E_in;
00322 if(mf12_NK > 1)
00323 {
00324
00325 e_in_link = coefs_[ 0 ].find_link( use_E_in, EG );
00326 }
00327 }
00328
00329
00330 if( e_in_link != coefs_[ 0 ].end() )
00331 {
00332 if( do_shift )
00333 {
00334 XYdata.x = EG + AWR*E_in/(AWR + 1);
00335 }
00336 else
00337 {
00338 XYdata.x = EG;
00339 }
00340 XYdata.y = how_many;
00341
00342 if( E_in > ENDL.Max_E_in )
00343 {
00344 double E_diff = E_in - prev_XY.x;
00345 if( ( E_diff <= 0.0 ) || ( iNP == 0 ) )
00346 {
00347 SevereError( "MF14_list::one_line", "energies out of order" );
00348 }
00349 XYdata.y = prev_XY.y +
00350 ( ENDL.Max_E_in - prev_XY.x ) *
00351 ( XYdata.y - prev_XY.y ) / dE;
00352 }
00353
00354
00355 if( XYdata.x < ENDL.Max_E_out + dE )
00356 {
00357 insert_pair( XYdata, e_in_link );
00358
00359 if( alloc_coef )
00360 {
00361 insert_Legendre( use_E_in, XYdata, *prev_E_in, Coef_ptrs );
00362 }
00363 else
00364 {
00365 XYdata.y = 0.0;
00366 for( L_count = 1; L_count <= order_; ++L_count )
00367 {
00368 if(mf14_NK > 1)
00369 {
00370
00371 e_in_link = coefs_[ L_count ].find_link( use_E_in, EG );
00372 }
00373 else
00374 {
00375
00376 new_link.E_in() = use_E_in;
00377 coefs_[ L_count ].insert(coefs_[ L_count ].end(), new_link);
00378 e_in_link = coefs_[ L_count ].end();
00379 --e_in_link;
00380 }
00381 insert_pair( XYdata, e_in_link );
00382 }
00383 }
00384 }
00385 }
00386
00387 *prev_E_in = use_E_in;
00388 prev_XY.x = XYdata.x;
00389 prev_XY.y = XYdata.y;
00390
00391
00392 if( E_in > ENDL.Max_E_in - dE )
00393 {
00394 done = true;
00395 }
00396 }
00397
00398
00399 if( alloc_coef )
00400 {
00401 delete [] coef_buff;
00402 delete [] Coef_ptrs;
00403 }
00404 }
00405
00406 void MF14_list::insert_pair( dd_link& XYdata,
00407 MF12_base::iterator e_in_link )
00408
00409 {
00410
00411
00412 one_d_table::iterator next_xy;
00413 if( e_in_link->empty() )
00414 {
00415 next_xy = e_in_link->end();
00416 }
00417 else
00418 {
00419
00420 for( next_xy = e_in_link->begin();
00421 next_xy != e_in_link->end();
00422 ++next_xy )
00423 {
00424 if ( next_xy->x >= XYdata.x )
00425 {
00426 break;
00427 }
00428 }
00429 }
00430 e_in_link->insert( next_xy, XYdata );
00431 }
00432
00433 void MF14_list::read_Legendre( double *coef_buff, double **Coef_ptrs )
00434
00435 {
00436 double e_in;
00437 double *this_ptr = coef_buff;
00438 string linebuff;
00439 string strbuff;
00440 int NL;
00441
00442
00443 angle_file->get_regions( mf14_NR, coefs_[1].NBT, coefs_[1].INT );
00444 if( (mf14_NR > 1) || ( (coefs_[1].INT[0] != 1) && (coefs_[1].INT[0] != 2) ) )
00445 {
00446 SevereError("MF14_list::read_Legendre","Implement interpolation");
00447 }
00448
00449
00450 for( int count = 0; count < mf14_NE; ++count )
00451 {
00452
00453 angle_file->Leg_head( &e_in, &NL );
00454 e_in *= ENDL.eV2MeV;
00455 *this_ptr = e_in;
00456 Coef_ptrs[ count ] = this_ptr;
00457 ++this_ptr;
00458
00459
00460 int iNL;
00461 for( iNL = 0; iNL < NL; ++iNL, ++this_ptr )
00462 {
00463 int iL=iNL % 6;
00464 if ( iL == 0 )
00465 {
00466 getline( *angle_file, linebuff);
00467 }
00468 strbuff = linebuff.substr( iL*11, 11 );
00469 read_d( &strbuff, this_ptr );
00470 }
00471
00472 for( ; iNL < order_; ++iNL, ++this_ptr )
00473 {
00474 *this_ptr = 0.0;
00475 }
00476 }
00477
00478
00479 if( aniso_count < num_aniso )
00480 {
00481
00482 angle_file->read_EG( &mf14_EG, &mf14_NR, &mf14_NE );
00483 mf14_EG *= ENDL.eV2MeV;
00484 if( mf14_EG == 0.0 )
00485 {
00486 Unimplemented("MF14_list::read_Legendre",
00487 "Implement Legendre expansion of the continuum");
00488 }
00489 ++aniso_count;
00490 }
00491 else
00492 {
00493
00494 mf14_EG = -1.0;
00495 }
00496 }
00497
00498 void MF14_list::insert_Legendre( double e_in, dd_link& XYdata,
00499 double prev_E_in, double **Coef_ptrs )
00500
00501
00502
00503 {
00504 MF12_base::iterator e_in_link;
00505 double scale = XYdata.y;
00506 int L_count;
00507 dd_link new_data;
00508 one_d_table new_link;
00509 double *prev_coef_ptr;
00510 double *next_coef_ptr;
00511
00512 new_data.x = XYdata.x;
00513
00514
00515 int j;
00516 for( j = 0; ( ( j < mf14_NE ) && ( *Coef_ptrs[ j ] < e_in ) ); ++j )
00517 {
00518 }
00519 if( j >= mf14_NE )
00520 {
00521 string msg( pastenum("Incident energy ",e_in)+" not found" + pastenum(" for gamma ", XYdata.x) );
00522 SevereError("MF14_list::insert_Legendre",msg);
00523 }
00524
00525
00526 if( j == 0 )
00527 {
00528 next_coef_ptr = Coef_ptrs[ 0 ];
00529 ++next_coef_ptr;
00530 for( L_count = 1; L_count <= order_; ++L_count, ++next_coef_ptr )
00531 {
00532 if(mf14_NK > 1)
00533 {
00534
00535 e_in_link = coefs_[ L_count ].find_link( e_in, mf14_EG );
00536 if ( e_in_link == coefs_[ L_count ].end() )
00537 SevereError("MF14_list::insert_Legendre","Cannot find link");
00538 }
00539 else
00540 {
00541
00542 new_link.E_in() = e_in;
00543 coefs_[ L_count ].insert(coefs_[ L_count ].end(), new_link);
00544 e_in_link = coefs_[ L_count ].end();
00545 --e_in_link;
00546 }
00547 XYdata.y = scale * (*next_coef_ptr);
00548 insert_pair( XYdata, e_in_link );
00549 }
00550 }
00551 else
00552 {
00553 prev_coef_ptr = Coef_ptrs[ j - 1 ];
00554 next_coef_ptr = Coef_ptrs[ j ];
00555 double alpha = ( e_in - *prev_coef_ptr ) /
00556 ( *next_coef_ptr - *prev_coef_ptr );
00557 for( L_count = 1; L_count <= order_; ++L_count )
00558 {
00559 if(mf14_NK > 1)
00560 {
00561
00562 e_in_link = coefs_[ L_count ].find_link( e_in, mf14_EG );
00563 if ( e_in_link == coefs_[ L_count ].end() )
00564 SevereError("MF14_list::insert_Legendre","Cannot find link");
00565 }
00566 else
00567 {
00568
00569 new_link.E_in() = e_in;
00570 coefs_[ L_count ].insert(coefs_[ L_count ].end(), new_link);
00571 e_in_link = coefs_[ L_count ].end();
00572 --e_in_link;
00573 }
00574
00575 ++next_coef_ptr;
00576 ++prev_coef_ptr;
00577 XYdata.y = scale * ( alpha * (*next_coef_ptr) +
00578 ( 1.0 - alpha) * (*prev_coef_ptr) );
00579 insert_pair( XYdata, e_in_link );
00580 }
00581 }
00582 }
00583
00584 void MF14_list::widen_delta( )
00585
00586 {
00587 MF12_base::iterator e_in_link[ order_ + 1 ];
00588 int L_count;
00589
00590
00591 for( L_count = 0; L_count <= order_; ++L_count )
00592 {
00593 e_in_link[ L_count ] = coefs_[ L_count ].begin();
00594 }
00595
00596
00597 dd_list::iterator this_link[ order_ + 1 ];
00598 dd_list::iterator next_link[ order_ + 1 ];
00599 dd_list::iterator prev_link;
00600
00601
00602 bool quit = false;
00603 for( ; !quit; )
00604 {
00605
00606 for( L_count = 0; L_count <= order_; ++L_count )
00607 {
00608 this_link[ L_count ] = e_in_link[ L_count ]->begin();
00609 next_link[ L_count ] = e_in_link[ L_count ]->begin();
00610 ++next_link[ L_count ];
00611 }
00612
00613 for( ; ; )
00614 {
00615 prev_link = this_link[ 0 ];
00616 --prev_link;
00617
00618
00619 double dE_L = (this_link[ 0 ] == e_in_link[ 0 ]->begin()) ?
00620 this_link[ 0 ]->E_out() :
00621 this_link[ 0 ]->E_out() - prev_link->E_out();
00622 double dE_R = (next_link[ 0 ] == e_in_link[ 0 ]->end()) ?
00623 this_link[ 0 ]->E_out() :
00624 next_link[ 0 ]->E_out() - this_link[ 0 ]->E_out();
00625 double dE = (dE_L < dE_R) ? dE_L : dE_R;
00626
00627
00628
00629 dE = ENDL_JUMP_WIDTH( this_link[ 0 ]->E_out() );
00630
00631 dd_link new_link = dd_link(this_link[ 0 ]->E_out() - dE, 0.0);
00632 for( L_count = 0; L_count <= order_; ++L_count )
00633 {
00634
00635 this_link[ L_count ]->y /= dE;
00636
00637
00638 e_in_link[ L_count ]->insert( this_link[ L_count ], new_link );
00639 }
00640 new_link = dd_link(this_link[ 0 ]->E_out() + dE, 0.0);
00641 for( L_count = 0; L_count <= order_; ++L_count )
00642 {
00643 e_in_link[ L_count ]->insert( next_link[ L_count ], new_link );
00644 this_link[ L_count ] = next_link[ L_count ];
00645 ++next_link[ L_count ];
00646 }
00647 if( this_link[ 0 ] == e_in_link[ 0 ]->end() )
00648 {
00649 break;
00650 }
00651 }
00652
00653 for( L_count = 0; L_count <= order_; ++L_count )
00654 {
00655 ++e_in_link[ L_count ];
00656 if( e_in_link[ L_count ] == coefs_[ L_count ].end() )
00657 {
00658 quit = true;
00659 break;
00660 }
00661 }
00662 }
00663 }
00664
00665 void MF14_list::thinit( )
00666
00667 {
00668
00669
00670 MF12_base::iterator e_in_list[ order_ + 1 ];
00671 dd_list::iterator left_link[ order_ + 1 ];
00672 dd_list::iterator mid_link[ order_ + 1 ];
00673 dd_list::iterator right_link[ order_ + 1 ];
00674 dd_list::iterator all_done;
00675 bool thin_ok;
00676 bool do_thin;
00677 bool prev_thin;
00678 const double cut_off = Global.Value("cut_off_1d");
00679 const double tol_1d = Global.Value("tol_1d");
00680 int L_order;
00681
00682
00683 for( L_order = 0; L_order <= order_; ++L_order )
00684 {
00685 e_in_list[ L_order ] = coefs_[ L_order ].begin( );
00686 }
00687
00688
00689 for( ; ; )
00690 {
00691
00692
00693 all_done = e_in_list[ 0 ]->end( );
00694 --all_done;
00695
00696
00697 double noise = 0.0;
00698
00699
00700 for( L_order = 0; L_order <= order_; ++L_order )
00701 {
00702 left_link[ L_order ] = e_in_list[ L_order ]->begin( );
00703 }
00704
00705 for( ; left_link[ 0 ] != all_done; ++left_link[ 0 ])
00706 {
00707
00708 for( L_order = 0; L_order <= order_; ++L_order )
00709 {
00710 mid_link[ L_order ] = left_link[ L_order ];
00711 ++mid_link[ L_order ];
00712 right_link[ L_order ] = mid_link[ L_order ];
00713 ++right_link[ L_order ];
00714 if( ( mid_link[ L_order ] == e_in_list[ L_order ]->end() ) ||
00715 ( right_link[ L_order ] == e_in_list[ L_order ]->end() ) )
00716 {
00717 break;
00718 }
00719 }
00720
00721
00722 prev_thin = false;
00723
00724
00725 for( ; right_link[ 0 ] != e_in_list[ 0 ]->end(); ++right_link[ 0 ] )
00726 {
00727
00728 do_thin = false;
00729
00730
00731 for( L_order = 0; L_order <= order_; ++L_order )
00732 {
00733 mid_link[ L_order ] = left_link[ L_order ];
00734 ++mid_link[ L_order ];
00735 }
00736 for( ; mid_link[ 0 ] != right_link[ 0 ]; ++mid_link[ 0 ] )
00737 {
00738 for( L_order = 0; L_order <= order_; ++L_order )
00739 {
00740 thin_ok = e_in_list[ L_order ]->check_interp(
00741 left_link[ L_order ], mid_link[ L_order ],
00742 right_link[ L_order ], tol_1d, noise );
00743
00744 if(thin_ok)
00745 {
00746
00747 do_thin = true;
00748 }
00749 else
00750 {
00751
00752 do_thin = false;
00753 break;
00754 }
00755 }
00756 if( !do_thin )
00757 {
00758 break;
00759 }
00760 for( L_order = 1; L_order <= order_; ++L_order )
00761 {
00762 ++mid_link[ L_order ];
00763 }
00764 }
00765
00766
00767 if(do_thin)
00768 {
00769 prev_thin = true;
00770
00771 for( L_order = 1; L_order <= order_; ++L_order )
00772 {
00773 ++right_link[ L_order ];
00774 }
00775 }
00776 else
00777 {
00778 break;
00779 }
00780 }
00781
00782
00783 dd_list::iterator left_next;
00784 dd_list::iterator right_prev;
00785
00786 if((prev_thin) && (!do_thin))
00787 {
00788
00789 for( L_order = 0; L_order <= order_; ++L_order )
00790 {
00791 left_next = left_link[ L_order ];
00792 ++left_next;
00793 right_prev = right_link[ L_order ];
00794 --right_prev;
00795 e_in_list[ L_order ]->erase(left_next, right_prev);
00796 }
00797 }
00798 else if( (do_thin) && (right_link[ 0 ] == e_in_list[ 0 ]->end() ) &&
00799 ( mid_link[ 0 ] == all_done) )
00800 {
00801
00802 for( L_order = 0; L_order <= order_; ++L_order )
00803 {
00804 left_next = left_link[ L_order ];
00805 ++left_next;
00806 e_in_list[ L_order ]->erase( left_next, mid_link[ L_order ] );
00807 }
00808 }
00809
00810
00811 for( L_order = 1; L_order <= order_; ++L_order )
00812 {
00813 ++left_link[ L_order ];
00814 }
00815 }
00816
00817 for( L_order = 0; L_order <= order_; ++L_order )
00818 {
00819 ++e_in_list[ L_order ];
00820 if( e_in_list[ L_order ] == coefs_[ L_order ].end( ) )
00821 {
00822 return;
00823 }
00824 }
00825 }
00826 }
00827
00828 void MF14_list::set_norms( )
00829
00830
00831 {
00832
00833 continuum_dist.multiple /= multiple;
00834 double scale_by;
00835
00836
00837 MF12_base::iterator disc_ptr[ order_ + 1 ];
00838 MF15_list::iterator contin_ptr = continuum_dist.begin( );
00839 int L_order;
00840 for( L_order = 0; L_order <= order_; ++L_order )
00841 {
00842 disc_ptr[ L_order ] = coefs_[ L_order ].begin();
00843 }
00844
00845
00846 for( ; contin_ptr != continuum_dist.end( ); ++contin_ptr )
00847 {
00848 double cont_wgt = continuum_dist.multiple.evaluate( contin_ptr->E_in( ) );
00849 if( ( cont_wgt < 0.0 ) || ( cont_wgt > 1.0 ) )
00850 {
00851 SevereError("MF14_list::set_norms",pastenum("Bad weight =",cont_wgt));
00852 }
00853 double norm_now = contin_ptr->get_norm( );
00854 if( norm_now <= 0.0 )
00855 {
00856 Warning("MF14_list::set_norms","Zero norm");
00857 }
00858 else
00859 {
00860 scale_by = cont_wgt / norm_now;
00861 *(contin_ptr) *= scale_by;
00862 }
00863
00864 norm_now = disc_ptr[ 0 ]->get_norm( );
00865 if( norm_now <= 0.0 )
00866 {
00867 disc_ptr[ 0 ]->print();
00868 Warning("MF14_list::set_norms","Zero norm");
00869 }
00870 else
00871 {
00872 scale_by = ( 1.0 - cont_wgt ) / norm_now;
00873 for( int L_order = 0; L_order <= order_; ++L_order )
00874 {
00875 *(disc_ptr[ L_order ]) *= scale_by;
00876 ++disc_ptr[ L_order ];
00877 }
00878 }
00879 }
00880 }
00881
00882
00883 void MF14_list::strip_zero_multiplicity( )
00884 {
00885 multiplicity::iterator multPtr = multiple.begin();
00886 while ( multPtr != multiple.end() )
00887 {
00888 if ( multPtr->y == 0.0 ) {
00889 double bad_Ein = multPtr->x;
00890 Info( "MF14_list::strip_zero_multiplicity", pastenum( "Erasing outgoing energy ", multPtr->x ) + pastenum( " because M(E) = ", multPtr->y ) );
00891 multPtr = multiple.erase( multPtr );
00892 for( int L_count = 0; L_count <= order_; ++L_count )
00893 {
00894 MF12_base::iterator list_ptr = coefs_[ L_count ].begin();
00895 while ( list_ptr != coefs_[ L_count ].end() )
00896 {
00897 if ( abs( bad_Ein - list_ptr->E_in( ) ) < 1e-10 ) list_ptr = coefs_[ L_count ].erase( list_ptr );
00898 else ++list_ptr;
00899 }
00900 }
00901 }
00902 else
00903 {
00904 ++multPtr;
00905 }
00906 }
00907 }
00908
00909
00910 void MF14_list::renorm( )
00911
00912 {
00913 MF12_base::iterator e_in_link[ order_ + 1 ];
00914 int L_count;
00915
00916
00917 for( L_count = 0; L_count <= order_; ++L_count )
00918 {
00919 e_in_link[ L_count ] = coefs_[ L_count ].begin();
00920 }
00921
00922
00923 for( ; ; )
00924 {
00925
00926 double norm = e_in_link[ 0 ]->get_norm( );
00927 if( norm == 0.0 )
00928 {
00929 Warning("MF14_list::renorm",
00930 pastenum("No spectrum for E_in= ",e_in_link[ 0 ]->E_in( )));
00931 }
00932 else
00933 {
00934
00935 for( L_count = 0; L_count <= order_; ++L_count )
00936 {
00937 *e_in_link[ L_count ] *= 1.0/norm;
00938 }
00939 }
00940
00941
00942 for( L_count = 0; L_count <= order_; ++L_count )
00943 {
00944 ++e_in_link[ L_count ];
00945 if( e_in_link[ L_count ] == coefs_[ L_count ].end() )
00946 {
00947 return;
00948 }
00949 }
00950 }
00951 }
00952
00953 void MF14_list::add_lists( )
00954
00955 {
00956
00957 list< double > E_incident;
00958 coefs_[ 0 ].collect_Ein( E_incident );
00959 continuum_dist.collect_Ein( E_incident );
00960 E_incident.sort( );
00961 E_incident.unique( );
00962 continuum_dist.fill_in_list( E_incident );
00963
00964
00965 extra_contin( );
00966
00967
00968 widen_delta( );
00969
00970
00971 set_norms( );
00972
00973
00974 MF12_base::iterator disc_ptr[ order_ + 1 ];
00975 int L_order;
00976 for( L_order = 0; L_order <= order_; ++L_order )
00977 {
00978 disc_ptr[ L_order ] = coefs_[ L_order ].begin();
00979 }
00980 for( MF15_list::iterator contin_ptr = continuum_dist.begin( );
00981 contin_ptr != continuum_dist.end(); ++contin_ptr )
00982 {
00983
00984 fill_in_lists( *contin_ptr, *(disc_ptr[ 0 ]) );
00985 for( L_order = 1; L_order <= order_; ++L_order )
00986 {
00987 fill_in_lists( *(disc_ptr[ 0 ]), *(disc_ptr[ L_order ]) );
00988 }
00989
00990 *disc_ptr[ 0 ] += *contin_ptr;
00991
00992 for( L_order = 0; L_order <= order_; ++L_order )
00993 {
00994 ++disc_ptr[ L_order ];
00995 }
00996 }
00997 check_Legendre( false );
00998 thinit( );
00999 renorm( );
01000 }
01001
01002 void MF14_list::extra_contin( )
01003
01004
01005
01006 {
01007
01008 MF12_base::iterator disc_ptr = coefs_[ 0 ].begin();
01009
01010
01011 MF15_list::iterator contin_ptr = continuum_dist.begin( );
01012 MF15_list::iterator next_contin = contin_ptr;
01013 ++next_contin;
01014
01015 const double EPS = Global.Value( "mf5_tol" );
01016 if( abs( disc_ptr->E_in( ) - contin_ptr->E_in( ) ) >
01017 EPS*contin_ptr->E_in( ) )
01018 {
01019 SevereError("MF14_list::extra_contin",
01020 "mf14 discrete and continuum lists should start together");
01021 }
01022
01023
01024 for( ; disc_ptr != coefs_[ 0 ].end( ); )
01025 {
01026 if( disc_ptr->E_in( ) < ( 1.0 - EPS )*contin_ptr->E_in( ) )
01027 {
01028
01029 SevereError("MF14_list::extra_contin",
01030 "For mf14 first expand the continuum data");
01031 }
01032 else if( disc_ptr->E_in( ) > ( 1.0 + EPS )*contin_ptr->E_in( ) )
01033 {
01034
01035 continuum_dist.erase( contin_ptr );
01036 contin_ptr = next_contin;
01037 ++next_contin;
01038 }
01039 else
01040 {
01041
01042 contin_ptr = next_contin;
01043 ++next_contin;
01044 ++disc_ptr;
01045 }
01046 }
01047 }
01048
01049 void MF14_list::widen_jumps( )
01050
01051 {
01052 Unimplemented("MF14_list::widen_jumps", "Write this code!");
01053 }
01054
01055 void MF14_list::continuum( int NR, int NP )
01056
01057 {
01058 if( !with_mf15 )
01059 {
01060 SevereError("MF14_list::continuum","no mf15 file!");
01061 }
01062
01063
01064 inFile->get_regions( NR, continuum_dist.multiple.NBT,
01065 continuum_dist.multiple.INT );
01066
01067 if( (NR > 1) || (continuum_dist.multiple.INT[0] != 2) )
01068 {
01069 Unimplemented("MF14_list::continuum","Implement interpolation in mf14 continuum");
01070 }
01071 continuum_dist.multiple.read_data( NP, *inFile );
01072
01073
01074 continuum_dist.read_data( contin_file );
01075 continuum_dist.set_interp();
01076 {
01077 Info("MF14_list::continuum","Closing file "+endf_file_name( 15, ENDL.T )+"...");
01078 }
01079 contin_file.close( );
01080 }
01081
01082 void MF14_list::check_Legendre( bool halt_on_error )
01083
01084
01085 {
01086 MF12_base::iterator E_in_ptr[ order_ + 1 ];
01087 int L_order;
01088 bool two_d_done = false;
01089
01090 for( L_order = 0; L_order <= order_; ++L_order )
01091 {
01092 E_in_ptr[ L_order ] = coefs_[ L_order ].begin();
01093 }
01094
01095 for( ; ; )
01096 {
01097
01098 double e_in = E_in_ptr[ 0 ]->E_in( );
01099 for( L_order = 1; L_order <= order_; ++L_order )
01100 {
01101 if( E_in_ptr[ L_order ]->E_in( ) != e_in )
01102 {
01103 string msg("Incompatible E_in\n"+
01104 pastenum(" For order 0, E_in = ",e_in)+
01105 pastenum(" for order ",L_order)+
01106 pastenum(" E_in = ",E_in_ptr[ L_order ]->E_in( )));
01107 if (halt_on_error) SevereError("MF14_list::check_Legendre",msg);
01108 else Warning("MF14_list::check_Legendre",msg);
01109 }
01110 }
01111
01112 bool one_d_done = false;
01113 dd_list::iterator L_ptr[ order_ + 1 ];
01114 for( L_order = 0; L_order <= order_; ++L_order )
01115 {
01116 L_ptr[ L_order ] = E_in_ptr[ L_order ]->begin( );
01117 }
01118
01119 for( ; ; )
01120 {
01121 for( L_order = 1; L_order <= order_; ++L_order )
01122 {
01123 double close_enough = ENDL_EPSILON( L_ptr[ 0 ]->x );
01124 if( abs(L_ptr[ L_order ]->x != L_ptr[ 0 ]->x) > close_enough )
01125 {
01126 string msg(
01127 pastenum("Incompatible gamma energy for E_in: ",e_in)+
01128 pastenum("\n For order 0, E_gamma = ",L_ptr[ 0 ]->x)+
01129 pastenum(" for order ",L_order)+
01130 pastenum(" E_gamma = ",L_ptr[ L_order ]->x));
01131 if (halt_on_error) SevereError("MF14_list::check_Legendre",msg);
01132 else Warning("MF14_list::check_Legendre",msg);
01133 }
01134 }
01135
01136 for( L_order = 0; L_order <= order_; ++L_order )
01137 {
01138 ++L_ptr[ L_order ];
01139 if( L_ptr[ L_order ] == E_in_ptr[ L_order ]->end( ) )
01140 {
01141 one_d_done = true;
01142 }
01143 }
01144 if( one_d_done )
01145 {
01146 break;
01147 }
01148 }
01149
01150 for( L_order = 0; L_order <= order_; ++L_order )
01151 {
01152 if( L_ptr[ L_order ] != E_in_ptr[ L_order ]->end( ) )
01153 {
01154 string msg(
01155 pastenum("For E_in: ",e_in)+
01156 pastenum(" extra link E_gamma: ",L_ptr[ L_order ]->x)+
01157 pastenum(" for order: ",L_order));
01158 if (halt_on_error) SevereError("MF14_list::check_Legendre",msg);
01159 else Warning("MF14_list::check_Legendre",msg);
01160 }
01161 }
01162
01163 for( L_order = 0; L_order <= order_; ++L_order )
01164 {
01165 ++E_in_ptr[ L_order ];
01166 if( E_in_ptr[ L_order ] == coefs_[ L_order ].end( ) )
01167 {
01168 two_d_done = true;
01169 }
01170 }
01171 if( two_d_done )
01172 {
01173 break;
01174 }
01175 }
01176
01177 for( L_order = 0; L_order <= order_; ++L_order )
01178 {
01179 if( E_in_ptr[ L_order ] != coefs_[ L_order ].end( ) )
01180 {
01181 string msg(
01182 pastenum("\n Extra list E_in: ",E_in_ptr[ L_order ]->E_in( ))+
01183 pastenum(" for order: ",L_order));
01184 if (halt_on_error) SevereError("MF14_list::check_Legendre",msg);
01185 else Warning("MF14_list::check_Legendre",msg);
01186 }
01187 }
01188 }
01189
01190 void MF14_list::print( )
01191
01192 {
01193 for( int L_order = 0; L_order <= order_; ++L_order )
01194 {
01195 cout << "Legendre order: " << L_order << endl;
01196 coefs_[ L_order ].print( );
01197 }
01198 }
01199
01200 void MF14_list::write_endl( )
01201
01202 {
01203 ENDL.set_I_number( 4 );
01204
01205 fstream endl_file;
01206 string file_name = ENDL.file_name;
01207
01208 if ( ENDL.new_file() )
01209 {
01210 endl_file.open(file_name.c_str(),ios::out);
01211 Info("MF14_list::write_endl","Opening ENDL file "+file_name);
01212 }
01213 else
01214 {
01215 endl_file.open(file_name.c_str(),ios::out|ios::app);
01216 Info("MF14_list::write_endl","Appending ENDL file "+file_name);
01217 }
01218
01219
01220 endl_file << ENDL.header_line_1 << endl;
01221 endl_file << ENDL.header_line_2 << endl;
01222 endl_file.setf(ios::scientific,ios::floatfield);
01223
01224
01225 for( int L_count = 0; L_count <= order_; ++L_count )
01226 {
01227 coefs_[ L_count ].out_data( 4, endl_file, 1.0*L_count );
01228 }
01229
01230
01231 endl_file << ENDL.eof_line << endl;
01232
01233
01234 Info("MF14_list::write_endl","Closing ENDL file "+file_name);
01235 endl_file.close();
01236 }
01237
01238
01239
01240 void MF14_split::master( double awr, int NK, mf12_file *InFile,
01241 mf14_file *angle_file )
01242
01243 {
01244
01245 movers.AWR = awr;
01246 mf12_NK = NK;
01247
01248 Warning("MF14_split::master", "Printing only the isotropic component");
01249
01250
01251 inFile = InFile;
01252 statics.inFile = InFile;
01253 raw_move.inFile = InFile;
01254 raw_static.inFile = InFile;
01255
01256
01257 with_move = false;
01258 with_static = false;
01259 with_mf15 = false;
01260
01261
01262 read_data( );
01263
01264 if( NK == 1 )
01265 {
01266
01267
01268
01269 if( with_mf15 )
01270 {
01271
01272 Info("MF14_split::master","mf14 continuum only");
01273 write_continuum( );
01274 }
01275 else if( with_static )
01276 {
01277
01278 Info("MF14_split::master","mf14 1 static line");
01279 write_static( );
01280 }
01281 else
01282 {
01283
01284 Info("MF14_split::master","mf14 1 moving line");
01285 write_mover( );
01286 }
01287 }
01288 else
01289 {
01290 if( with_mf15 )
01291 {
01292 if( with_move )
01293 {
01294 Info("MF14_split::master", "mf14 continuum plus moving lines");
01295 move_w_contin( );
01296 }
01297 else
01298 {
01299
01300 Info("MF14_split::master","mf14 static lines plus continuum");
01301 plus_contin( );
01302 }
01303 }
01304 else if( with_move )
01305 {
01306
01307 Info("MF14_split::master","mf14 static lines plus movers");
01308 do_movers( );
01309 }
01310 else
01311 {
01312
01313 Info("MF14_split::master","mf14 static lines only");
01314 just_statics( );
01315 }
01316 }
01317 }
01318
01319
01320 MF14_c55_list::MF14_c55_list()
01321 {
01322 }
01323
01324 MF14_c55_list::~MF14_c55_list()
01325 {
01326 }
01327
01328 void MF14_c55_list::master( mf14_file& inFile, int LTT, int NK, int NI )
01329
01330
01331
01332
01333 {
01334 int num_to_do = NK - NI;
01335 double EG[ num_to_do ];
01336 int count;
01337 int start_at;
01338
01339 ENDL.set_c_number(55);
01340 ENDL.set_yo(7);
01341 ENDL.set_x0(0.0);
01342
01343
01344 for( count = 0; count < NI; ++count )
01345 {
01346 double eg;
01347 inFile.discrete( &eg );
01348 }
01349
01350
01351 if( LTT == 1 )
01352 {
01353 Info("MF14_c55_list::master"," Doing mf14 Legendre for c55");
01354
01355 two_d_Legendre Legendre[ num_to_do ];
01356 for( count = 0; count < num_to_do; ++count )
01357 {
01358 EG[count] = make_Legendre( inFile, Legendre[count] );
01359 }
01360
01361
01362 start_at = num_to_do - 1;
01363 if ( EG[ start_at ] == 0.0 )
01364 {
01365
01366 ENDL.set_x1(0.0);
01367 ENDL.set_s_number(0);
01368 Legendre[ start_at ].write_endl(1);
01369 --start_at;
01370 }
01371
01372 ENDL.set_s_number(3);
01373 for( count = start_at; count >= 0; --count )
01374 {
01375 ENDL.set_x1( EG[ count ] );
01376 Legendre[ count ].write_endl(1);
01377 ENDL.append = true;
01378 }
01379 }
01380 else if( LTT == 2 )
01381 {
01382
01383 mf4_table tables[ num_to_do ];
01384 for( count = 0; count < num_to_do; ++count )
01385 {
01386 EG[count] = make_table( inFile, tables[count] );
01387 }
01388
01389
01390 start_at = num_to_do - 1;
01391 if ( EG[ start_at ] == 0.0 )
01392 {
01393
01394 ENDL.set_x1(0.0);
01395 ENDL.set_s_number(0);
01396 tables[ start_at ].write_endl(1);
01397 --start_at;
01398 }
01399
01400 ENDL.set_s_number(3);
01401 for( count = start_at; count >= 0; --count )
01402 {
01403 ENDL.set_x1( EG[ count ] );
01404 tables[ count ].write_endl(1);
01405 ENDL.append = true;
01406 }
01407 }
01408 else
01409 {
01410 SevereError("MF14_list::master",pastenum("Bad LTT value ",LTT));
01411 }
01412 }
01413
01414 double MF14_c55_list::make_Legendre( mf14_file& inFile,
01415 two_d_Legendre& Legendre )
01416
01417 {
01418 double EG;
01419 int NR;
01420 int NE;
01421
01422 inFile.read_EG( &EG, &NR, &NE );
01423 inFile.get_regions( NR, Legendre.NBT, Legendre.INT );
01424 Legendre.expand_data( inFile, NE, 4 );
01425
01426
01427 return EG * ENDL.eV2MeV;
01428 }
01429
01430
01431 double MF14_c55_list::make_table( mf14_file& inFile,
01432 mf4_table& table )
01433
01434 {
01435 double EG;
01436 int NR;
01437 int NE;
01438
01439 inFile.read_EG( &EG, &NR, &NE );
01440 inFile.get_regions( NR, table.NBT, table.INT );
01441 table.read_data( inFile, NE );
01442
01443
01444 return EG * ENDL.eV2MeV;
01445 }
01446