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

Ion braginskii fluid #263

Closed
wants to merge 26 commits into from
Closed

Ion braginskii fluid #263

wants to merge 26 commits into from

Conversation

LucasMontoya4
Copy link
Collaborator

Preliminary ion code, where braginskii for krook operator is used to calculate heat flux. Ions can now be drift_kinetic_ions, gyrokinetic_ions (which replaced the gyrokinetic_ions = true flag) or braginskii_ions. The boundary condition is set from the Stangeby book on total energy flux for ions.

There is also a plotting system for collisionality_plots, which compares gradient length scales to the mean free path (to establish how collisional you are). Options in the post_processing_input.toml file can be found in the set_defaults_check_section!() part of the _setup_single_input() function that calls collisionality_plots

…nskii ion physics. Gyrokinetic flag replacement of the gyrokinetic_ions case will happen in a later commit, so right now the gyrokinetic option for ion_physics does the same as drift_kinetic.
…gyrokinetic_ions = true being the test, we see whether ion_physics == gyrokinetic_ions
…nnormalised pdf (then subsequent heat flux updates will be with the braginskii closure)
….jl to use the reference collision frequency to calculate braginskii heat flux
…mean free path) and braginskii heat flux boundary condition at walls, following Stangeby (though I haven't checked the subtracted part for conductive heat flux yet).
…small correction to ion braginskii heat flux boundary condition
…ocstring for collisionality_plots function in makie_post_processing
@johnomotani
Copy link
Collaborator

I think the test failures are unrelated to this PR. The version of OpenMPI we get for the tests seems to have been updated to v5, and that changed some configuration parameters - see open-mpi/ompi#8955. I'll make a separate PR to fix that.

@LucasMontoya4
Copy link
Collaborator Author

I see, thanks for letting me know!

johnomotani and others added 6 commits September 26, 2024 19:58
…hat run (for when heat flux in the simulation is calculated using the shape function - having this option for braginskii_ions would just plot the same thing twice)
…nd power in upstream external source. Might add higher powers later.
… braginskii one (which just overplots the old one, apart from the boundaries)
@mrhardman
Copy link
Collaborator

Does this option also support using the collisional coefficients derived from the Fokker-Planck operator? The name "Braginskii" here might be misleading, when I think Braginskii electrons do use the Fokker-Planck coefficients, instead of the Krook ones.

@LucasMontoya4
Copy link
Collaborator Author

After discussing it with John and Sarah, I think the most consistent naming would be for us to call it collisional_krook, because the coefficients for the ion heat flux were calculated using the same formalism as Braginskii, but without the assumption of high flow (because that's not relevant in 1D). Then for the electrons, the fokker-planck operator was used for those coefficients as well, but again we don't yet have the assumption of high flow, so the braginskii closure for electrons should probably be called collisional_fokker-planck for the same reason. The gyro radius over scale length expansion and collision frequency over gyrofrequency expansions are used, but Braginskii is also meant to be high flow. What do you think?

@mrhardman
Copy link
Collaborator

Sounds good to me! I would stick to using all underscores or all hyphens in the string input parameter. Strings like collisional-... or collisional_... seem good to me.

@LucasMontoya4
Copy link
Collaborator Author

I don't know why I wrote fokker-planck with a dash, but I definitely have always preferred keeping underscores for everything, so I'll do that here. In this case, collisional_fokker_planck etc..

…hich is much clearer than just writing braginskii everywhere. Note that I will soon change the naming system to collisional_krook
Copy link
Collaborator

@johnomotani johnomotani left a comment

Choose a reason for hiding this comment

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

Looks good! Once the renaming's done we can merge :-)

Just a couple of little things to look at in the post-processing.

Comment on lines +4155 to +4163
if :ir ∈ keys(kwargs) && isa(kwargs[:ir], mk_int)
for it ∈ 1:size(variable, 3)
@views derivative!(variable[:,:,it], T[:,:,it], run_info.z, run_info.z_spectral)
end
else
for it ∈ 1:size(variable, 4), ir ∈ 1:run_info.r.n
@views derivative!(variable[:,:,ir,it], T[:,:,ir,it], run_info.z, run_info.z_spectral)
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this one, and also "dn_dz" and "dupar_dz", need a loop over species (in case there are multiple ion species). That would lead to 4 different cases depending on if is and/or ir is an integer. I think the following would be better, although the use of CartesianIndices is a bit more cryptic than I'd like

for i  CartesianIndices(selectdim(variable, 1, 1))
    @views derivative!(variable[:,i], T[:,i], run_info.z, run_info.z_spectral)
end

@LucasMontoya4 what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That seems like a pretty nice solution to me! Sorry about that, I was being lazy and avoiding writing multiple species functionality…

Comment on lines +4226 to +4230
n = get_variable(run_info, "density"; kwargs...)
vth = get_variable(run_info, "thermal_speed"; kwargs...)
dT_dz = get_variable(run_info, "dT_dz"; kwargs...)
nu_ii = get_variable(run_info, "collision_frequency_ii"; kwargs...)
variable = @. -(1/2) * 5/4 * n * vth^2 * dT_dz / nu_ii
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we introduce a function for the inside of the loop in calculate_ion_qpar_from_braginskii!() we could re-use it here, like

function _calculate_ion_qpar_from_braginskii_inner(density, vth, nu_ii, dT_dz)
    return @. -(1/2) * 5/4 * density[iz,ir] * vth[iz,ir]^2 /nu_ii * dT_dz[iz,ir,1]
end

The @. should mean this function works for either scalar inputs (like in calculate_ion_qpar_from_braginskii!()) or array inputs (like here).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds great to me. There are a few other cases of re calculating things in the ‘load_data.jl’ file, so there might be a nicer way to revamp all of that function?

Comment on lines +882 to +883
conductive_heat_flux = total_heat_flux - 2.5 * this_ppar * this_upar -
0.5 * this_dens * this_upar^3
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to check whether this is 5/2 or 3/2 in a 1V case... Can check by working out the total heat flux from \int dvpa vpa * 1/2 * vpa^2.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, I should have checked this earlier! Since ppar is only defined as \int dwpa m wpa^2 f , rather than one third of that in the 3d isotropic pressure case, it is only 3/2 instead of 5/2.

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

Successfully merging this pull request may close these issues.

3 participants