-
Notifications
You must be signed in to change notification settings - Fork 50
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
Auto-computing the Required Units #198
Comments
I really want to leverage the machinery introduced by #209 for auto-computing units sooner rather than later.
Currently, Essentially I want to be able to support passing a
The challenge is how do we specify the current scale-factor? I see 2 approaches:
From an API perspective, I kinda prefer choice 1 since it avoids adding "state" to the grackle-solver. With that said, I don't think adding this "state" is really a problem for any particular applications. I definitely welcome opinions! There are currently some internal advantages to state 2, but those may go away after the ongoing refactoring efforts are complete. In all cases, the requirements and handling of |
I like this idea a lot. It will simplify things for users and help emphasize that our choice of comoving units is a particular choice and is not (currently) super flexible. I think a neat eventual extension that Matthew mentioned earlier is to support other comoving coordinate choices. In terms of how to specify the scale-factor, I don't have a strong preference. Part of the |
In my opinion, one of the most difficult things about integrating Grackle into a simulation-code is its handling of the unit-system.
I think part of what makes it so confusing is that we place all the responsibility on the user for making sure that the
code_units
struct is in always in a proper state. What if we let Grackle directly track this unit information?1Essentially, the idea would involve 3 main changes:
code_data
instance used for initializinggrackle_data_storage
inside the instance ofgrackle_data_storage
.unit_name
at the specifiedcurrent_a_value
unit_name
was specified orcurrent_a_value
was specified with an invalid value) by returning a negative value.current_a_value
member to thegrackle_field_data
struct. When Grackle is taking responsibility for tracking its code-units, the value stored by the member would be used to determine the current code-units during function calls to{local_}solve_chemistry
or functions like{local_}calculate_temperature
I think we would need to take some care in 2 regards:
current_a_value
(whether it's an argument ofgr_required_units
or a member of thegrackle_field_data
struct. I would propose that a value of-1
indicates that thea_value
value used during initialization should be used. I would also propose forcomoving_coordinates == 0
, that we treat anycurrent_a_value
value other that does not exactly match-1
or thea_value
value used during initialization as an error.{local_}solve_chemistry
or functions like{local_}calculate_temperature
(i.e. when do we honor thecurrent_a_value
value stored within thegrackle_field_data
struct?). I see a few options:grackle_field_data
is initialized with acurrent_a_value
that disables this behavior by default and that requires users to opt into this new behavior (unfortunately, this is not a backwards-compatible option since we don't currently require users to make use of an initializer-function)NULL
pointer as thecode_units*
arg (I'm a little concerned about cases whereNULL
pointers are passed unintentionally, but we don't currently handle that case gracefully anyways).chemistry_data
struct to opt into the new behavior (I'm less thrilled with this)code_units
struct. But, if we do that, I think it would be worth discussing some larger changes (that might eventually drop the distinction between the global API and local API).Footnotes
This exact sort of automatic unit-tracking is also being suggested as part of the a proposed update to the
pygrackle
api in PR Proposal: More Explicit/User-Friendly Python Bindings #195. ↩The text was updated successfully, but these errors were encountered: