Skip to content

Neutral toroidal slip for 1D simulations#297

Draft
bendudson wants to merge 6 commits intomasterfrom
neutral-toroidal-slip
Draft

Neutral toroidal slip for 1D simulations#297
bendudson wants to merge 6 commits intomasterfrom
neutral-toroidal-slip

Conversation

@bendudson
Copy link
Collaborator

@bendudson bendudson commented Feb 21, 2025

Allow parallel flow into the target, by setting the component of the velocity into the target to zero. This is a combination of the parallel flow and perpendicular flow.

Sets a Neumann boundary condition on the parallel velocity, and calculates the perpendicular velocity (i.e. neutral pressure gradient) at the target such that the net flow into the target is zero.

MK comments
Here is my understanding of how this boundary condition works:

  • Usually, neutral velocity must be zero at the boundary in a fluid model if no neutrals are leaving the domain. There is no other way. It was tempting to assume that we could have a momentum source there to represent FC velocity towards the domain, but then no particles would ever get to the target in the first place to become reflected.
  • The only way to relax this requirement is to allow some velocity "out of the page". Physically, picture a neutral bouncing off the target in a direction perpendicular to the field line and flying off into other field lines. It is effectively cross-field transport which enhances parallel diffusion through its poloidal component.
  • In 1D, this translates as parallel particle transport in the upstream direction. The way to get this to work in our model is to make this transport diffusive. This way you could have the momentum equation transport neutrals to the target, but then use the diffusion equation to transport them in the opposite direction after reflection - all simultaneously!
  • This is achieved by the pressure diffusion model, like in 2D. To begin with, we can assume that all particles undergo fast reflection. This is equivalent to a "slip" condition with no losses at the target. We then calculate a neutral pressure at the target such that pressure diffusion occurs with a velocity equal and opposite to that solved by the neutral momentum at the target.
  • In practice, this is like a more physically meaningful neutral redistribution method than that in SD1D and SOL-KiT. It should lead to high flows in the neutral cloud and into the target, and transport the particles from near the target to farther upstream.

Adds diagnostics to print where a value is being used, if it
is modified after use.

Amjuel reactions and CX don't need velocity boundary conditions,
so GET_NOBOUNDARY can be used. This allows the velocity
boundary condition to be set after the reactions.
Loops over both lower and upper boundaries while calling a
user-supplied lambda function. This removes duplication since
a boundary condition only needs to be implemented once rather
than twice.
Work in progress. Runs but not properly tested.

Sets the parallel flow at the wall so that the combined flow into the
target is zero, using a constant neutral pressure gradient.  This
allows a net flow along the target.

An alternative would be to set e.g. a Neumann condition on the
parallel flow, and use that to set the neutral pressure gradient
at the wall.
@bendudson bendudson marked this pull request as draft February 21, 2025 06:50
IS_SET marks the boundary as used, but density boundary is not needed.
Use IS_SET_NOBOUNDARY instead.
If toroidal_slip is true (the default), set the parallel flow to a
Neumann boundary condition. Use the flow velocity to calculate the
pressure gradient needed to create a perpendicular flow that cancels
the net flow into the target.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to make sure I fully understand this. How come using get prevents setting a velocity BC after the reactions? And what is the difference between get and GET_VALUE in general?

Copy link
Collaborator Author

@bendudson bendudson Feb 22, 2025

Choose a reason for hiding this comment

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

Hey @mikekryjak ! The idea is to prevent quantities from being modified after they are used. When get is called it sets two attributes: "final" and "final-domain"
https://github.com/bendudson/hermes-3/blob/master/include/component.hxx#L117
When set is called it checks if these attributes have been set:
https://github.com/bendudson/hermes-3/blob/master/include/component.hxx#L231

To allow quantities to be used in the domain before boundary conditions have been applied, there is getNoBoundary that only sets the "final-domain" attribute:
https://github.com/bendudson/hermes-3/blob/master/include/component.hxx#L183
This allows setBoundary to set the boundary because it only checks the "final" attribute:
https://github.com/bendudson/hermes-3/blob/master/include/component.hxx#L261
In this case the boundary condition on velocity depended on the collision frequency, and the collisions component used the velocity to calculate friction terms, but only in the domain. When collisions are calculated it therefore should use getNoBoundary, which will allow a boundary to be applied later but prevent the values in the domain from being modified.

Both get and getBoundary have an optional second argument location. This is a string that is included in the error messages from set and setBoundary. These tell the user where the quantity was used; otherwise the user just has to guess which components are in the wrong order. The easiest way to set that string is to use GET_VALUE and GET_NOBOUNDARY. These combine the name of the file and the line number where they are run, passing this as the location to get:
https://github.com/bendudson/hermes-3/blob/master/include/component.hxx#L163

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wow, I'm glad I'm learning about this! I think we need to put this in the docs under a new section called "Developer manual" or similar. I raised an issue: #299

This was referenced Feb 23, 2025
The perpendicular momentum of parallel momentum should be separate
from the parallel viscosity term.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Priority development

Development

Successfully merging this pull request may close these issues.

2 participants