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

Apparent bug in ion contribution to Thomson scattering spectrum #2698

Closed
namurphy opened this issue May 23, 2024 · 1 comment · Fixed by #2699
Closed

Apparent bug in ion contribution to Thomson scattering spectrum #2698

namurphy opened this issue May 23, 2024 · 1 comment · Fixed by #2699
Milestone

Comments

@namurphy
Copy link
Member

We received a bug report over email.

I believe there may be a bug in the computation of the ion contribution for the Thomson scattering in diagnostics/thomson.py. Specifically, the contribution from the species' charge (line 247) appears to be slightly incorrect. Rather than ion_z​ it should be ion_z**2 / zbar​ according to Sheffield (Section 5.1, Eq. 5.1.2 and following on page 104 - see screenshot below)
unnamed

@pheuer — could you look into this?

@namurphy namurphy added this to the v2024.9.0 milestone May 23, 2024
@pheuer
Copy link
Member

pheuer commented May 23, 2024

Thank you to whoever was looking this closely at the code!

The term in Sheffield is

$\sum_j Z_j^2 n_j / \sum_k n_k Z_k$

if we divide both top and bottom by the total density $\sum_x n_x$ we get

$\sum_j Z_j^2 F_i / \sum_k F_k z_k$

where $F_i =n_i / \sum_x n_x$ is the fraction of each ion species.

Where, using the definition of zbar earlier in our code as
$\bar Z = \sum_k F_k Z_k$

we get
$\sum_j f_i Z_j^2 / \bar Z$

The $f_i$ is already included in our code, so I think the user's suggested code is correct.

I think we should change it as suggested. I will open a PR.

image

EDIT: math

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants