00001 /* 00002 ------------------------------------------------------------------- 00003 00004 Copyright (C) 2008, 2009, Andrew W. Steiner 00005 00006 This file is part of O2scl. 00007 00008 O2scl is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 O2scl is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with O2scl. If not, see <http://www.gnu.org/licenses/>. 00020 00021 ------------------------------------------------------------------- 00022 */ 00023 #ifndef REACTION_LIB_H 00024 #define REACTION_LIB_H 00025 00026 #include <iostream> 00027 #include <fstream> 00028 #include <string> 00029 #include <sstream> 00030 00031 #include <o2scl/err_hnd.h> 00032 #include <o2scl/string_conv.h> 00033 #include <o2scl/nucleus.h> 00034 #include <o2scl/nuclear_mass.h> 00035 00036 #ifndef DOXYGENP 00037 namespace o2scl { 00038 #endif 00039 00040 /// A simple nuclear reaction specification 00041 class nuclear_reaction { 00042 00043 public: 00044 00045 /// Chapter 00046 size_t chap; 00047 /// Names of the participating nuclei 00048 std::string name[6]; 00049 /// Reference 00050 std::string ref; 00051 /// Type of rate (resonant/non-resonant/weak) 00052 char type; 00053 /// Forward or reverse 00054 char rev; 00055 /// Q value 00056 double Q; 00057 /// Coefficients 00058 double a[7]; 00059 /// Proton number of participating nuclei 00060 size_t Z[6]; 00061 /// Mass number of participating nuclei 00062 size_t A[6]; 00063 /// Isomer designation of participating nuclei 00064 size_t isomer[6]; 00065 00066 nuclear_reaction() { 00067 } 00068 00069 /** \brief Convert the reaction to a string for screen output 00070 */ 00071 std::string to_string() { 00072 std::ostringstream outs; 00073 outs.width(2); 00074 outs << chap << ": "; 00075 nuclear_mass_info nmi; 00076 for(size_t i=0;i<6;i++) { 00077 if (name[i].length()>0 && A[i]>0) { 00078 if (Z[i]==0 && A[i]==1) outs << "n "; 00079 else if (Z[i]==1 && A[i]==1) outs << "p "; 00080 else if (Z[i]==1 && A[i]==2) outs << "d "; 00081 else if (Z[i]==1 && A[i]==3) outs << "t "; 00082 else outs << nmi.Ztoel(Z[i]) << A[i] << " "; 00083 if (i==0 && (chap==1 || chap==2 || chap==3 || chap==11)) { 00084 outs << "-> "; 00085 } else if (i==1 && (chap==4 || chap==5 || chap==6 || chap==7)) { 00086 outs << "-> "; 00087 } else if (i==2 && (chap==8 || chap==9)) { 00088 outs << "-> "; 00089 } else if (i==3 && chap==10) { 00090 outs << "-> "; 00091 } else if (i<5 && name[i+1].length()>0 && A[i+1]>0) { 00092 outs << "+ "; 00093 } 00094 } else { 00095 i=6; 00096 } 00097 } 00098 return outs.str(); 00099 } 00100 00101 /// Clear the rate 00102 int clear() { 00103 chap=0; 00104 ref=""; 00105 type=0; 00106 rev=0; 00107 Q=0.0; 00108 for(size_t i=0;i<6;i++) { 00109 name[i]=""; 00110 a[i]=0.0; 00111 Z[i]=0; 00112 A[i]=0; 00113 isomer[i]=0; 00114 } 00115 a[6]=0.0; 00116 00117 return 0; 00118 } 00119 00120 /// Copy constructor 00121 nuclear_reaction(const nuclear_reaction &nr) { 00122 chap=nr.chap; 00123 ref=nr.ref; 00124 type=nr.type; 00125 rev=nr.rev; 00126 Q=nr.Q; 00127 for(size_t i=0;i<6;i++) { 00128 name[i]=nr.name[i]; 00129 a[i]=nr.a[i]; 00130 Z[i]=nr.Z[i]; 00131 A[i]=nr.A[i]; 00132 isomer[i]=nr.isomer[i]; 00133 } 00134 a[6]=nr.a[6]; 00135 } 00136 00137 /// Copy constructor 00138 nuclear_reaction &operator=(const nuclear_reaction &nr) { 00139 00140 // Check for self-assignment 00141 if (this==&nr) return *this; 00142 00143 chap=nr.chap; 00144 ref=nr.ref; 00145 type=nr.type; 00146 rev=nr.rev; 00147 Q=nr.Q; 00148 for(size_t i=0;i<6;i++) { 00149 name[i]=nr.name[i]; 00150 a[i]=nr.a[i]; 00151 Z[i]=nr.Z[i]; 00152 A[i]=nr.A[i]; 00153 isomer[i]=nr.isomer[i]; 00154 } 00155 a[6]=nr.a[6]; 00156 00157 return *this; 00158 } 00159 00160 /** \brief Compute the reaction rate from the temperature in units of 00161 \f$ 10^9 K \f$ 00162 */ 00163 double rate(double T9) { 00164 double ret; 00165 double T913=cbrt(T9); 00166 ret=exp(a[0]+a[1]/T9+a[2]/T913+a[3]*T913+a[4]*T9+ 00167 a[5]*T9*T913*T913)*pow(T9,a[6]); 00168 return ret; 00169 } 00170 00171 }; 00172 00173 /** 00174 \brief Simple reaction library 00175 00176 Units: 00177 - Chapters 1,2,3, and 11: 1/s 00178 - Chapters 4,5,6, and 7: cm^3/g/s 00179 - Chapter 8 and 9: cm^6/g^2/s 00180 - Chapter 10: cm^9/g^3/s 00181 00182 Chapters: 00183 - 1: nuc1 -> nuc2 00184 - 2: nuc1 -> nuc2 + nuc3 00185 - 3: nuc1 -> nuc2 + nuc3 + nuc4 00186 - 4: nuc1 + nuc2 -> nuc3 00187 - 5: nuc1 + nuc2 -> nuc3 + nuc4 00188 - 6: nuc1 + nuc2 -> nuc3 + nuc4 + nuc5 00189 - 7: nuc1 + nuc2 -> nuc3 + nuc4 + nuc5 + nuc6 00190 - 8: nuc1 + nuc2 + nuc3 -> nuc4 00191 - 9: nuc1 + nuc2 + nuc3 -> nuc4 + nuc5 00192 - 10: nuc1 + nuc2 + nuc3 + nuc4 -> nuc5 + num6 00193 - 11: nuc1 -> nuc2 + nuc3 + nuc4 + nuc5 00194 00195 Original FORTRAN format: 00196 \verbatim 00197 FORMAT(i1,4x,6a5,8x,a4,a1,a1,3x,1pe12.5) 00198 FORMAT(4e13.6) 00199 FORMAT(3e13.6) 00200 \endverbatim 00201 */ 00202 class reaction_lib { 00203 00204 public: 00205 00206 /// The library 00207 std::vector<nuclear_reaction> lib; 00208 00209 /** \brief Read from a file in the REACLIB2 format 00210 00211 \note This function does not check that the chapter numbers 00212 are correct for the subsequent reaction. 00213 */ 00214 int read_file_reaclib2(std::string fname); 00215 00216 /** 00217 \brief Find a set of nuclear reactions in a specified chapter 00218 00219 \comment 00220 This function doesn't make any assumptions about the ordering of 00221 the rates and the chapters. 00222 \endcomment 00223 */ 00224 int find_in_chap(std::vector<nuclear_reaction> &nrl, 00225 size_t chap, std::string nuc1, std::string nuc2="", 00226 std::string nuc3="", std::string nuc4="", 00227 std::string nuc5="", std::string nuc6=""); 00228 00229 protected: 00230 00231 /// Storage for the find function 00232 //@{ 00233 int fN[6], fZ[6], fA[6]; 00234 size_t fi; 00235 //@} 00236 00237 /// Test if entry \c ul in the arrays matches the library reaction 00238 bool matches(size_t ul, size_t ri); 00239 00240 }; 00241 00242 #ifndef DOXYGENP 00243 } 00244 #endif 00245 00246 #endif
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page