C program for neutron efficiency: Difference between revisions

From New IAC Wiki
Jump to navigation Jump to search
Oborn (talk | contribs)
No edit summary
 
Oborn (talk | contribs)
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
/**************************************************************************
  #include <iostream>
* Author: Rebecca Bodily
  #include <cmath>
  * Date: 05/02/2008
  using namespace std;
  * Organization: Idaho State University
  *************************************************************************/


#include <iostream>
double crossSectionHydrogenFunction();
#include <cmath>
double numberCarbonFunction(double thickness,
using namespace std;
                            const double CUBICCENTIMETERCARBON);
double numberHydrogenFunction(double thickness,
                              const double CUBICCENTIMETERHYDROGEN);
double crossSectionCarbonFunction();
void efficiencyFunction(double numberHydrogen, double numberCarbon,
                        double crossSectionHydrogen, double crossSectionCarbon,
                        double thickness);


double crossSectionHydrogenFunction();
<code>/************************************************************************
double numberCarbonFunction(double thickness, const double
                            CUBICCENTIMETERCARBON);
double numberHydrogenFunction(double thickness, const double
                              CUBICCENTIMETERHYDROGEN);
double crossSectionCarbonFunction();
void efficiencyFunction(double numberHydrogen, double
                        numberCarbon, double
                        crossSectionHydrogen, double
                        crossSectionCarbon, double thickness);
 
/*************************************************************************
  * This program is to find the
  * This program is to find the
  * efficiency of a neutron detector.
  * efficiency of a neutron detector.
  ************************************************************************/
  ************************************************************************/
double  main()
double  main()
{
{</code>
  double neutronEnergy;
  double neutronEnergy;
  double numberHydrogen;
  double numberHydrogen;
  double numberCarbon;
  double numberCarbon;
  double crossSectionHydrogen;
  double crossSectionHydrogen;
  double crossSectionCarbon;
  double crossSectionCarbon;
  double thickness;
  double thickness;
  const double CUBICCENTIMETERCARBON = 5.23e22;
  const double CUBICCENTIMETERCARBON = 5.23e22;
  const double CUBICCENTIMETERHYDROGEN = 4.74e22;
  const double CUBICCENTIMETERHYDROGEN = 4.74e22;


  cout << endl;
  cout << endl;
  cout << "Enter thickness of detector (in centimeters): ";
  cout << "Enter thickness of detector (in centimeters): ";
  cin >> thickness;
  cin >> thickness;


  crossSectionHydrogen = crossSectionHydrogenFunction();
  crossSectionHydrogen = crossSectionHydrogenFunction();
  numberCarbon = numberCarbonFunction(thickness,
  numberCarbon = numberCarbonFunction(thickness,
                                      CUBICCENTIMETERCARBON);
                                      CUBICCENTIMETERCARBON);
  numberHydrogen = numberHydrogenFunction(thickness,
  numberHydrogen = numberHydrogenFunction(thickness,
                                          CUBICCENTIMETERHYDROGEN);
                                          CUBICCENTIMETERHYDROGEN);
  crossSectionCarbon = crossSectionCarbonFunction();
  crossSectionCarbon = crossSectionCarbonFunction();


  efficiencyFunction(numberHydrogen, numberCarbon,
  efficiencyFunction(numberHydrogen, numberCarbon,
                    crossSectionHydrogen, crossSectionCarbon,
                      crossSectionHydrogen, crossSectionCarbon,
                    thickness);
                      thickness);
}
}


/***********************************************************************
/**********************************************************************
   * Equation for cross section of hydrogen according to
   * Equation for cross section of hydrogen according to
   * equation 15-9 from Radiation Detection and Measurement
   * equation 15-9 from Radiation Detection and Measurement
Line 57: Line 50:
   *********************************************************************/
   *********************************************************************/
   double crossSectionHydrogenFunction()
   double crossSectionHydrogenFunction()
    {
  {
      double neutronEnergy;
    double neutronEnergy;
      double crossSectionHydrogen;
    double crossSectionHydrogen;


      cout << endl;
    cout << endl;
      cout << "Enter neutron energy (in MeV): ";
    cout << "Enter neutron energy (in MeV): ";
      cin >> neutronEnergy;
    cin >> neutronEnergy;


      crossSectionHydrogen = ((4.83 / sqrt(neutronEnergy))
    crossSectionHydrogen = ((4.83e-24 / sqrt(neutronEnergy))
                               - .578e-24);
                               - .578e-24);


      return crossSectionHydrogen;
    return crossSectionHydrogen;
    }
  }


