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

Plasma in-situ diags #968

Merged

Conversation

SeverinDiederichs
Copy link
Member

@SeverinDiederichs SeverinDiederichs commented Jun 2, 2023

This PR adds plasma in-situ diagnostics. They can be used to calculate e.g., the temperature evolution of the plasma.

I also refactored the documentation on in-situ diagnostics a little bit.

  • Small enough (< few 100s of lines), otherwise it should probably be split into smaller PRs
  • Tested (describe the tests in the PR description)
  • Runs on GPU (basic: the code compiles and run well with the new module)
  • Contains an automated test (checksum and/or comparison with theory)
  • Documented: all elements (classes and their members, functions, namespaces, etc.) are documented
  • Constified (All that can be const is const)
  • Code is clean (no unwanted comments, )
  • Style and code conventions are respected at the bottom of https://github.com/Hi-PACE/hipace
  • Proper label and GitHub project, if applicable

@SeverinDiederichs SeverinDiederichs added component: plasma About the plasma species component: diagnostics About any types of diagnostics labels Jun 2, 2023
@SeverinDiederichs SeverinDiederichs changed the title [WIP] Plasma insitu diags Plasma in-situ diags Jun 3, 2023
@SeverinDiederichs SeverinDiederichs requested review from AlexanderSinn and MaxThevenet and removed request for AlexanderSinn June 3, 2023 09:50
Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! See suggestions & comments below.

docs/source/run/parameters.rst Outdated Show resolved Hide resolved
docs/source/run/parameters.rst Outdated Show resolved Hide resolved
docs/source/run/parameters.rst Show resolved Hide resolved
docs/source/run/parameters.rst Outdated Show resolved Hide resolved
docs/source/run/parameters.rst Outdated Show resolved Hide resolved
src/particles/plasma/PlasmaParticleContainer.cpp Outdated Show resolved Hide resolved
src/particles/plasma/PlasmaParticleContainer.cpp Outdated Show resolved Hide resolved
src/particles/plasma/PlasmaParticleContainer.cpp Outdated Show resolved Hide resolved
Comment on lines 100 to 135
def temperature_in_ev_x(all_data, per_slice=True):
if per_slice:
if all_data["is_normalized_units"][0]:
return (constants.m_e * constants.c**2 / constants.e) * normalized_momentum_std_x(all_data)**2 * np.atleast_2d(all_data["mass"]).T
else:
return (constants.c**2 / constants.e) * normalized_momentum_std_x(all_data)**2 * np.atleast_2d(all_data["mass"]).T
else:
if all_data["is_normalized_units"][0]:
return (constants.m_e * constants.c**2 / constants.e) * normalized_momentum_std_x(all_data["average"])**2 * all_data["mass"]
else:
return (constants.c**2 / constants.e) * normalized_momentum_std_x(all_data["average"])**2 * all_data["mass"]

def temperature_in_ev_y(all_data, per_slice=True):
if per_slice:
if all_data["is_normalized_units"][0]:
return (constants.m_e * constants.c**2 / constants.e) * normalized_momentum_std_y(all_data)**2 * np.atleast_2d(all_data["mass"]).T
else:
return (constants.c**2 / constants.e) * normalized_momentum_std_y(all_data)**2 * np.atleast_2d(all_data["mass"]).T
else:
if all_data["is_normalized_units"][0]:
return (constants.m_e * constants.c**2 / constants.e) * normalized_momentum_std_y(all_data["average"])**2 * all_data["mass"]
else:
return (constants.c**2 / constants.e) * normalized_momentum_std_y(all_data["average"])**2 * all_data["mass"]

def temperature_in_ev_z(all_data, per_slice=True):
if per_slice:
if all_data["is_normalized_units"][0]:
return (constants.m_e * constants.c**2 / constants.e) * normalized_momentum_std_z(all_data)**2 * np.atleast_2d(all_data["mass"]).T
else:
return (constants.c**2 / constants.e) * normalized_momentum_std_z(all_data)**2 * np.atleast_2d(all_data["mass"]).T
else:
if all_data["is_normalized_units"][0]:
return (constants.m_e * constants.c**2 / constants.e) * normalized_momentum_std_z(all_data["average"])**2 * all_data["mass"]
else:
return (constants.c**2 / constants.e) * normalized_momentum_std_z(all_data["average"])**2 * all_data["mass"]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you merge these 3 with a new mandatory input parameter? Maybe define a function normalized_momentum_std that is a copy of _x or _y etc. depending on the direction, and then have the cumbersome piece of code only once?

Copy link
Member Author

@SeverinDiederichs SeverinDiederichs Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to clean it, please have a look (best use split screen, otherwise it is awful to look at)

Co-authored-by: Maxence Thévenet <[email protected]>
Comment on lines +559 to +562
#ifdef HIPACE_USE_OPENPMD
// create subdirectory
openPMD::auxiliary::create_directories(m_insitu_file_prefix);
#endif
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we need openPMD::auxiliary

@MaxThevenet
Copy link
Member

  • eV

Copy link
Member

@MaxThevenet MaxThevenet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@MaxThevenet MaxThevenet merged commit bd7d541 into Hi-PACE:development Jun 8, 2023
@SeverinDiederichs SeverinDiederichs deleted the plasma_insitu_diags branch June 8, 2023 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: diagnostics About any types of diagnostics component: plasma About the plasma species
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants