mctools / ncrystal

NCrystal : a library for thermal neutron transport in crystals and other materials
https://mctools.github.io/ncrystal/
Other
38 stars 17 forks source link

PG-mode for beryllium exposes numerical integration issue #171

Closed tkittel closed 2 months ago

tkittel commented 2 months ago
import NCrystal as NC
import numpy as np
wl_x = np.arange(0.0,10.0,0.01)
pc_x=NC.createScatter("Be_sg194.ncmat;dir1=@crys_hkl:0,0,1@lab:0,1,0;dir2=@crys_hkl:1,0,0@lab:1,0,0;mos=1deg;dirtol=180deg;lcaxis=0,0,1")
pc_x.crossSection(NC.wl2ekin(wl_x),direction=(0,0,1))

Gives warnings (and eventually an error):

NCrystal WARNING: Problems during numerical integration of Gaussian density on sphere. Romberg integration did not converge after 2049 function evaluations (requested acc=0.0001, got acc=nan). Dumping integrand to ncrystal_goscircleintegral_fct.txt for debugging. Further warnings of this type will not be emitted.
tkittel commented 2 months ago

FYI @dddijulio @marquezj I will track this issue here.

tkittel commented 2 months ago

I think I have a trivial fix for this, let me test it a bit.

tkittel commented 2 months ago

It was some cosine value which ended up as 1.000000000000004 and a subsequent sin=sqrt(1-cos*cos) then resulting in an FPE/NAN.

tkittel commented 2 months ago

Fixed in 3.8.1. Closing.