/**********************************************************************
/**********************************************************************
* Equation for calculating the number of Carbons in
  * Equation for calculating the number of Carbons in
* the problem per cubic centimeter, dependent on what
  * the problem per cubic centimeter, dependent on what
* the user put in for the thickness of the detector.
  * the user put in for the thickness of the detector.
*********************************************************************/
  *********************************************************************/
double numberCarbonFunction(double thickness, const
  double numberCarbonFunction(double thickness, const
                            double CUBICCENTIMETERCARBON)
                              double CUBICCENTIMETERCARBON)
{
  {
  double numberCarbon;
    double numberCarbon;


  numberCarbon = thickness * CUBICCENTIMETERCARBON;
    numberCarbon = CUBICCENTIMETERCARBON;
  return numberCarbon;
    return numberCarbon;
}
  }  


/*********************************************************************
/*********************************************************************
* Equation for calculating the number of Hydrogens in
  * Equation for calculating the number of Hydrogens in
* the problem per cubic centimeter, dependent on what
  * the problem per cubic centimeter, dependent on what
  * the user put in for the thickness of the detector.
  * the user put in for the thickness of the detector.
********************************************************************/
  ********************************************************************/
double numberHydrogenFunction(double thickness, const
  double numberHydrogenFunction(double thickness, const
                              double CUBICCENTIMETERHYDROGEN)
                                double CUBICCENTIMETERHYDROGEN)
{
  {
  double numberHydrogen;
    double numberHydrogen;


  numberHydrogen = thickness * CUBICCENTIMETERHYDROGEN;
    numberHydrogen = CUBICCENTIMETERHYDROGEN;
  return numberHydrogen;
    return numberHydrogen;
}
  }


/*********************************************************************
/*********************************************************************
* Requesting the cross section from the Knoll book, and
  * Requesting the cross section from the Knoll book, and
* then calculating it from barns to centimeters.
  * then calculating it from barns to centimeters.
********************************************************************/
  ********************************************************************/
double crossSectionCarbonFunction()
  double crossSectionCarbonFunction()
{
  {
  double crossSectionCarbon;
    double crossSectionCarbon;


  cout << endl;
    cout << endl;
  cout << "Enter the cross section of Carbon by "
    cout << "Enter the cross section of Carbon by "
      << "looking in Radiation" << endl
        << "looking in Radiation" << endl
      << "Detection and Measurement by Glenn Knoll, on"
        << "Detection and Measurement by Glenn Knoll, on"
      << " page 535, " << endl
        << " page 535, " << endl
      << "Figure 15-15b (in square centimeters): ";
        << "Figure 15-15b (in barns): ";
  cin >> crossSectionCarbon;
    cin >> crossSectionCarbon;
    crosSectionCarbon = crossSectionCarbon * 1e-24;


  return crossSectionCarbon;
    return crossSectionCarbon;
}
  }


/********************************************************************
/*******************************************************************
   * Equation for efficiency according to equation 15-8b
   * Equation for efficiency according to equation 15-8b
   * from Radiation Detection and Measurement
   * from Radiation Detection and Measurement
   *                            by Glenn Knoll
   *                            by Glenn Knoll
   ******************************************************************/
   ******************************************************************/
void efficiencyFunction(double numberHydrogen, double
  void efficiencyFunction(double numberHydrogen, double
                        numberCarbon, double crossSectionHydrogen,
                          numberCarbon, double crossSectionHydrogen,
                        double crossSectionCarbon, double
                          double crossSectionCarbon, double
                        thickness)
                          thickness)
{
  {
    double efficiency;
    double efficiency;
    double nHcH = numberHydrogen * crossSectionHydrogen;
    double nHcH = numberHydrogen * crossSectionHydrogen;
    double nCcC = numberCarbon * crossSectionCarbon;
    double nCcC = numberCarbon * crossSectionCarbon;


    efficiency = (((nHcH) / (nHcH + nCcC)) * (1-exp(-(nHcH
    efficiency = (((nHcH) / (nHcH + nCcC)) * (1-exp(-(nHcH
                                                   + nCcC))
                                                   + nCcC)
                                             * thickness) * 100);
                                             * thickness)));
    cout.precision(4);
    if(efficiency <= 0)
    cout << endl;
    {
    cout << "Therefore, the efficiency of our "
      efficiency = 0;
          << "system is: " << efficiency << "%" << endl;
    }
    cout << endl;
    cout.precision(4);
    return;
    cout << endl;
  }
    cout << "Therefore, the efficiency of our "
        << "system is: " << efficiency *100 << "%" << endl;
    cout << endl;
    return;
  }

