Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #604 +/- ##
==========================================
- Coverage 88.13% 88.08% -0.06%
==========================================
Files 32 32
Lines 4729 4749 +20
Branches 796 802 +6
==========================================
+ Hits 4168 4183 +15
Misses 401 401
- Partials 160 165 +5 ☔ View full report in Codecov by Sentry. |
| HII_D_PARA}; | ||
|
|
||
| unsigned long long int idx; | ||
| if (optional_quantities_global->kinetic_temperature) { |
There was a problem hiding this comment.
Notice that the sole purpose of set_ionized_temperatures is to determine the kinetic_temperature, so it is best to put this condition when set_ionized_temperatures is called (from ComputeIonizedBox) rather than to place this condition in set_ionized_temperatures.
| growth = get_growth_factor(inputs=inputs, redshift=redshift) | ||
| return get_delta_crit_nu(inputs.matter_options.cdict["HMF"], sigma, growth) | ||
| return get_delta_crit_nu( | ||
| inputs.matter_options.cdict["HMF"], float(sigma[0]), growth |
There was a problem hiding this comment.
Why this change was made?
|
|
||
|
|
||
| @attrs.define(kw_only=True, frozen=True) | ||
| class OptionalQuantities(InputStruct): |
There was a problem hiding this comment.
Does it really need to be a sub-class of InputStruct?
jordanflitter
left a comment
There was a problem hiding this comment.
Thanks @steven-murray ! I made some minor comments/questions. My major comments/questions are the following:
- I understand the overall logic, but I wish, if it’s possible, to include the optional quantities in a more elegant way. For example, in the (very near) future, I’d like to include MANY optional quantities from
SpinTemperatureBox.c(e.g.x_alpha, Lya flux,tau_GP, heating/cooling rates, essentially all the physical quantities that the code computes), as it will be very illuminating to see how all of these IGM’s properties evolve over time (withrun_global_evolution). If we keep specifying manually each possible optional quantities, we will end up with a struct that contains A LOT of fields, where most of them will be discarded (unless werun_global_evolution). So what I have in my mind is thatrun_coevalwill have aquantitiesargument (similarly asrun_lightcone). Then, based on the user’s specified quantities + required quantities from each output struct, we will have a list of all the quantitates that we do want to keep. There’s a different question now of how to pass that list elegantly to the backend. One idea that I have from the top of my had is to send the backend a long string that contains all the desired fields, separated by a dash (or any other separator you have in mind), e.g. “neutral_fraction-brightness_temp”. Then the C code could easily understand if a given quantity should be stored as an output or not. Similarly, the wrapper will understand if it needs to allocate memory for that quantity. What I’m suggesting here might be an overkill for this preliminary PR, especially when considering its urgency, but maybe something between the current implementation and this idea could be done. - I don’t understand why
kinetic_temp_neutralfromTsBoxis an optional quantity. IfUSE_TS_FLUCT=True, that quantity is absolutely necessary for the evaluation of the spin temperature. Otherwise, ifUSE_TS_FLUCT=False, noTsBoxesare made, and the C code inIonisationBox.calready knows what to do whenkinetic_temp_neutralis not available.
|
Thanks @jordanflitter for your comments. I think it would be wise, given your comments, to back off on this PR until we have a better idea of how it should work. In particular, the benefits of having the optional boxes be specified as an
OTOH, the benefits of having the boxes be specified directly to
I think out of these considerations, one that is an absolute must is that users should not be able to get into the situation in which they run a simulation, and then later decide they actually want This situation is handled "for free" if we specify the optional quantities as InputStructs. To handle this situation if these were instead passed as lists of strings (or similar) to
Actually, I think (3) is the clear winner.... what do you think @jordanflitter ? |
|
Thanks for the very impressive comment ;) So I totally agree that (2) is better than (1), for several reasons: obnoxious implementation of for the developers, telling the users to switch cache directory (pretty annoying). My problem with (3) is that while currently it can work, let's say with fields like I therefore vote for (2). In my opinion, I think it's perfectly fine that After thinking about this a little bit more, maybe we can have a "ghost" |
|
@jordanflitter I am not sure I understand your reservations about (3). I think the point of "optional" quantities is that they are optional -- anything indispensable for the rest of the calculations must be computed as normal. Only these end-results that don't contribute to anything else should be treated in this way. There is I suppose the potential for there to be quantities that are required to compute some other optional quantity only. In this case, they are required if the user wants the downstream optional quantity, but otherwise could be considered their own optional quantity. Maybe this is what you were getting at. I'm not quite sure how to deal with this. I also don't particularly like (2). It's better than (1), but it doesn't feel right to switch out the user's inputs from under them. Also, right now the only optional things are in the astro boxes, which means we only have to invalidate that cache (and can reuse the ICs and PFs even when the optional quantities are changed). However, in the future it's possible we'll also have density-field optional quantities (?) and then we'll have to think of some API that's a bit more modular. The other reason I don't particularly like (2) is that re-running just to get a couple of extra optional quantities seems... wsateful. And also the whole new box, with all the same quantities (plus a couple of extra) will be re-written to disk, instead of just adding the new quantities to the existing file (or their own file). |
This PR adds the general ability for us to have "optional quantities" that can be output for the user, but otherwise are not required. For starters, I've added the three easiest of these (mean free path, kinetic_temp_neutral and kinetic_temperature).
This adds a new InputStruct, but since it is a simple one, old boxes and templates should all read in just fine.