00001
00002
00003 #include "flux/AlbedoSpectrum.h"
00004
00005 #include "facilities/error.h"
00006 #include <cmath>
00007 #include <string.h>
00008 #include <algorithm>
00009 #include "SpectrumFactory.h"
00010
00011 static SpectrumFactory<AlbedoSpectrum> factory;
00012 const ISpectrumFactory& AlbedoSpectrumFactory = factory;
00013
00014
00015 namespace {
00016
00017
00018
00019 float fromMeV ( float e ) { return e / 1000.; }
00020 }
00021
00022 AlbedoSpectrum::AlbedoSpectrum(const std::string& name)
00023 {
00024 if( name == "gamma" )
00025 type_ = photon;
00026 else if( name == "n" || name=="neutron" )
00027 type_ = neutron;
00028 else
00029 FATAL(" AlbedoSpectrum: not \"gamma\" or \"n\" ");
00030 }
00031
00032
00033 const char * AlbedoSpectrum::particleName()const {
00034 if (type_==photon) return "gamma";
00035 else return "neutron";
00036 }
00037
00038 std::string AlbedoSpectrum::title()const
00039 {
00040 return std::string("albedo-")+std::string(particleName());
00041 }
00042
00043
00044 static double albedo_photon_energy(double);
00045 static double albedo_neutron_energy(double);
00046
00047
00048 float AlbedoSpectrum::operator()(float r)const
00049 {
00050 r = std::max(1e-6, 1.0-r);
00051 return fromMeV((type_==photon)? albedo_photon_energy(r)
00052 : albedo_neutron_energy(r) );
00053 }
00054
00055
00056
00057
00058
00059 #include <math.h>
00060
00061
00062 static const double neutron_emin= 100.,
00063 photon_emin=10.;
00064 static const double neutronexp =(1.6 - 1.0);
00065
00066 static double albedo_photon_energy(double r)
00067
00068
00069 { return photon_emin / r; }
00070
00071 static double albedo_neutron_energy(double r)
00072
00073
00074
00075
00076 { return neutron_emin / pow(r, 1./neutronexp); }
00077
00078
00079 double AlbedoSpectrum::calculate_rate(double old_rate)
00080 {
00081 return old_rate;
00082 }