-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor composition and species inputs #234
Conversation
…ectron_physics option.
…ring const variables which match allowed TOML input variables.
…ts. Another level of Dict nesting would require further effort.
…g because of some strange typing error, to be fixed.
…ge key => value sections of a Dictionary. This seems to fix the bug in the previous commit.
Use our `Enum`-handling method of `Base.get()` to handle `Enum` type variables in `set_defaults_and_check_section!()`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main change of this PR - better structs for the species/composition variables and separate input file sections for the options - is one we've been wanting for a while. That all looks good.
On the Enum
s:
- I'd much rather use a standard feature of the language (the
Enum
), than a similar but non-standard bodge. - The way we input
Enum
s includes a check the the value in the input file is an allowed value. With the bodge, this is not currently done forelectron_physics
, and would need to be written by hand each time as a generic function cannot know the allowed values - with theEnum
the generic function can get the allowed values from the type. - It's easier to find the allowed values with
Enum
- they're defined on a single line, and you can also find them in the REPLjulia> moment_kinetics.input_structs.electron_physics moment_kinetics.input_structs.electron_physics_type Enum moment_kinetics.input_structs.electron_physics_type: boltzmann_electron_response = 0 boltzmann_electron_response_with_simple_sheath = 1 braginskii_fluid = 2 kinetic_electrons = 3 kinetic_electrons_with_temperature_equation = 4
It's true that the support was incomplete. We have to add it ourselves since TOML doesn't support Enum
(since that couldn't be done generically). #236 should complete our Enum
support for both input from and output to TOML.
I can see why you wrote test_scripts/dict_merge.jl
and test_scripts/species_input_test.jl
, but are they actually useful to have in the repo? Unlike the collision operator scripts, I'm not seeing how they're useful for future testing/debugging.
makie_post_processing/makie_post_processing/src/shared_utils.jl
Outdated
Show resolved
Hide resolved
@@ -663,6 +511,8 @@ function mk_input(scan_input=Dict(); save_inputs_to_txt=false, ignore_MPI=true) | |||
error("Mirror terms not yet implemented for moment-kinetic modes") | |||
end | |||
|
|||
species_immutable = (ion = composition.ion, neutral = composition.neutral) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If everything in the species
struct is now contained in composition
, can't we just get rid of species
completely? That'd be better for a follow-up PR though, as it'd be nice to merge the electrons
branch first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we could remove species completely. I didn't do so because I wanted to make the minimal number of changes to make it easier for you to approve. Happy to wait for the merge with kinetic electrons (or do it after the merge, if it's me that does the merge here).
Thanks!
But should I put integer or string options in the TOML input to
OK. I am still not fully happy that we needed to make a custom hack to convert enum to string TOML, but if you are confident that it is robust then I cannot argue : ).
These scripts can indeed be deleted now that the functionality is ported into the main code. I wanted them to convince myself that the refactoring was possible in the way that I envisaged it. |
Co-authored-by: John Omotani <[email protected]>
Co-authored-by: John Omotani <[email protected]>
Co-authored-by: John Omotani <[email protected]>
Co-authored-by: John Omotani <[email protected]>
Co-authored-by: John Omotani <[email protected]>
Co-authored-by: John Omotani <[email protected]>
…ures from last merge.
… {String,Any} arguments. Further namelist input Dicts should use OptionsDict.
… argument to prevent inconsistent supply of reference parameters, and to reduce duplicate code if these structs are included in mms tests or diagnostics.
…s using old boltzmann electron logical flag.
… user of the new input structure.
…turn value. Use the return value function to correct the merging of Dicts in the wall_bc_inputs.jl file. Note that the behaviour of merge() on Dicts of Dicts is to replace values of keyword arguements which are themselves Dicts, hence the need for these functions. Presumably these functions could be improved by making them recursive to merge Dicts with arbitrary many levels of Dicts (if no base Julia solution is available).
I am confused as to why the parallel tests are failing here. The |
I could reproduce the errors by running the 'long tests' (which are included in the parallel tests job on ubuntu) and debug tests on my laptop. I think I've fixed them now. |
99b5ec8
to
a3a6186
Compare
When an OptionsDict is passed as a keyword argument in the long tests, the `shortname` could become too long. Add some special handling for AbstractDict arguments to prevent this, by truncating the name. Also pass OptionsDict for timestepping arguments.
The T_wall setting had been accidentally altered (or failed to merge?) when the inputs were refactored, causing sqrt(-1) errors. Reset T_wall to a working value.
a3a6186
to
2c6452d
Compare
PR #225 should be merged to master for this PR to enter master.
This PR makes a namelist structure for the input TOML for composition and species inputs, allowing inputs for an arbitrary number of species to be given. This has the added bonus of cleaning up part of
moment_kinetics_input.jl
and reducing the number of duplicated functions for the generating composition struct data in test scripts.As a part of this refactoring it was convenient (for dealing with file i/o, see PR #233) to remove the
@enum
feature for the electron_physics input. I am quite satisfied with theelectron_physics
option functionality in this PR, because we keep the@enum
variables, whilst allowing a sensible string input to the TOML. Happy to discuss the pros and cons of this change.This PR is a stepping stone towards making a fully multi-species version of moment_kinetics, enabling different charge numbers and masses. Further input option refactoring could be achieved in this PR, if desired (@johnomotani is this interesting?).