Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

mf14table.cpp

Go to the documentation of this file.
00001 /*
00002  * ******** fete: From ENDF To ENDL *********
00003  * 
00004  * Copyright (c) 2006, The Regents of the University of California. 
00005  * All rights reserved.
00006  * 
00007  * Produced at the Lawrence Livermore National Laboratory. 
00008  * Written by David A. Brown, Gerry Hedstrom, Tony Hill
00009  * 
00010  * This file is part of fete v1.0  (UCRL-CODE-218718)
00011  * 
00012  * Please read the COPYING file for "Our Notice and GNU General 
00013  * Public License" in the root of this software distribution.  
00014  * 
00015  * This program is free software; you can redistribute it and/or modify 
00016  * it under the terms of the GNU General Public License (as published by 
00017  * the Free Software Foundation) version 2, dated June 1991. 
00018  * 
00019  * This program is distributed in the hope that it will be useful, 
00020  * but WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF 
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 
00022  * and conditions of the GNU General Public License for more details. 
00023  * 
00024  * You should have received a copy of the GNU General Public License along 
00025  * with this program; if not, write to the Free Software Foundation, Inc., 
00026  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
00027  * 
00028  * $Revision: 1748 $
00029  * $Date: 2006-03-14 12:18:15 -0800 (Tue, 14 Mar 2006) $
00030  * $Author: dbrown $
00031  * $Id: mf14table.cpp 1748 2006-03-14 20:18:15Z dbrown $
00032  * 
00033  * ******** fete: From ENDF To ENDL *********
00034  */
00035 
00036 // implementation of the classes for translating the MF=14 tabular data
00037 
00038 #include <vector>
00039 
00040 #include "endl_formats.hpp"
00041 #include "messaging.hpp"
00042 #include "mf14table.hpp"
00043 
00044 extern ENDLClass ENDL;
00045 
00046 // ********* for class MF14_table_raw *************
00047 // ----------- MF14_table_raw::read_data ----------------
00048 void MF14_table_raw::read_data( mf14_file& angle_file, int num_gamma )
00049 {
00050   int NR;  // number of interpolation regions
00051   int NE;  // number of incident energies
00052   double EG;  // energy of the gamma
00053 
00054   mf4_table new_table;  // table to insert into the list
00055   MF14_table_raw::iterator this_data;
00056 
00057   // read the data for the lines
00058   for( int count = 0; count < num_gamma; ++count )
00059   {
00060     // get the gamma energy
00061     angle_file.read_EG( &EG, &NR, &NE );
00062 
00063     // prepend the next table and point to it
00064     insert( begin( ), new_table );
00065     this_data = begin( );
00066 
00067     // the gamma energy in MeV
00068     this_data->E_gamma( ) = EG * ENDL.eV2MeV;
00069 
00070     // read the interpolation regions
00071     angle_file.get_regions( NR, this_data->NBT, this_data->INT );
00072 
00073     // read the data for this line
00074     this_data->read_data( angle_file, NE );
00075 
00076     // set the interpolation rules between E_in values
00077     this_data->set_interp( );
00078   }
00079 }
00080 // ----------- MF14_table_raw::fill_E_in ----------------
00081 void MF14_table_raw::fill_E_in( )
00082 // There must be common E_in values
00083 {
00084   list< double > E_in_list;
00085   list< double >::iterator E_in_ptr;
00086   MF14_table_raw::iterator this_gamma;
00087   mf4_table::iterator this_E;
00088   double E_in;
00089 
00090   // Make the list of all E_in values
00091   for( this_gamma = begin( ); this_gamma != end( ); ++this_gamma )
00092   {
00093     // scan the E_in values for this gamma
00094     for( this_E = this_gamma->begin( ); this_E != this_gamma->end( );
00095      ++this_E )
00096     {
00097       E_in = this_E->E_in( );
00098       E_in_list.push_back( E_in );
00099     }
00100   }
00101   // sort the list
00102   E_in_list.sort( );
00103 
00104   // remove duplicates
00105   E_in_list.unique( );
00106 
00107   // For each gamma make common E_in values
00108   for( this_gamma = begin( ); this_gamma != end( ); ++this_gamma )
00109   {
00110     one_d_table new_table;    //  for new entries
00111     mf4_table::iterator new_table_ptr;
00112     mf4_table::iterator prev_E;
00113 
00114     // initial E_in value for this gamma
00115     this_E = this_gamma->begin( );
00116     E_in = this_E->E_in( );
00117 
00118     // Are there E_in_list values less than E_in?
00119     E_in_ptr = E_in_list.begin( );
00120     for( ; *E_in_ptr < E_in; ++E_in_ptr )
00121     {
00122       //      cout << "E_gamma: " << this_gamma->E_gamma( ) <<
00123       //    " prepend: " << *E_in_ptr << endl;
00124 
00125       if( E_in_ptr == E_in_list.end( ) )
00126       {
00127         SevereError( "MF14_table_raw::fill_E_in",
00128              " passed the end of E_in_list" );
00129       }
00130       // insert a copy
00131       this_gamma->insert( this_E, new_table );
00132       new_table_ptr = this_E;
00133       --new_table_ptr;
00134       new_table_ptr->copy( *this_E );
00135       new_table_ptr->E_in( ) = *E_in_ptr;
00136     }
00137 
00138     // Do the rest of E_in_list
00139     for(  ; E_in_ptr != E_in_list.end( ); ++E_in_ptr )
00140     {
00141       E_in = *E_in_ptr;
00142 
00143       // We could be past the end
00144       if( this_E == this_gamma->end( ) )
00145       {
00146     //        cout << "E_gamma: " << this_gamma->E_gamma( ) <<
00147     //          " append: " << E_in << endl;
00148 
00149         this_gamma->insert( this_E, new_table );
00150         new_table_ptr = this_E;
00151         --new_table_ptr;
00152         new_table_ptr->copy( *prev_E );
00153         new_table_ptr->E_in( ) = E_in;
00154       }
00155       // The energies could match
00156       else if( this_E->E_in( ) == E_in )
00157       {
00158         prev_E = this_E;
00159         ++this_E;
00160       }
00161       else
00162       {
00163     //        cout << "E_gamma: " << this_gamma->E_gamma( ) <<
00164     //          " insert: " << E_in << endl;
00165 
00166         this_gamma->insert( this_E, new_table );
00167         new_table_ptr = this_E;
00168         --new_table_ptr;
00169         new_table_ptr->list_interp( E_in, *prev_E, *this_E );
00170     //        new_table_ptr->print( );
00171       }
00172     }
00173   }
00174 
00175   // for each value of E_in we need common mu values
00176   fill_mu( );
00177 }
00178 // ---------------- MF14_table_raw::fill_mu ----------------
00179 void MF14_table_raw::fill_mu( )
00180 // There must be common mu values for each E_in
00181 {
00182   list< double > mu_list;   // the common mu values for one E_in
00183   double mu;
00184   vector< mf4_table::iterator > E_in_ptrs;  // one E_in pointer for each gamma
00185   MF14_table_raw::iterator this_gamma;
00186   one_d_table::iterator this_mu_p;
00187 
00188   // go through the gammas to set up E_in_ptrs
00189   for( this_gamma = begin( ); this_gamma != end( ); ++this_gamma )
00190   {
00191     mf4_table::iterator E_in_ptr = this_gamma->begin( );
00192     E_in_ptrs.push_back( E_in_ptr );
00193   }
00194   int num_gamma = E_in_ptrs.size( );
00195   int j;
00196 
00197   // go through the incident energies for the first gamma
00198   this_gamma = begin( );
00199   for(  ; E_in_ptrs[ 0 ] != this_gamma->end( ); )
00200   {
00201     // collect the mu values for this E_in
00202     for( j = 0; j < num_gamma; ++j )
00203     {
00204       for( this_mu_p = E_in_ptrs[ j ]->begin( );
00205        this_mu_p != E_in_ptrs[ j ]->end( ); ++this_mu_p )
00206       {
00207         mu = this_mu_p->x;
00208         mu_list.push_back( mu );
00209       }
00210     }
00211     // sort and remove duplicates
00212     mu_list.sort( );
00213     mu_list.unique( );
00214 
00215     //    cout << "E_in: " << E_in_ptrs[ 0 ]->E_in( ) << endl;
00216     //    for( list< double >::iterator mu_list_ptr = mu_list.begin( );
00217     //   mu_list_ptr != mu_list.end( ); ++mu_list_ptr )
00218     //    {
00219     //      cout << *mu_list_ptr << endl;
00220     //    }
00221 
00222     // For each E_in make common mu values
00223     for( j = 0; j < num_gamma; ++j )
00224     {
00225       list< double >::iterator mu_list_ptr = mu_list.begin( );
00226       dd_link new_pair;  //  for new (mu, p) entries
00227       one_d_table::iterator prev_mu_p;
00228 
00229       this_mu_p = E_in_ptrs[ j ]->begin( );
00230       mu = this_mu_p->x;
00231 
00232       // Are there mu_list values less than mu?
00233       mu_list_ptr = mu_list.begin( );
00234       for( ; *mu_list_ptr < mu; ++mu_list_ptr )
00235       {
00236     //        cout << "E_gamma: " << this_gamma->E_gamma( ) <<
00237     //    " E_in: " << E_in_ptrs[ j ]->E_in( ) <<
00238     //          " prepend: " << *mu_list_ptr << endl;
00239 
00240         if( mu_list_ptr == mu_list.end( ) )
00241         {
00242           SevereError( "MF14_table_raw::fill_mu",
00243                        " passed the end of mu_list" );
00244         }
00245         // insert a zero
00246         new_pair.x = *mu_list_ptr;
00247         new_pair.y = 0.0;
00248         E_in_ptrs[ j ]->insert( this_mu_p, new_pair );
00249        }
00250 
00251       // Do the rest of mu_list
00252       for(  ; mu_list_ptr != mu_list.end( ); ++mu_list_ptr )
00253       {
00254         mu = *mu_list_ptr;
00255 
00256         // We could be past the end
00257         if( this_mu_p == E_in_ptrs[ j ]->end( ) )
00258         {
00259       //          cout << "E_gamma: " << this_gamma->E_gamma( ) <<
00260       //              " E_in: " << E_in_ptrs[ j ]->E_in( ) <<
00261       //                  " append: " << mu << endl;
00262 
00263           new_pair.x = *mu_list_ptr;
00264           new_pair.y = 0.0;
00265           E_in_ptrs[ j ]->insert( this_mu_p, new_pair );
00266         }
00267         // The energies could match
00268         else if( this_mu_p->mu( ) == mu )
00269         {
00270           prev_mu_p = this_mu_p;
00271           ++this_mu_p;
00272         }
00273         else
00274         {
00275       //          cout << "E_gamma: " << this_gamma->E_gamma( ) <<
00276       //              " E_in: " << E_in_ptrs[ j ]->E_in( ) <<
00277       //                 " insert: " << mu << endl;
00278 
00279           new_pair.x = *mu_list_ptr;
00280           new_pair.y = E_in_ptrs[ j ]->linlin_interp( new_pair.x,
00281             *prev_mu_p, *this_mu_p );
00282           E_in_ptrs[ j ]->insert( this_mu_p, new_pair );
00283         }
00284       }
00285     }
00286 
00287     // start clean for the next E_in
00288     mu_list.erase( mu_list.begin( ), mu_list.end( ) );
00289 
00290     // increment the E_in pointers
00291     for( j = 0; j < num_gamma; ++j )
00292     {
00293       ++E_in_ptrs[ j ];
00294     }
00295   }
00296 }
00297 
00298 // ********* for class MF14_table *************
00299 // ----------- MF14_table::master ----------------
00300 void MF14_table::master( mf12_file& mult_file, mf14_file& angle_file,
00301   int num_mf12, int num_mf14 )
00302 {
00303   // set up the mf12 input file
00304   line_mult.inFile = &mult_file; 
00305 
00306   // the first block is the total multiplicity
00307   int NR; // number of interpolation regions
00308   int NP; // number of (E, multiplicity) pairs
00309   mult_file.read_line2( &NR, &NP );
00310   mult_file.get_regions( NR, multiple.NBT, multiple.INT );
00311   multiple.read_data( NP, mult_file );
00312 
00313   if( ENDL.F == 13 )  //Need to convert cross section to multiplicity
00314   {
00315     multiple.divide_by_xs( );
00316   }
00317   multiple.write_endl( 9 );
00318 
00319   // read the multiplicities of the gammas
00320   read_mf12( mult_file, num_mf12 );
00321 
00322   // read the mf14 data
00323   endf_mf14.read_data( angle_file, num_mf14 );
00324 
00325   // make sure that there is raw mf14 data for every E_in value
00326   endf_mf14.fill_E_in( );
00327 
00328   // weight the raw mf14 data by their multiplicity
00329   mult_weight( );
00330 
00331   // put the data into ENDL order
00332   ENDL_order( );
00333 
00334   // convert the lines to delta-functions
00335   widen_deltas( );
00336 
00337   // create the ENDL i = 1 angular distributions
00338   make_i1( );
00339 
00340   // print the ENDL data
00341   write_endl( );
00342 }
00343 // ----------- MF14_table::read_mf12 ----------------
00344 void MF14_table::read_mf12( mf12_file& mult_file, int num_mf12 )
00345 // read the multiplicities of the gamma lines
00346 {
00347   for( int count = 0; count < num_mf12; ++count )
00348   {
00349     double EG;     //  gamma energy
00350     double ES;     //  excitation level
00351     int LP;        // energy-dependent gamma?
00352     int LF;        // discrete-continuum flag
00353     int NR;        // number of interpolation regions
00354     int NP;        // number of (E, multiplicity) pairs
00355 
00356     mult_file.gamma_line1( &EG, &ES, &LP, &LF, &NR, &NP );
00357     // check the data
00358     if( ( LF != 2 ) || ( LP == 2 ) )
00359     {
00360       SevereError( "MF14_table::master", " strange mf12 data" );
00361     }
00362     line_mult.one_line( EG * ENDL.eV2MeV, NR, NP );
00363   }
00364 }
00365 // ----------- MF14_table::mult_weight ----------------
00366 void MF14_table::mult_weight( )
00367 // weight the raw mf14 data by their multiplicity
00368 {
00369   // go through the gammas
00370   MF12_raw::iterator this_mult = line_mult.begin( );
00371 
00372   for( MF14_table_raw::iterator this_gamma = endf_mf14.begin( );
00373        this_gamma != endf_mf14.end( ); ++this_gamma, ++this_mult )
00374   {
00375     // do a check
00376     if( ( this_gamma->E_gamma( ) != this_mult->E_gamma( ) ) ||
00377     this_mult == line_mult.end( ) )
00378     {
00379       SevereError( "MF14_table::mult_weight", 
00380            " gamma energy mismatch" );
00381     }
00382 
00383     // iterate over the incident energies
00384     for( mf4_table::iterator this_E = this_gamma->begin( );
00385      this_E != this_gamma->end( ); ++this_E )
00386     {
00387       double mult = this_mult->evaluate( this_E->E_in( ) );
00388       // scale the probabilities
00389       *this_E *= mult;
00390     }
00391   }
00392 }
00393 // ----------- MF14_table::ENDL_order ----------------
00394 void MF14_table::ENDL_order( )
00395 // put the data into ENDL order
00396 {
00397   two_d_ENDL_table ENDL_E_in;         // for inserting into the list
00398   MF14_table::iterator ENDL_E_in_ptr;  //  point to the new data
00399   mf4_table::iterator E_in_ptr;
00400   MF14_table_raw::iterator this_gamma;
00401   one_d_table::iterator this_mu_p;
00402 
00403   // set up the ENDL list structure
00404   // go through the incident energies for the first gamma
00405   this_gamma = endf_mf14.begin( );
00406   for( E_in_ptr = this_gamma->begin( ); E_in_ptr != this_gamma->end( );
00407        ++E_in_ptr )
00408   {
00409     // insert a new 2-d list and point to it
00410     insert( end( ), ENDL_E_in );
00411     ENDL_E_in_ptr = end( );
00412     --ENDL_E_in_ptr;
00413     ENDL_E_in_ptr->E_in( ) = E_in_ptr->E_in( );
00414 
00415     // set up the 1-d lists for each mu
00416     for( this_mu_p = E_in_ptr->begin( ); this_mu_p != E_in_ptr->end( );
00417      ++this_mu_p )
00418     {
00419       one_d_table new_table;
00420       new_table.mu( ) = this_mu_p->x;
00421       ENDL_E_in_ptr->insert( ENDL_E_in_ptr->end( ), new_table );
00422       dd_link new_pair;  //  for new (mu, p) entries
00423     }
00424   }
00425 
00426   // fill in the ENDL list
00427   // go through the gammas
00428   for( this_gamma = endf_mf14.begin( ); this_gamma != endf_mf14.end( );
00429     ++this_gamma )
00430   {
00431     double E_gam = this_gamma->E_gamma( );
00432 
00433     // start with the first ENDL incident energy
00434     ENDL_E_in_ptr = begin( );
00435 
00436     // go through the ENDF incident energies
00437     for( E_in_ptr = this_gamma->begin( ), ENDL_E_in_ptr = begin( );
00438           E_in_ptr != this_gamma->end( ); ++E_in_ptr, ++ENDL_E_in_ptr )
00439     {
00440       dd_link new_pair;  //  for new (E_gamma, p) entries
00441       new_pair.x = E_gam;
00442 
00443       // go through the mu values
00444       two_d_ENDL_table::iterator ENDL_mu = ENDL_E_in_ptr->begin( );
00445       for( this_mu_p = E_in_ptr->begin( ); this_mu_p != E_in_ptr->end( );
00446            ++this_mu_p, ++ENDL_mu )
00447       {
00448         new_pair.y = this_mu_p->y;
00449         ENDL_mu->insert( ENDL_mu->end( ), new_pair );
00450       }
00451     }
00452   }
00453 }
00454 // ----------- MF14_table::widen_deltas ----------------
00455 void MF14_table::widen_deltas( )
00456 // convert the lines to delta-functions
00457 {
00458   for( MF14_table::iterator ENDL_E_in_ptr = begin( );
00459        ENDL_E_in_ptr != end( ); ++ENDL_E_in_ptr )
00460   {
00461     for( two_d_ENDL_table::iterator mu_ptr = ENDL_E_in_ptr->begin( );
00462      mu_ptr != ENDL_E_in_ptr->end( ); ++mu_ptr )
00463     {
00464       mu_ptr->widen_delta( );
00465     }
00466   }
00467 }
00468 // ----------- MF14_table::make_i1 ----------------
00469 void MF14_table::make_i1( )
00470 // create the ENDL i = 1 angular distributions
00471 {
00472   for( MF14_table::iterator ENDL_E_in_ptr = begin( );
00473        ENDL_E_in_ptr != end( ); ++ENDL_E_in_ptr )
00474   {
00475     // add a link to the cosine list
00476     one_d_table new_cos;
00477     cosines.push_back( new_cos );
00478 
00479     // expand this cosine link
00480     two_d_list<one_d_table>::iterator cos_ptr = cosines.end( );
00481     --cos_ptr;
00482     ENDL_E_in_ptr->make_cos_link( ENDL_E_in_ptr->E_in( ), cos_ptr );
00483   }
00484 }

Generated on Thu Sep 7 10:30:09 2006 for fete -- From ENDFB6 To ENDL by doxygen 1.3.4