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

bdfls_tools.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: 1840 $
00029  * $Date: 2006-04-14 16:26:58 -0700 (Fri, 14 Apr 2006) $
00030  * $Author: hedstrom $
00031  * $Id: bdfls_tools.cpp 1840 2006-04-14 23:26:58Z hedstrom $
00032  * 
00033  * ******** fete: From ENDF To ENDL *********
00034  */
00035 
00036 //Implementation of the bdfls class
00037 
00038 #include "bdfls_tools.hpp"     //converting strings to numbers
00039 #include "convert.hpp"         // converting strings to numbers
00040 #include "global_params.hpp"   //global parameters
00041 #include "messaging.hpp"
00042 
00043 extern GlobalParameterClass Global;
00044 
00045 // *********** mass_life_link class ***********************
00046 // ----------- mass_life_link::print ---------------
00047 // print the data in a link
00048 void mass_life_link::print( )
00049 {
00050   cout << za_ << "  " << mass_ << "  " << lifetime_ << endl;
00051 }
00052 
00053 // *********** mass_life_list class ***********************
00054 // ----------- mass_life_list::at ---------------
00055 // Function to get the link at "x"
00056 // Returns "false" if the entry is not found.
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 // ----------- mass_life_list::print ---------------
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 // *********** bdflsClass class ******
00083 // -------------------- bdflsClass constructor ----------------
00084 //default constructor
00085 bdflsClass::bdflsClass()   
00086 {
00087   //The section array holds the names of types of info in the bdfls file
00088   //in the order they are encountered.
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 // -------------------- bdflsClass destructor ----------------
00104 //default destructor
00105 bdflsClass ::~bdflsClass()
00106 { 
00107 }
00108 // -------------------- bdflsClass::read ----------------
00109 //Function to read in the bdfls file
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 // -------------------- bdflsClass::read_sections ----------------
00137 //Function that reads each section of the bdfls file
00138 void bdflsClass::read_sections( )
00139 {
00140   //Reads the entire bdfls file
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 )  //loop through all the sections
00151     {
00152       if ( nsection != lastsection )  //print some info each new section
00153     {
00154       Info("bdflsClass::read_sections","Reading "+section[nsection]+" information...");
00155       lastsection=nsection;
00156     }
00157       
00158     //Do what we gotta do for each section of data
00159     //Decided to use switch statement cuz I have never used them before
00160     switch( nsection )
00161     {  
00162       
00163     case 0:
00164       if ( !EndofSection() )  //Read & test the line for end of section
00165       { //don't care about group data
00166       }
00167       else
00168       { ++nsection;}
00169       break;
00170       
00171     case 1:
00172       if ( !EndofSection() )  //Read & test the line for end of section
00173       { //don't care about flux data
00174       }
00175       else
00176       { ++nsection;}
00177       break;
00178       
00179     case 2:
00180       if ( !EndofSection() )  //Read & test the line for end of section
00181       { //here are the masses
00182         split_line = split(stringbuff);
00183         za = stoi(split_line[0]);
00184         mass = stod(split_line[1]);
00185         
00186         //small_string = stringbuff.substr(0,10);
00187         //za = stoi(small_string);  
00188         //small_string = stringbuff.substr(11,21);
00189         //mass = stod(small_string);
00190         
00191         // have we already got a lifetime for this ZA?
00192         if(life_done && Mass_Life.at(za, XYptr))
00193         {
00194            XYptr->Mass() = mass;
00195         }
00196            else
00197         {
00198           XYdata.ZA() = za;  //Load into link
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() )  //Read & test the line for end of section
00213       { //here are the lifetimes
00214         small_string = stringbuff.substr(0,10);
00215         za = stoi(small_string);
00216         if ( stringbuff.length() < 11 )  // Some have no life info
00217         {
00218           //Load up a long lifetime if there is a mass entry for this isotope
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           // have we already got a mass for this ZA?
00237           if(mass_done && Mass_Life.at(za, XYptr))
00238           {
00239             XYptr->LifeTime() = life;
00240           }
00241           else
00242           {
00243             XYdata.ZA() = za;  //Load into link
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() )  //Read & test the line for end of section
00256       { //here are the nuclear constants
00257         if ( nc_index > 0 ) //First line is nothing
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() )  //Read & test the line for end of section
00270       { //don't care about temperature sets data
00271       }
00272       else
00273       { ++nsection;}
00274       break;
00275       
00276     case 6:
00277       if ( !EndofSection() )  //Read & test the line for end of section
00278       { //don't care about subshell designator data
00279       }
00280       else
00281       { ++nsection;}
00282       break;
00283     }
00284   }
00285 }
00286 
00287 // --------------------  bdflsClass::EndofSection ----------------
00288 //! Function that reads in a line of the bdfls file and determines
00289 //! whether or not the line is the last of a section.
00290 bool bdflsClass::EndofSection( )
00291 {
00292   // Performs two tasks - reads in a line from file and then
00293   // tests to see if it is the end of a section
00294   // Note: line containing end of line marker has no other
00295   // particularly useful information in it (if any other at all)
00296   
00297   getline( bdflsFile, stringbuff ); //read in the line
00298   
00299   if ( stringbuff.length() >= 73 && stringbuff[72]=='1' )  // end of section mark
00300   {
00301     return true;
00302   }
00303   else
00304   {
00305     return false;
00306   }
00307 }
00308 
00309 

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