-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add simple radiation model (Prad as a fraction of P_tot_in) #572
base: main
Are you sure you want to change the base?
Conversation
@Nush395 if you've got time, could you lend a hand with this? I have a couple of questions about implicit sources and sources that link back. At the moment I'm finding that my implementation is nonzero when I inspect it during runtime but has no effect on the state. In the output, it is 0. |
Yes for sure! Happy to answer questions, feel free to drop them on this PR or we can go over on a call if that's easier :) |
Just took a quick look at the change. Just a sanity check, have you run the
? |
Ah, thanks for spotting that. That would be why it wasn't being used! I'll do that and then see where I get to. Sorry for not spotting the obvious thing! |
No worries at all, I've run into that gotcha myself! |
As of 69f5ada, unit tests fail because I've added a term to post_processed_outputs that is not present in all of the current |
There is, there is a |
@Nush395 it now makes sense to ask my questions!
|
Required regenerating some integration tests with new Prad output
Use source_builder in all tests, except from BootstrapCurrentSource and QeiSource
3cd6cad
to
7a0936a
Compare
For the time being I've gone for only inheriting from
I couldn't quite figure out why |
f737ad0
to
601cde4
Compare
Hey Theo, sorry for the slow response on this.
In the general case I'd advise inheriting from
That's a good question. Taking a quick look now it doesn't seem there is one which is something we can rectify. Thanks for raising this. |
For |
I'm more than happy to tackle this in a separate PR if you want to have a look at the ohmic source? Unless you'd rather do both! |
That would be great if you have time, thanks! |
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.
Looks really great, thanks!
Appreciate also the extensive testing + extensions to the tests.
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.
-
Not sure there's much point in making an example config out of a single feature?
-
Our standard pattern is to make a new integration test in tests/tests_data with new features for regression and integration testing.
Suggest to remove it here, make a new integration test (to add to tests/sim.py also) based on one of the standard cases like test_iterhybrid_predictor_corrector
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.
a bit of a nit:
radiation_heat_sink isn't specific enough, it could refer to cyclotron, bremsstrahlung, e.g.
How about impurity_radiation_heat_sink
?
Was also thinking about line_radiation_heat_sink
, but some radiation models like Mavrin polynomials include both line radiation + cremsstrahlung, so maybe ok to specify just "impurity"
) -> jax.Array: | ||
"""Model function for radiation heat sink. | ||
|
||
In this model, a fixed % of the total power input to the temp_el equation is lost.""" |
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.
nit: confusing wording. Maybe "A fixed % of the total power input is lost as a sink of the temp_el equation"
|
||
Qtot_in = jnp.sum(jnp.stack(source_profiles), axis=0) | ||
Ptot_in = math_utils.cell_integration(Qtot_in * geo.vpr, geo) | ||
Vtot = math_utils.cell_integration(geo.vpr, geo) |
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.
can just use geo.volume_face[-1]
. It will differ by a tiny amount (like 0.01% or so, depending on the grid and geometry resolution) from this cell_integration, since geo.volume_face comes directly from the vpr integration on the original geometry grid, as opposed to the interpolation on the TORAX cell grid.
# Manually remove sources that will not be summed | ||
sources_to_sum = source_models.temp_el_sources | source_models.temp_ion_sources | ||
sources_to_sum.pop(SOURCE_NAME, None) | ||
sources_to_sum.pop(bremsstrahlung_heat_sink.SOURCE_NAME, None) |
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.
Can easily imagine a bug where we add more heat sinks and forget to update this function.
Can we guard against it somehow? Maybe check all remaining keys if they contain the substring 'sink' and then raise an error. This depends on having the discipline to call all new sinks "something_heat_sink", but it's better than nothing.
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.
can remove
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.
can remove
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.
can remove
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.
how come this needed to be replaced?
# and summing over *both* ion and electron heating | ||
|
||
def get_temp_el_profile(source_name: str, source: source_lib.Source) -> jax.Array: | ||
# TODO: Currently this recomputes the profile for each source, which is inefficient |
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.
agree. We will prioritize changing the pattern such that this won't happen.
Add a simplified radiation sink model,
P_rad = α*(P_aux + P_alpha + P_ohmic)
This is based on the functionality in JETTO:
Todo: