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

[EPIC] Unit system #2704

Open
1 of 3 tasks
MelReyCG opened this issue Sep 22, 2023 · 3 comments · Fixed by #2552
Open
1 of 3 tasks

[EPIC] Unit system #2704

MelReyCG opened this issue Sep 22, 2023 · 3 comments · Fixed by #2552
Assignees
Labels
EPIC The agile epic concept type: feature New feature or request type: new A new issue has been created and requires attention

Comments

@MelReyCG
Copy link
Contributor

MelReyCG commented Sep 22, 2023

Issue general information

What is the requested feature?

  • A unit system for GEOS.

Is your request related to a specific problem?

  1. Some data structures, as the TableFunction, hold data and does not know its unit, so related reports or error message can be misleading.
  2. GEOS users cannot specify which unit they want for the various input & output data.
  3. The code could be more self-explaining if variables could be declared as Pressure, Distance or Viscosity type rather than real64.
  4. There is a lack of information on the temperature units (Kelvin or Celsius) at different places in the code.


  • II. Add a statically typed unit system.
  • We could add or inspire from a library like mp-units.
  • We need an extensive, simple and light solution, the goal is not to complexify the code nor to affect the performances.
  • We need to be able to statically or dynamically add an unit to a value or a container.

  • III. Expose a unit system configuration for GEOS input / output.
  • Add a <UnitSystem/> node to <Problem/>
  • Add a preset attribute to UnitSystem, which would allow to quickly use a unit system preset as a base. These preset would be documented in the user guide, and would be added by the different teams working on GEOS.
  • Add <UnitSystem/> children node for each characteristics.
    As an exemple : <Time inputFiles="years" stdout="days" outputFiles="s" />
    Or, as a more uniform exemple : <Time units="d" />

_Note: I'm not perfectly convinced that the task II. is required for GEOS, input / output conversion may be sufficient.

@MelReyCG MelReyCG added type: feature New feature or request type: new A new issue has been created and requires attention EPIC The agile epic concept labels Sep 22, 2023
@MelReyCG MelReyCG self-assigned this Sep 22, 2023
@paveltomin paveltomin reopened this Oct 26, 2023
@rrsettgast
Copy link
Member

@MelReyCG Lets pick this back up.
As a reference, the way we did units in the old GEOS as to have them be strictly an input/output concept.

  • There was a unit block with the default system.
  • Any numerical values were allowed to contain a unit at the end of the input string. These would be separated with a space, allowing parsing of the units upon processing of the XML.
  • Values with a unit other than the default system would be converted to the default units, values with no unit specified would be assumed to be in the default unit. We generally used SI as the default units.
  • The internals of the code had no concept of units.
  • outputs could be converted to a output unit system.

I think this is kind of a subset of what you propose, but it is fairly non-intrusive. The problems we have now are the fact that we have other ways to access data (i.e. python interface) but could try to specify values in the non-default units....etc.

@untereiner
Copy link
Contributor

The problems we have now are the fact that we have other ways to access data (i.e. python interface)

That’s a reason we propose to statically type C++ variables: Compute functions can then be overloaded for different unit types and do computation in different ways

@rrsettgast
Copy link
Member

Can you give an example of a case where we would want to overload a compute function based on unit type?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EPIC The agile epic concept type: feature New feature or request type: new A new issue has been created and requires attention
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants