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

mf13classes.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: 1881 $
00029  * $Date: 2006-05-24 13:27:07 -0700 (Wed, 24 May 2006) $
00030  * $Author: dbrown $
00031  * $Id: mf13classes.cpp 1881 2006-05-24 20:27:07Z dbrown $
00032  * 
00033  * ******** fete: From ENDF To ENDL *********
00034  */
00035 
00036 // implementation of the classes for translating the MF=13 data
00037 #include "mf13classes.hpp"
00038 #include "endl_formats.hpp"
00039 #include "mf4classes.hpp"
00040 #include "mf15classes.hpp"
00041 #include "global_params.hpp"
00042 #include "mf14classes.hpp"
00043 
00044 extern ENDLClass ENDL;
00045 extern GlobalParameterClass Global;
00046 
00047 // ********* for class MF13_list *************
00048 // ----------- MF13_list::master -----------------
00049 void MF13_list::master( int NK, mf13_file& inFile )
00050 // handle an mf13 file
00051 {
00052   int NR,NP;
00053 
00054   if(NK > 1)
00055   {
00056     // the first block is the total production of discrete gammas.
00057     // Skip over it
00058     inFile.read_line2(&NR, // number of interpolation regions
00059       &NP);            // number of data points
00060 
00061     multiplicity total;
00062     // read the interpolation information
00063     inFile.get_regions(NR, total.NBT, total.INT);
00064 
00065     //The first data is the total multiplicity
00066     total.read_data( NP, inFile);
00067   }
00068   // get the energy distributions
00069   read_data( NK, inFile );
00070 }
00071 // ----------- MF13_list::read_data -----------------
00072 void MF13_list::read_data( int NK, mf13_file& inFile )
00073 // This routine is used to read in ENDF/B-VI probabilities
00074 // for discrete gamma production.
00075 // NK is the number of data blocks (discrete gammas + continuum)
00076 {
00077   double EG;  // gamma energy
00078   double ES;  // nucleus excitation level
00079   int LP;   // 2 for primary photons; 1 for nonprimaries;
00080             // 0 for we don't know.  We do not use this number
00081   int LF;   // 2 for discrete; 1 for continuum (MF15)
00082   int NR;   // number of words in the record (3*NA)
00083   int NP;   // number of incident energies
00084 
00085   with_discrete = false;  // the default is no discrete gammas
00086 
00087   for(int count = 0; count < NK; ++count)
00088   {
00089     // go through all of the incident energies for each gamma
00090     inFile.gamma_line1(&EG,     //  gamma energy
00091               &ES,     //  excitation level
00092           &LP,     // is this a primary gamma?
00093           &LF,     // discrete-continuum flag
00094           &NR,     // number of interpolation regions
00095           &NP);    // number of (E, gamma production) pairs
00096 
00097     if( LF == 1 )
00098     {
00099       continuum(NR, NP, inFile);
00100       break; // we should be done
00101     }
00102     // change to MeV
00103     EG *= ENDL.eV2MeV;
00104 
00105     // start a new two_d_link for this incident energy
00106     multiplicity new_link;
00107     new_link.E_gamma( ) = EG;
00108     // put it at the beginning---the gamma energies are decreasing
00109     insert( begin( ), new_link );
00110 
00111     // read the data for this gamma
00112     two_d_iterator e_gam_link = begin( );
00113     // read in the interpolation regions
00114     inFile.get_regions( NR, e_gam_link->NBT, e_gam_link->INT );
00115     e_gam_link->read_data( NP, inFile);
00116   }
00117   if( (NK > 1) || (LF == 2))
00118   {
00119     with_discrete = true;
00120     if( ENDL.F == 12 )
00121     {
00122       for(two_d_iterator link = begin(); link != end(); 
00123       ++link)
00124       {
00125         link->scale_by_xs( );
00126       }
00127     }
00128 
00129     // test for the presence of an mf14 file
00130     mf14_file angle_file;
00131     angle_file.open( 14, ENDL.T );
00132     if( angle_file )
00133     {
00134       int ZA;
00135       double AWR;
00136       int LI, LTT;
00137       int NK,NI;
00138       MF14_c55_list angles;
00139       angle_file.first_line(&ZA,   // target Z & A 
00140           &AWR,            // target mass
00141           &LI,             // isotropy flag
00142           &LTT,            // Legendre flag
00143           &NK,             // number of discreet photons (inc continuum)
00144           &NI);            // number of isotropic photon dists
00145 
00146       if ( LI == 1 )  //all photons isotropic
00147       {
00148         isotropic();   // make isotropic distributions
00149       }
00150       else if ( LI == 0 ) // anisotropic distribution
00151       {
00152     // handle the angular distributions
00153         angles.master( angle_file, LTT, NK, NI );
00154       }
00155       else
00156       {
00157         SevereError("MF13_list::read_data",
00158             pastenum("Horrible problem! LI = ",LI)+" not known MF=14!");
00159       }
00160     }
00161     else
00162     {
00163       isotropic();   // make isotropic distributions
00164     }
00165   }
00166 }
00167 // ----------- MF13_list::write_endl -----------------
00168 void MF13_list::write_endl()
00169 // write a c = 55, i = 0, s = 3 ENDL file
00170 {
00171   ENDL.set_c_number(55);
00172   ENDL.set_s_number(3);
00173   ENDL.set_yo(0);
00174   ENDL.set_I_number(0);
00175 
00176   fstream endl_file;
00177   string file_name = ENDL.file_name;
00178 
00179   if ( ENDL.new_file() )
00180   {
00181     endl_file.open(file_name.c_str(),ios::out);
00182     Info("MF13_list::write_endl","Opening ENDL file "+file_name);
00183   }
00184   else
00185   {
00186     endl_file.open(file_name.c_str(),ios::out|ios::app);
00187     Info("MF13_list::write_endl","Appending ENDL file "+file_name);
00188   }
00189 
00190   //Now loop over the data and write it out
00191   for(two_d_iterator link = begin(); link != end(); 
00192       ++link)
00193   {
00194     if( ENDL.F == 12 )
00195     {
00196       link->scale_by_xs( );
00197     }
00198     ENDL.set_x1(link->E_gamma());
00199     // rebuild the header
00200     ENDL.set_I_number(0);
00201     // Print the header info
00202     endl_file << ENDL.header_line_1 << endl;
00203     endl_file << ENDL.header_line_2 << endl;
00204     endl_file.setf(ios::scientific,ios::floatfield);
00205 
00206     for(dd_list::iterator prob_link = link->begin();
00207         prob_link != link->end(); ++prob_link)
00208     {
00209       endl_file << ENDL.data(prob_link->x, prob_link->y) << endl;
00210     } 
00211     //Put on end of file/section line into output file
00212     endl_file << ENDL.eof_line << endl;
00213   }
00214   
00215   // Finally, we close the output file
00216     Info("MF13_list::write_endl","Closing ENDL file "+file_name);
00217   endl_file.close();
00218 }
00219 
00220 // ----------- MF13_list::isotropic -----------------
00221 void MF13_list::isotropic()
00222 // write a c = 55, i = 1, s = 3 ENDL file
00223 {
00224   ENDL.set_c_number(55);
00225   ENDL.set_s_number(3);
00226   ENDL.set_yo(7);
00227 
00228   ENDL.set_I_number(1);
00229 
00230   fstream endl_file;
00231   string file_name = ENDL.file_name;
00232   if ( ENDL.new_file() )
00233   {
00234     endl_file.open(file_name.c_str(),ios::out);
00235     Info("MF13_list::isotropic","Opening ENDL file "+file_name);
00236   }
00237   else
00238   {
00239     endl_file.open(file_name.c_str(),ios::out|ios::app);
00240     Info("MF13_list::isotropic","Appending ENDL file "+file_name);
00241   }
00242 
00243   // make an isotropic distribution
00244   two_d_isotropic angles;
00245   angles.expand_data(0);
00246   two_d_isotropic::iterator first_E_in = angles.begin();
00247 
00248   //Now loop over the gamma production data and get the thresholds
00249   for(two_d_iterator link = begin(); link != end(); 
00250       ++link)
00251   {
00252     // reset the header lines
00253     ENDL.set_x1(link->E_gamma());
00254     ENDL.set_I_number(1);
00255 
00256     first_E_in->E_in() = link->begin()->x;
00257 
00258     //Shove the header info in
00259     endl_file << ENDL.header_line_1 << endl;
00260     endl_file << ENDL.header_line_2 << endl;
00261     endl_file.setf(ios::scientific,ios::floatfield);
00262 
00263     // print the distribution
00264     angles.out_data( 1, endl_file, 0.0 );
00265 
00266     //Put on end of file/section line into output file
00267     endl_file << ENDL.eof_line << endl;
00268   }
00269   //Finally, we close the output file
00270     Info("MF13_list::isotropic","Closing ENDL file "+file_name);
00271   endl_file.close();
00272 }
00273 // ----------- MF13_list::continuum -----------------
00274 void MF13_list::continuum( int NR, int NP, mf13_file& inFile )
00275 // handle gamma production and energy distributions for the continuum
00276 {
00277   // read the interpolation regions
00278   inFile.get_regions(NR, cont_multiple.NBT, cont_multiple.INT);
00279   //The first data is the total multiplicity
00280   cont_multiple.read_data( NP, inFile);
00281 
00282   mf15_file mf15File;   //Instantiate the input file
00283   mf15File.open(15, ENDL.T);
00284 
00285   cont_data.read_data( mf15File );
00286   Info("MF13_list::continuum","Closing file "+endf_file_name(15,ENDL.T)+"...");
00287   mf15File.close();
00288 }
00289 // ----------- MF13_list::write_continuum -----------------
00290 void MF13_list::write_continuum( )
00291 // Writes C55 data for the continuum
00292 {
00293   ENDL.set_c_number( 55 );
00294   ENDL.set_s_number( 0 );  // for continuum
00295   ENDL.set_yo( 0 );
00296   ENDL.set_x0( 0.0 );  // ENDL convention for Q of c55 gammas
00297 
00298   cont_multiple.widen_jumps( );
00299   cont_multiple.write_endl( 0 );
00300 }
00301 
00302 // ***************** class C55_gammas *******************
00303 // --------------- C55_gammas::write_endl -------------
00304 void C55_gammas::write_endl( )
00305 // Writes the c55 files
00306 {
00307   // Reset the header information, overwrite the previous reaction
00308   ENDL.write_file = true;
00309   ENDL.set_x0( 0.0 );  // the Q value
00310   ENDL.T = 3;  // This is mt=3 plus mt=4 data
00311   ENDL.set_c_number(55);
00312 
00313   //The addition operators for different lists do not know how to
00314   //handle empty lists.  So, we insure non-empty lists before we add
00315 
00316   // --- for the continuum energy distributions ---
00317   ENDL.set_s_number(0);  // for gamma continuum
00318   ENDL.set_yo(7);
00319 
00320   if( !MT3_gammas.cont_data.empty( ) && !MT4_gammas.cont_data.empty( ) )
00321   {
00322     Info("C55_gammas::write_endl","we have distributions from both MT3 & MT4");
00323     // record the types of interpolation between 1-d lists
00324     MT3_gammas.cont_data.set_interp( );
00325     MT4_gammas.cont_data.set_interp( );
00326     set_weights( );  // weight according to photon production
00327 
00328     // for sum_lists, make the incident neutron energies agree
00329     list< double > E_incident;
00330     MT3_gammas.cont_data.collect_Ein( E_incident );
00331     MT4_gammas.cont_data.collect_Ein( E_incident );
00332     E_incident.sort( );
00333     E_incident.unique( );
00334     MT3_gammas.cont_data.fill_in_list( E_incident );
00335     MT4_gammas.cont_data.fill_in_list( E_incident );
00336     MT3_gammas.cont_data.use_weight( );  // scale by the weight
00337 
00338     sum_lists( MT3_gammas.cont_data, MT4_gammas.cont_data );
00339 
00340     MT3_gammas.cont_data.widen_jumps( );
00341     MT3_gammas.cont_data.renorm( );
00342     MT3_gammas.cont_data.write_endl( 4 );
00343   }
00344   else if ( !MT3_gammas.cont_data.empty( ) && MT4_gammas.cont_data.empty( ) )
00345   {
00346     Info("C55_gammas::write_endl","We have continuum from MT3");
00347     MT3_gammas.cont_data.widen_jumps( );
00348     MT3_gammas.cont_data.write_endl( 4 );
00349   }
00350   else if ( MT3_gammas.cont_data.empty( ) && !MT4_gammas.cont_data.empty( ) )
00351   {
00352     Info("C55_gammas::write_endl","We have continuum from MT4");
00353     MT4_gammas.cont_data.widen_jumps( );
00354     MT4_gammas.cont_data.write_endl( 4 );
00355   }
00356   else
00357   {
00358     Info("C55_gammas::write_endl","No continuum energy distributions.");
00359   }
00360 
00361   // --- for the continuum photon production cross sections ---
00362   ENDL.set_yo( 0 );
00363   ENDL.set_I_number( 0 );  // recompose the header
00364   if( !MT3_gammas.cont_multiple.empty( ) && !MT4_gammas.cont_multiple.empty( ) )
00365   {
00366     Info("C55_gammas::write_endl","We have continuum from both MT3 & MT4");
00367     MT3_gammas.cont_multiple += MT4_gammas.cont_multiple;
00368     MT3_gammas.write_continuum( );
00369   }
00370   else if ( !MT3_gammas.cont_multiple.empty( ) && MT4_gammas.cont_multiple.empty( ) )
00371   {
00372     Info("C55_gammas::write_endl","We have continuum from MT3");
00373     MT3_gammas.write_continuum( );
00374   }
00375   else if ( MT3_gammas.cont_multiple.empty( ) && !MT4_gammas.cont_multiple.empty( ) )
00376   {
00377     Info("C55_gammas::write_endl","We have continuum from MT4");
00378     MT4_gammas.write_continuum( );
00379   }
00380   else
00381   {
00382     Info("C55_gammas::write_endl","Has no continuum.");
00383   }
00384 
00385 
00386   // ---for the discrete lines---
00387   if( MT3_gammas.with_discrete && MT4_gammas.with_discrete )
00388   {
00389     Info("C55_gammas::write_endl","we have discrete from both MT3 & MT4");
00390     list< double > E_incident;
00391     MT3_gammas.collect_Ein( E_incident );
00392     MT4_gammas.collect_Ein( E_incident );
00393     E_incident.sort( );
00394     E_incident.unique( );
00395     MT3_gammas.fill_in_list( E_incident );
00396     MT4_gammas.fill_in_list( E_incident );
00397 
00398     MT3_gammas.use_weight( ); // scale by the weight
00399     sum_lists( MT3_gammas, MT4_gammas );  // weight MT4 and add
00400     MT3_gammas.write_endl( );
00401   }
00402   else if( MT3_gammas.with_discrete && !MT4_gammas.with_discrete )
00403   {
00404     Info("C55_gammas::write_endl","we have discrete from MT3");
00405     MT3_gammas.write_endl( );
00406   }
00407   else if(  !MT3_gammas.with_discrete && MT4_gammas.with_discrete )
00408   {
00409     Info("C55_gammas::write_endl","we have discrete from MT4");
00410     MT4_gammas.write_endl( );
00411   }
00412   else
00413   {
00414     Info("C55_gammas::write_endl","no discrete lines");
00415   }
00416 }
00417 // --------------- C55_gammas::set_weights -------------
00418 void C55_gammas::set_weights( )
00419 // Sets the weights of the energy distributions according to
00420 // the photon production cross section.
00421 {
00422   MF15_list::iterator cont_ptr;
00423   double e_in;
00424 
00425   // set the weights for the MT3 data
00426   for( cont_ptr = MT3_gammas.cont_data.begin( );
00427        cont_ptr != MT3_gammas.cont_data.end( ); ++cont_ptr )
00428   {
00429     e_in = cont_ptr->E_in( );
00430     cont_ptr->weight = MT3_gammas.cont_multiple.evaluate( e_in );
00431   }
00432 
00433   // set the weights for the MT4 data
00434   for( cont_ptr = MT4_gammas.cont_data.begin( );
00435        cont_ptr != MT4_gammas.cont_data.end( ); ++cont_ptr )
00436   {
00437     e_in = cont_ptr->E_in( );
00438     cont_ptr->weight = MT4_gammas.cont_multiple.evaluate( e_in );
00439   }
00440 }

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