Skip to content

Unexpected NaN Values in Particle Position Computation #2786

Closed

Description

@Itay-max

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.

Activity

  1. Itay-max commented on Nov 25, 2023

    @Itay-max
    Author
  2. pshriwise commented on Nov 29, 2023

    @pshriwise
    Contributor

    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?

  3. GuySten commented on Aug 28, 2026

    @GuySten
    Contributor

    Should have been fixed by #3526.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions