diff --git a/CMakeLists.txt b/CMakeLists.txt index 449512fc128..28f917956a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -320,7 +320,6 @@ list(APPEND libopenmc_SOURCES src/string_utils.cpp src/summary.cpp src/surface.cpp - src/tallies/MyCalcs.cpp src/tallies/derivative.cpp src/tallies/filter.cpp src/tallies/filter_azimuthal.cpp diff --git a/include/openmc/particle.h b/include/openmc/particle.h index df5d9094105..66e7da31d10 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -40,6 +40,10 @@ class Particle : public ParticleData { //! create a secondary particle // + // + double getMass() const; + // + // //! stores the current phase space attributes of the particle in the //! secondary bank and increments the number of sites in the secondary bank. //! \param wgt Weight of the secondary particle diff --git a/include/openmc/tallies/tally_scoring.h b/include/openmc/tallies/tally_scoring.h index ee7155e0f5f..1765c333850 100644 --- a/include/openmc/tallies/tally_scoring.h +++ b/include/openmc/tallies/tally_scoring.h @@ -77,6 +77,14 @@ void score_point_tally(Particle& p); //! Score tallies based on a simple count of events (for continuous energy). // +void boostf( double A[4], double B[4], double X[4]); +double Vdot(double A[4],double B[4]); +void Vcros(double A[4],double B[4],double C[4]); +void Vunit(double A[4] ,double B[4]); + + +void getMu_COM(double x_det , double y_det , double z_det ,Particle p_col , double awr , double incoming_mass, double ReturnArray[],int diff_mode,double dl ); + //! Analog tallies are triggered at every collision, not every event. // //! \param p The particle being tracked diff --git a/src/output.cpp b/src/output.cpp index a31fe9d8030..f2a8961a2a0 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -60,8 +60,8 @@ void title() " #################### aight%%%%%%%%%%%%%%%%%%\n" " ##################### its working%%%%%%%%%%\n" " ###################### %%%%%%%%%%%%%%%%%%%%\n" - " ####################### %%%%%%%%%%%%%%%%%%\n" - " ####################### %%%%%%%%%%%%%%%%%\n" + " ########itay########### %%%%%%%%%%%%%%%%%%\n" + " ######is loser######### %%%%%%%%%%%%%%%%%\n" " ###################### %%%%%%%%%%%%%%%%%\n" " #################### %%%%%%%%%%%%%%%%%\n" " ################# %%%%%%%%%%%%%%%%%\n" diff --git a/src/particle.cpp b/src/particle.cpp index c30b7deda38..ccc8523ba50 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -59,6 +59,26 @@ double Particle::speed() const // Calculate speed via v = c * sqrt(1 - γ^-2) return C_LIGHT * std::sqrt(1 - inv_gamma * inv_gamma); } +double Particle::getMass() const +{ + // Determine mass in eV/c^2 + double mass; + switch (this->type()) { + case ParticleType::neutron: + mass = MASS_NEUTRON_EV; + break; + case ParticleType::photon: + mass = 0.0; + break; + case ParticleType::electron: + case ParticleType::positron: + mass = MASS_ELECTRON_EV; + break; + } + + return mass; +} + void Particle::initilze_ghost_particle(Particle& p,Direction u_new, double E_new) { diff --git a/src/tallies/MyCalcs.cpp b/src/tallies/MyCalcs.cpp index 4f0ae958680..8c7b71fb1eb 100644 --- a/src/tallies/MyCalcs.cpp +++ b/src/tallies/MyCalcs.cpp @@ -1,14 +1,26 @@ #include #include #include "/home/open_mc/openmc/include/openmc/position.h" +#include "openmc/boundary_condition.h" + +#include + +#include + +#include "openmc/constants.h" +#include "openmc/error.h" +#include "openmc/surface.h" using namespace std; + void boostf( double A[4], double B[4], double X[4]); double Vdot(double A[4],double B[4]); void Vcros(double A[4],double B[4],double C[4]); void Vunit(double A[4] ,double B[4]); -int getMu_lab(double x_det , double y_det , double z_det ,Position p_col , double awr , double incoming_mass ) + + +int getMu_lab(double x_det , double y_det , double z_det ,openmc::Position p_col , double awr , double incoming_mass ) { cout<<" p col "< #include "openmc/bank.h" #include "openmc/capi.h" #include "openmc/constants.h" @@ -20,7 +20,7 @@ #include "openmc/distribution_multi.h" #include "openmc/secondary_uncorrelated.h" #include "openmc/geometry.h" -#include "/home/open_mc/openmc/src/tallies/MyCalcs.cpp" +//#include "/home/open_mc/openmc/src/tallies/MyCalcs.cpp" #include #include int ghost_counter=0; @@ -2429,11 +2429,17 @@ void score_collision_tally(Particle& p) void score_point_tally(Particle& p) { fmt::print("------------------------collison happened------------------------\n"); - + std::cout << "mass in ev " << p.getMass() << std::endl ; // Determine the collision estimate of the flux + bool verbose=true; + double ReturnArray[2]; double flux = 0.0; const auto& nuc {data::nuclides[p.event_nuclide()]}; double awr = nuc->awr_; + //auto [value1, value2] = getMu_COM(0,0,0,p,awr,p.getMass(),ReturnArray); + //double ResultsArray = getMu_COM(0,0,0,p,awr,p.getMass()); + double dl = 1e-5; + getMu_COM(0,0,0,p,awr,p.getMass(),ReturnArray , 0, dl); const auto& rx {nuc->reactions_[0]}; auto& d = rx->products_[0].distribution_[0]; auto d_ = dynamic_cast(d.get()); @@ -2442,11 +2448,23 @@ void score_point_tally(Particle& p) double cos_lab = u_lab.dot(p.u_last()); double theta_lab = std::acos(cos_lab); double sin_lab = std::sin(theta_lab); - double mu_COM = (std::sqrt(awr*awr - sin_lab*sin_lab)*cos_lab - sin_lab*sin_lab)/awr; + double mu_COM_or_itay = (std::sqrt(awr*awr - sin_lab*sin_lab)*cos_lab - sin_lab*sin_lab)/awr; + double mu_COM = ReturnArray[0]; + double ReturnArrayPlus[2]; + double ReturnArrayMinus[2]; + //getMu_COM(0,0,0,p,awr,p.getMass(),ReturnArrayPlus ,1 , 1e-5 ); + //getMu_COM(0,0,0,p,awr,p.getMass(),ReturnArrayMinus ,-1 , 1e-5 ); + //double MuPlus = ReturnArrayPlus[0]; // not sure about changing mu lab correctly + //double MuMinus = ReturnArrayMinus[0]; double theta_pdf = d_->angle().get_pdf_value(p.E_last(),mu_COM,p.current_seed()); - double E_ghost = p.E_last()*(1+awr*awr+2*awr*mu_COM)/(1+awr)/(1+awr); - getMu_lab(0,0,0,p.r,awr,1); - + + //double derivative = std::abs(MuPlus-MuMinus)/(2*dl); + double derivative =1; + double theta_pdf_lab = theta_pdf * derivative; + //double E_ghost = p.E_last()*(1+awr*awr+2*awr*mu_COM)/(1+awr)/(1+awr); + + //double m_incoming =MASS_NEUTRON_EV; + double E_ghost = ReturnArray[1]; if(!std::isnan(mu_COM)) { @@ -2490,17 +2508,25 @@ void score_point_tally(Particle& p) //ghost::ghost_particles[0].event_death(); //ghost::ghost_particles.resize(0); - flux = 0.5*ghost_particle.wgt()*exp(-total_MFP)/(2*3.14*total_distance*total_distance); + flux = 0.5*ghost_particle.wgt()*exp(-total_MFP)/(2*3.14*total_distance*total_distance)*theta_pdf_lab; flux = flux*2; - if(flux>1e-10) + + if(verbose) { + fmt::print("------------------------flux contribution------------------------\n"); fmt::print("parent particle pos = {0} , {1} , {2}\n",p.r().x,p.r().y,p.r().z); - fmt::print("parent particle u = {0} , {1} , {2}\n",p.u().x,p.u().y,p.u().z); + fmt::print("parent particle u = {0} , {1} , {2}\n",p.u_last().x,p.u_last().y,p.u_last().z); fmt::print("parent particle E = {}\n",p.E_last()); fmt::print("ghost particle E = {}\n",ghost_particle.E()); fmt::print("ghost particle u = {0} , {1} , {2}\n",ghost_particle.u().x,ghost_particle.u().y,ghost_particle.u().z); - fmt::print("ghost particle Mu COM = {}\n",mu_COM); + fmt::print("ghost particle Mu COM Arik= {}\n",mu_COM); + fmt::print("ghost particle Mu COM Or and Itay = {}\n",mu_COM_or_itay); fmt::print("flux = {}\n",flux); + fmt::print("theta cm pdf ={} \n",theta_pdf); + fmt::print("derivative ={} \n",derivative); + fmt::print("theta lab pdf ={} \n",theta_pdf_lab); + //fmt::print("Mu - ={} \n",MuMinus); + //fmt::print("Mu + ={} \n",MuPlus); } } @@ -2608,4 +2634,254 @@ void score_surface_tally(Particle& p, const vector& tallies) match.bins_present_ = false; } + + + + +void getMu_COM(double x_det , double y_det , double z_det ,Particle p_col , double awr , double incoming_mass ,double ReturnArray[],int diff_mode,double dl ) +{ + //double inv_gamma = p_col.getMass()/ (p_col.E_last() + p_col.getMass()); + //double p_momentum = (1/inv_gamma)*(p_col.getMass() / 1e9 )*std::sqrt(1 - inv_gamma * inv_gamma); // GeV/c + //struct retVals { int i1, i2; }; // Declare a local structure + double m1= p_col.getMass()/1e6; // mass of incoming particle in MeV + double E1_tot = p_col.E_last()/1e6 + m1; // total Energy of incoming particle in MeV + double p1_tot = std::sqrt(E1_tot*E1_tot - m1*m1); + //return retVals {10, 20}; + // std::cout<<" p col "<=-1) + {cosLAB = cosLAB-dl;} + std::cout<<"cosLAB= "<