Problem 2316

Summary: Incorrect cubic spline interpolation in G4PhysicsVector
Product: Geant4 Reporter: Konstantin <konstik>
Component: global/managementAssignee: Vladimir.Ivantchenko
Status: RESOLVED FIXED    
Severity: major    
Priority: P4    
Version: 10.7   
Hardware: All   
OS: All   
Attachments: program, it's output and description of program formulas

Description Konstantin 2021-01-24 22:11:16 CET
Created attachment 661 [details]
program, it's output and description of program formulas

Interpolation of physical values by spline has discontinuities of the first derivative at some knot points. It can be shown by the attached code ("Program" section in attached file). There we calculate derivative of successive splines at the same point analytically (description of formulas is in attached pdf file) and numerically for a vector. In program output ("Output" section) we can see that at some points derivatives from successive cubic polynomials doesn't coincide at some points.
Comment 1 Vladimir.Ivantchenko 2021-11-17 12:48:40 CET
Hello,

thank you for the proposal. For the new release 11.0 which will be publicly available soon there is a possibility to use different spline methods with different properties. Note, that spline depend on a condition applied to the first and the last point. Your proposal may be also considered, if the first and the last point can be correctly evaluated (sorry had no time to check yet).

Concerning the example of Barkas correction table. After evaluation we decided to disable spline for it, because the correction itself is small and the table values have some irregularites, so linear interpolation is more safe and reasonably accurate for this case.

Vladimir
Comment 2 Vladimir.Ivantchenko 2022-01-05 17:29:53 CET
Hello,

the formula [1] from your attachment is used in Geant4. There are different approaches how to compute the cubic spline coefficients. For today we have 3 variants with different level of accuracy: https://geant4.kek.jp/lxr/source/global/management/src/G4PhysicsVector.cc 

If you will propose an alternative one it can be considered.

VI