Latest revision as of 16:58, 13 May 2008

#include <iostream>
#include <cmath>
using namespace std;
double crossSectionHydrogenFunction();
double numberCarbonFunction(double thickness, 
                            const double CUBICCENTIMETERCARBON);
double numberHydrogenFunction(double thickness, 
                              const double CUBICCENTIMETERHYDROGEN);
double crossSectionCarbonFunction();
void efficiencyFunction(double numberHydrogen, double numberCarbon, 
                        double crossSectionHydrogen, double crossSectionCarbon, 
                        double thickness);
/************************************************************************
* This program is to find the
* efficiency of a neutron detector.
************************************************************************/
double  main()
{
  double neutronEnergy;
  double numberHydrogen;
  double numberCarbon;
  double crossSectionHydrogen;
  double crossSectionCarbon;
  double thickness;
  const double CUBICCENTIMETERCARBON = 5.23e22;
  const double CUBICCENTIMETERHYDROGEN = 4.74e22;
  cout << endl;
  cout << "Enter thickness of detector (in centimeters): ";
  cin >> thickness;
  crossSectionHydrogen = crossSectionHydrogenFunction();
  numberCarbon = numberCarbonFunction(thickness,
                                      CUBICCENTIMETERCARBON);
  numberHydrogen = numberHydrogenFunction(thickness,
                                          CUBICCENTIMETERHYDROGEN);
  crossSectionCarbon = crossSectionCarbonFunction();
  efficiencyFunction(numberHydrogen, numberCarbon,
                     crossSectionHydrogen, crossSectionCarbon,
                     thickness);
}
/**********************************************************************
 * Equation for cross section of hydrogen according to
 * equation 15-9 from Radiation Detection and Measurement
 *                                   by Glenn Knoll
 *********************************************************************/
 double crossSectionHydrogenFunction()
 {
   double neutronEnergy;
   double crossSectionHydrogen;
   cout << endl;
   cout << "Enter neutron energy (in MeV): ";
   cin >> neutronEnergy;
   crossSectionHydrogen = ((4.83e-24 / sqrt(neutronEnergy))
                             - .578e-24);
   return crossSectionHydrogen;
 }
/**********************************************************************
 * Equation for calculating the number of Carbons in
 * the problem per cubic centimeter, dependent on what
 * the user put in for the thickness of the detector.
 *********************************************************************/
 double numberCarbonFunction(double thickness, const
                             double CUBICCENTIMETERCARBON)
 {
   double numberCarbon;
   numberCarbon = CUBICCENTIMETERCARBON;
   return numberCarbon;
 } 
/*********************************************************************
 * Equation for calculating the number of Hydrogens in
 * the problem per cubic centimeter, dependent on what
 *  the user put in for the thickness of the detector.
 ********************************************************************/
 double numberHydrogenFunction(double thickness, const
                               double CUBICCENTIMETERHYDROGEN)
 {
   double numberHydrogen;
   numberHydrogen = CUBICCENTIMETERHYDROGEN;
   return numberHydrogen;
 }
/*********************************************************************
 * Requesting the cross section from the Knoll book, and
 * then calculating it from barns to centimeters.
 ********************************************************************/
 double crossSectionCarbonFunction()
 {
   double crossSectionCarbon;
   cout << endl;
   cout << "Enter the cross section of Carbon by "
        << "looking in Radiation" << endl
        << "Detection and Measurement by Glenn Knoll, on"
        << " page 535, " << endl
        << "Figure 15-15b (in barns): ";
   cin >> crossSectionCarbon;
   crosSectionCarbon = crossSectionCarbon * 1e-24;
   return crossSectionCarbon;
 }
/*******************************************************************
 * Equation for efficiency according to equation 15-8b
 * from Radiation Detection and Measurement
 *                            by Glenn Knoll
 ******************************************************************/
 void efficiencyFunction(double numberHydrogen, double
                         numberCarbon, double crossSectionHydrogen,
                         double crossSectionCarbon, double
                         thickness)
 {
   double efficiency;
   double nHcH = numberHydrogen * crossSectionHydrogen;
   double nCcC = numberCarbon * crossSectionCarbon;
   efficiency = (((nHcH) / (nHcH + nCcC)) * (1-exp(-(nHcH
                                                  + nCcC)
                                            * thickness)));
   if(efficiency <= 0)
   {
     efficiency = 0;
   }
   cout.precision(4);
   cout << endl;
   cout << "Therefore, the efficiency of our "
        << "system is: " << efficiency *100 << "%" << endl;
   cout << endl;
   return;
 }