openmc icon indicating copy to clipboard operation
openmc copied to clipboard

Unexpected NaN Values in Particle Position Computation

Open Itay-max opened this issue 2 years ago • 2 comments

Bug Description

Unexpected behavior in particle position computation leading to NaN values.

Steps to Reproduce

  1. Run a simple simulation using the latest OpenMC version.

Simulation example

  • Geometry Description: Water-filled sphere centerd at the origin surrounded by a vacuum region.
  • Materials Used: The only material defined is water.
  • Particle Source: An isotropic point source of neutrons is placed at the origin (0, 0, 0) with an energy distribution defined as a discrete energy of 1e6 MeV.
  • The simulation is set to run in fixed source mode with 1,000,000 particles and 100 batches.
  1. Include the following modification (under this line in particle.cpp file):
   if ((this)->E_last()*1e8 < 10)
   {
       std::cout << "p->E_last()  "<< (this)->E_last() <<std::endl;
       std::cout << "p->r() "<< this->r().x<<" "<<this->r().y<<" "<<this->r().z<<" "<<std::endl;
   }
  1. Recompile the project:
cmake ../openmc          
   -DCMAKE_CXX_COMPILER=mpicxx    
   -DOPENMC_USE_MPI=on         
   -DHDF5_PREFER_PARALLEL=on 
   -DCMAKE_INSTALL_PREFIX=/root/OpenMC/install 

make install

Observed Behavior

The code prints nan values for the position of the particle the once in around 15 batches. Here is an example for such case:

p->E_last()  4.33725e-08
p->r() nan nan nan

Expected Behavior

The particle position should be well-defined and should not result in NaN values.

Environment

OpenMC official Docker image.

Itay-max avatar Nov 23 '23 11:11 Itay-max

Might be related: https://openmc.discourse.group/t/segmentation-fault-on-simple-model-after-many-particles/3250

Itay-max avatar Nov 25 '23 13:11 Itay-max

Just noting this comment on the geometry description this morning:

Geometry Description: Water-filled sphere centerd at the origin surrounded by a vacuum region.

@Itay-max, is this based on the same geometry as the one @shimwell provided in the forum discussion you've linked above?

pshriwise avatar Nov 29 '23 16:11 pshriwise