Problem 2316 - Incorrect cubic spline interpolation in G4PhysicsVector
Summary: Incorrect cubic spline interpolation in G4PhysicsVector
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: global/management (show other problems)
Version: 10.7
Hardware: All All
: P4 major
Assignee: Vladimir.Ivantchenko
URL:
Depends on:
Blocks:
 
Reported: 2021-01-24 22:11 CET by Konstantin
Modified: 2022-01-05 17:29 CET (History)
0 users

See Also:


Attachments
program, it's output and description of program formulas (157.79 KB, application/pdf)
2021-01-24 22:11 CET, Konstantin
Details

Note You need to log in before you can comment on or make changes to this problem.
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