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

mappings.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: 1735 $
00029  * $Date: 2006-02-09 13:47:26 -0800 (Thu, 09 Feb 2006) $
00030  * $Author: dbrown $
00031  * $Id: mappings.cpp 1735 2006-02-09 21:47:26Z dbrown $
00032  * 
00033  * ******** fete: From ENDF To ENDL *********
00034  */
00035 
00036 // implementation of the mappings class
00037 
00038 #include <fstream>  // standard file stream package
00039 #include <iostream>
00040 
00041 #include "mappings.hpp"
00042 #include "messaging.hpp"
00043 
00044 using namespace std;
00045 
00046 // Set Use_cm true if you want to keep Kalbach data 
00047 // in the center-of-mass frame, false for lab frame.
00048 const bool Use_cm = false;
00049 
00050 // ********* Pair class **********************
00051 // ------------- constructor --------------------
00052 Pair::Pair()
00053 {
00054   E = 0.0;
00055   mu = 0.0;
00056 }
00057 // ------------- copy constructor -----------------
00058 Pair::Pair(double energy, double cosine)
00059 {
00060   E = energy;
00061   mu = cosine;
00062 }
00063 // ------------- destructor --------------------
00064 Pair::~Pair()
00065 {
00066 }
00067 // ------------- subtraction -------------------
00068 Pair operator-(const Pair& A, const Pair& B)
00069 // return A - B
00070 {
00071   Pair diff = Pair(A.E - B.E, A.mu - B.mu);
00072   return diff;
00073 }
00074 // ------------- Pair_area -------------------
00075 double Pair_area(const Pair& A, const Pair& B)
00076 // area of the triangle generated by A, B, and O
00077 {
00078   // use the vector cross product
00079   double area = 0.5*(A.E*B.mu - B.E*A.mu);
00080   return area;
00081 }
00082 
00083 // ********* mappings class **********************
00084 // ------------- default constructor --------------------
00085 mappings::mappings( )
00086 {
00087   _E_in = 0.0;
00088 
00089   E_transl = 0.0;
00090 }
00091 // ------------- constructor --------------------
00092 mappings::mappings(Target *target, Projectile *projectile,
00093     Product *ejectum, double E_in)
00094 {
00095   _target = target;
00096   _projectile = projectile;
00097   _ejectum = ejectum;
00098   _E_in = E_in;
00099 
00100   // translational energy from initial collision
00101   // AWR is the atomic weight.
00102   // It is zero if we stay in center-of-mass frame
00103   E_transl = ( Use_cm ) ? 0.0 :
00104     (projectile->AWR)*(ejectum->AWR)*E_in/
00105     ((projectile->AWR + target->AWR)*
00106       (projectile->AWR + target->AWR));
00107 }
00108 // ------------- destructor --------------------
00109 mappings::~mappings()
00110 {
00111 }
00112 // ------------- mappings::set_map --------------------
00113 void mappings::set_map(Target *target, Projectile *projectile,
00114     Product *ejectum, double E_in)
00115 {
00116   _target = target;
00117   _projectile = projectile;
00118   _ejectum = ejectum;
00119   _E_in = E_in;
00120 
00121   // translational energy from initial collision
00122   // AWR is the atomic weight.
00123   // It is zero if we stay in center-of-mass frame
00124   E_transl = ( Use_cm ) ? 0.0 :
00125     (projectile->AWR)*(ejectum->AWR)*E_in/
00126     ((projectile->AWR + target->AWR)*
00127       (projectile->AWR + target->AWR));
00128 }
00129 // ------------- lab_to_cm --------------------
00130 Pair mappings::lab_to_cm(Pair& lab)
00131 {
00132   // this mapping is ill posed if cm.E is near 0
00133   const double Floor = 1.0e-8 * E_transl;
00134   if( Use_cm )
00135   {
00136     return lab;  // no change of coordinates
00137   }
00138   else
00139   {
00140     Pair cm;
00141 
00142     cm.E = lab.E + E_transl - 2*(lab.mu)*sqrt(E_transl*lab.E);
00143     if( cm.E < Floor )
00144     {
00145       cm.mu = 0.0;
00146     }
00147     else
00148     {
00149       cm.mu = (lab.mu)*sqrt(lab.E/cm.E) - sqrt(E_transl/cm.E);
00150     }
00151     return cm;
00152   }
00153 }
00154 // ------------- cm_to_lab --------------------
00155 Pair mappings::cm_to_lab(Pair& cm)
00156 // map from center-of-mass to Lab
00157 {
00158   if( Use_cm )
00159   {
00160     return cm;  // no change of coordinates
00161   }
00162   else
00163   {
00164     Pair lab;
00165 
00166     lab.E = cm.E + E_transl + 2*(cm.mu)*sqrt(E_transl*cm.E);
00167 
00168     if(lab.E == 0.0)
00169     {
00170       lab.mu = 0.0;  //  pick an angle
00171     }
00172     else
00173     {
00174       lab.mu = (cm.mu)*sqrt(cm.E/lab.E) + sqrt(E_transl/lab.E);
00175     }
00176     return lab;
00177   }
00178 }
00179 // ------------- J_cm_to_lab --------------------
00180 double mappings::J_cm_to_lab( double E_cm, double E_lab )
00181 // Jacobian of the mapping
00182 {
00183   if( Use_cm )
00184   {
00185     return 1.0;  // no change of coordinates
00186   }
00187   else
00188   {
00189     const double J_max = 1.0e7;
00190 
00191     // don't divide by zero
00192     double J = ( E_cm*J_max*J_max < E_lab )? J = J_max :
00193       sqrt( E_lab / E_cm );
00194 
00195     return J;
00196   }
00197 }
00198 // ------------- get_min_mu --------------------
00199 double mappings::get_min_mu(double E_cm)
00200 // return the minimal cosine (lab frame) for this exit energy
00201 {
00202   double smallest;
00203 
00204   if(E_cm > E_transl)
00205   {
00206     smallest = -1.0;
00207   }
00208   else if(E_cm == E_transl)
00209   {
00210     smallest = 0.0;
00211   }
00212   else
00213   {
00214     smallest = sqrt(1.0 - E_cm/E_transl);
00215   }
00216   return smallest;
00217 }
00218 
00219 // ------------- get_E_range --------------------
00220 void mappings::get_E_range(double E_cm, double mu, double *E_back,
00221   double *E_ahead)
00222 // Return the lab frame exit energies for given center-of-mass exit
00223 // energy and lab angle mu.
00224 // If there are 2 such energies, the smaller one is E_back.
00225 // If there is only 1, it is E_ahead and E_back = -1.
00226 // If there are none, then both E_ahead and E_back are set to -1.
00227 {
00228   double V_1 = E_cm - (1 - mu*mu)*E_transl;
00229 
00230   if(V_1 < 0.0)
00231   {
00232     Warning("mappings::get_E_range",pastenum("no particles with mu: ",mu));
00233     *E_back = -1.0;
00234     *E_ahead = -1.0;
00235   }
00236   else
00237   {
00238     V_1 = sqrt(V_1);
00239     double V_2 = mu*sqrt(E_transl);
00240     if(E_cm < E_transl)
00241     {
00242       // there are two forward velocities
00243       *E_back = (V_2 - V_1)*(V_2 - V_1);
00244       *E_ahead = (V_2 + V_1)*(V_2 + V_1);
00245     }
00246     else
00247     {
00248       // there is just one velocity
00249       *E_back = -1.0;
00250       *E_ahead = (V_2 + V_1)*(V_2 + V_1);
00251     }
00252   }
00253 }
00254 // ------------- mappings::get_lab_E --------------------
00255 // Calculates the larger lab energy for given c-m energy and lab mu
00256 double mappings::get_lab_E( double E_cm, double mu_lab, int sigma )
00257 {
00258   // With V_0 = sqrt(E_transl) and alpha = tan(theta_lab),
00259   // find the intersection of the line
00260   //   y = alpha * (x + V_0)
00261   // with the circle x^2 + y^2 = E_cm,
00262   // sigma specifies the sign of the square root
00263 
00264   double E_lab;
00265 
00266   // special for mu = 0
00267   if( mu_lab == 0.0 )
00268   {
00269     E_lab = E_cm - E_transl;
00270     if( E_lab < 0.0 )
00271     {
00272       SevereError("mappings::lab_E_big", "negative E_lab");
00273     }
00274   }
00275   else
00276   {
00277     double alpha_sq = ( 1 - mu_lab*mu_lab ) / ( mu_lab*mu_lab );
00278     double alpha = sqrt( alpha_sq );
00279     if( mu_lab < 0.0 )
00280     {
00281       alpha *= -1.0;
00282     }
00283     double V_0 = sqrt( E_transl );
00284     double radical = alpha_sq*alpha_sq*E_transl +
00285       (1 + alpha_sq)*(E_cm - alpha_sq*E_transl);
00286     if( radical < 0.0 )
00287     {
00288       SevereError("mappings::get_lab_E", "no E_lab found");
00289     }
00290     double x = ( -alpha_sq*V_0 + sigma*sqrt( radical ) ) / ( 1 + alpha_sq );
00291     double y = alpha * ( x + V_0 );
00292     E_lab = ( x + V_0 )*( x + V_0 ) + y*y;
00293   }
00294   return E_lab;
00295 }
00296 

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