Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coefficient error in subroutine msdist_pII #110

Closed
jantolak opened this issue Jun 25, 2016 · 1 comment
Closed

Coefficient error in subroutine msdist_pII #110

jantolak opened this issue Jun 25, 2016 · 1 comment
Assignees
Labels

Comments

@jantolak
Copy link
Contributor

jantolak commented Jun 25, 2016

In egsnrc.mortran, subroutine msdist_pII at line 4092, it appears that the polynomial in the denominator is incorrect. Here is the current code at those lines.

4091    "e       = e * (1 - epsilonp*epsilonp*((6+tau*(10+5*tau))/(tau+1)/(tau+2))/24);
4092    e       = e * (1 - epsilonp*epsilonp*(6+10*tau+5*tau2)/(24*tau2+48*tau+72));

Assuming that the expression on line 4091 is correct, the denominator in the last term should be
24*(tau+1)*(tau+2) = 24*(tau2+3*tau+2) = (24*tau2+72*tau+48): the 72 and 48 are not in the right place in the code. Therefore, line 4092 should read

4092    e       = e * (1 - epsilonp*epsilonp*(6+10*tau+5*tau2)/(24*tau2+72*tau+48));

It appears that this error makes very little difference, which is likely why it has not been noticed. The error was actually pointed out to me by a trainee who was working on his own MC code for electron scattering and wanted to compare to an existing code as a baseline.

@ftessier ftessier changed the title possible error in subroutine msdist_pII Possible error in subroutine msdist_pII Jul 29, 2016
@ftessier
Copy link
Member

ftessier commented Jul 29, 2016

Certainly an unfortunate typo!! Fixed in pull request #134.

Accrding to equation A6 of the 2000 Kawrakow paper (Kawrakow, Iwan. "Accurate condensed history Monte Carlo simulation of electron transport. I. EGSnrc, the new EGS4 version." Medical physics 27.3 (2000): 485-498), the denominator should indeed read (24*tau2+72*tau+48), from the expansion of 24*(tau+1)*(tau+2), where tau represents the kinetic energy in units of the rest mass.

For tau > 0 the incurred relative error in the polynomial [ (tau^2+2*tau+3)/(tau^2+3*tau+2) ] - 1 varies between a maximum of 50% at tau = 0 and a minimum of about 0.9 at tau ~= 3.449, and approaches 0 for large energies.

Fortunately, this mistake appears in a second-order term in epsilonp*epsilonp which mitigates its ultimate impact. The relative error in e and other dependent quantities in the code is found to be at most about 1%.

@ftessier ftessier self-assigned this Jul 29, 2016
@ftessier ftessier added the bug label Jul 29, 2016
@ftessier ftessier changed the title Possible error in subroutine msdist_pII Coefficient error in subroutine msdist_pII Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants