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

"Function" Fields #30

Open
luizfelippesr opened this issue Jul 4, 2020 · 1 comment
Open

"Function" Fields #30

luizfelippesr opened this issue Jul 4, 2020 · 1 comment
Labels
enhancement New feature or request Field Involves Field, Grid, Field Factory or Prior objects

Comments

@luizfelippesr
Copy link
Member

At present, Field objects are evaluated on an entire coordinate grid before been passed to a Simulator. More specifically, the get_field method (which relies on the user defined compute_field method) will always return a Quantity array evaluated over the whole coordinate grid that was provided.

This design choice was based on simplicity (it is easy to visualise pre-evaluating everything on a fixed grid) and the present way that Hammurabi works (it can read gridded fields from binary files). In the future, however, there may be room for fields which are only evaluated in the specific points where Simulator needs them. Below a draft design specification of this future feature:

Specification

  • Field's should have an attribute function_field which, when False falls back to the current behaviour
  • If function_field==True
    • The subclass has to include a standardized function (or similar name) method, which takes a coordinate point as argument and returns the evaluated field on that specific point
    • The get_field method will keep backwards compatibility, simply evaluating the function method, instead of relying on compute_field
  • The Simulator will have an attribute indicating whether or not it supports "function fields"
  • If it does support, instead of evaluating and summing the fields, a list of functions is passed to the simulator (which will be able to evaluate them wherever it wants)
  • There is room for Simulators sublcasses which support only "grid fields" (the present behaviour), "grid and function fields" and "only function fields"
    • If a particular Simulator subclass supports only "grid fields", any "function fields" will be evaluated on the grid before being handed to it.
    • If for a particular Simulator only "function fields" are supported, a fake "function field" can be automatically constructed from any "grid-only fields" using interpolation
    • In the case both "grid" and "function fields" are supported, both are provided to the subclasses

Field dependencies are expected to be a major technical challenge to this implementation. For example: a "grid field" which depends on a field type should force all the "function fields" to behave as "grid fields" (or is there a better alternative?).

@luizfelippesr luizfelippesr added enhancement New feature or request Field Involves Field, Grid, Field Factory or Prior objects labels Jul 4, 2020
@luizfelippesr luizfelippesr self-assigned this Jul 30, 2020
@luizfelippesr
Copy link
Member Author

Updated specification

A boolean class attribute GRID_FIELD will define the behaviour of compute_field. If True, compute_field returns an array. If False, it returns a function which takes the coordinates as arguments. The simulator class will be adjusted accordingly.

@luizfelippesr luizfelippesr removed their assignment Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Field Involves Field, Grid, Field Factory or Prior objects
Projects
None yet
Development

No branches or pull requests

1 participant