SPENVIS Integral vs Differential Data for User-Defined Histograms/Arbitrary Point-Wise Spectrum?

Hello,

I’m using the /gps/hist/point (E_hi) (Weight) command to generate an energy distribution from SPENVIS for a space-radiation application. Since my text files from SPENVIS provide several data point pairs of incident radiation energy and particle flux (see example below), then I believe that I should use /gps/ene/type Arb (arbitrary point-wise energy spectrum) instead of /gps/ene/type User (User-defined energy histogram). However, I’m not sure what type of particle flux I should use for the “Weight” in /gps/hist/point (E_hi) (Weight).

  1. If I’m irradiating a material using /gps/ene/type Arb, does Geant4 randomly select an energy within the energy bounds that I provide in /gps/hist/point according to the weights that I assign to it? If I use /gps/hist/inter Lin, does Geant4 linearly interpolate the energy and weight of the data points in between the ones that I specify using /gps/hist/point?
  2. Should the “Weight” in /gps/hist/point (E_hi) (Weight) be differential particle flux (cm^-2 s^-1 MeV^-1) or integral particle flux (cm^-2 s^-1)? I think the Geant4 GPS documentation says that both the /gps/ene/type User and /gps/ene/type Arb commands require the user to list the differential energy data points via /gps/hist/point (E_hi) (Weight).

Electron Energy Spectrum from SPENVIS
/gps/ang/type planar
/gps/pos/type Plane
/gps/pos/shape Circle
/gps/pos/centre 0 0 20 cm
/gps/pos/radius 1 cm
/gps/particle e-
/gps/ene/type Arb
/gps/ene/diffspec 1
/gps/hist/type arb

/gps/hist/point 0 0
/gps/hist/point 0.04 302130
/gps/hist/point 0.1 185300
/gps/hist/point 0.2 80335
/gps/hist/point 0.3 39246

/gps/hist/point 6 0.03089
/gps/hist/point 6.5 0
/gps/hist/point 7 0
/gps/hist/inter Lin

1 Like
  1. Yes, and yes. If your physics behind the spectrum is some power-law-generating one, I recommend using Log interpolation to avoid funny bumps in the approximated spectrum.
  2. You have /gps/ene/diffspec 1, and it tells Geant4 that the spectrum is differential. Points must be in differential units.
1 Like

Differential spectrum is also the default option (i.e., if you do not specify /gps/ene/diffspec, it assumes to be True).

1 Like

Thank you, this helps a lot! The integral and differential energy spectra that I got from SPENVIS for electrons is shown below. I think I’ll start with a linear interpolation first and I’ll see if that yields satisfactory results before moving on to one of the other interpolation options if needed.

Try plotting a linear interpolation, e.g., in Python, and see what you get in a log-log plot. I do not recommend the linear one unless for a first try.

Thank you for the suggestion! I used MatLab to plot a linear interpolation for an example of an electron and proton energy spectrum that I get from SPENVIS. In the plot below, I arbitrarily chose a 0.5 MeV step size for the interpolation of each spectrum. Of course, if I lower the step size then I get better agreement between the interpolation curves and the data points marked using asterisks (*), and worse agreement when I increase the step size.

By chance, is there some document that discusses the step size/resolution/number of points that Geant4 uses to perform its linear interpolations?

Geant4 goes from point to point. The plots you show are not linear interpolation but rather some running averaging and intelligent smoothing. Interpolation must go through all points of data.

Yes, you’re right. I plotted the previous graph using MATLAB’s linear interpolation function with a relatively coarse step size (0.5 MeV), which yielded suboptimal results. If I use a much finer step size (0.05 MeV), then MATLAB is able to generate points in between my given data points and the actual data points themselves (i.e., the interpolation goes through all points of the given data). The results are shown in the plot below. The interpolation curves are actually several closely spaced data points in the plot and are not a fitting function. Although, I have chosen to draw the interpolation points as a line instead of discrete points so that the given data points (*) are more visible.

By chance, is there some document that discusses the step size/resolution/number of points that Geant4 uses to perform its linear interpolations?

I ask this so that I can understand how Geant4 calculates its linear interpolation. Unlike other software, Geant4 does not seem to have a command for me to specify the step size/number of data points/resolution that it should use in its linear interpolation calculation. And so, I’m worried that Geant4 may use too coarse of a step size, leading to the suboptimal interpolation curves in my previous reply.

Any help would be greatly appreciated.

its not necessarily documentation, but I think this is the relevant source code for your question:
https://apc.u-paris.fr/~franco/g4doxy/html/G4SPSEneDistribution_8cc-source.html#l00313

number of points for the interpolation seems to be the number of points of the given histogram!?

Thank you for sharing that link! I think that in order to understand how many points are being used for the linear interpolation, I would have to understand the

G4int maxi = ArbEnergyH.GetVectorLength();

line in the source code. The value of imax is used by various for loops to calculate relevant quantities for the interpolation (e.g., the gradients between the data points). However, I’m not sure if Geant4 is setting imax equal to 1024 or if it’s setting imax equal to the number of points defined by the user using the /gps/hist/point command?

I haven’t been able to find what the ArbEnergy.H.GetVectorLength() does from the Geant4 source code. I’ll keep looking into it.

It must be an overloaded method returning the length of the vector. I.e., the number of points given in the macro.