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

Improve unit handling #216

Open
wants to merge 122 commits into
base: main
Choose a base branch
from
Open

Improve unit handling #216

wants to merge 122 commits into from

Conversation

spahrenk
Copy link
Contributor

Description

  • Changes unit-handling throughout HPWHsim. Independent physical constants relevant to HPWHsim are reduced to a short list of exact or reliable values, from which others are then derived. These are defined in file units.hpp, which provides inline initialization of conversion maps and defines partially specialized types for containing values and vectors with unit information.
  • The conversion mechanism is established in 'unity.hpp'. A static std::map is retained for each type of units that provides conversion to/from a reference unit. No association between units of different types (e.g., 'm/s' = 'm' / 's') was deemed necessary to improve units organization within HPWHsim, while maintaining performance.
  • Values with units are specializations of ScaleVal and ScaleOffsetVal, and are retained as doubles. Effort was made to enable easy accessibility of the underlying double, while retaining explicit construction. The internal value (double), or a reference to this value, can be accessed with the () operator.
  • The same guidelines were applied to vectors. These are retained internally as std::vector<double> (e.g., rather than std::vector<ScaleVal<...>>).
  • Every model test reference was replaced, due to generally negligible changes. Differences in yearly test results are somewhat larger, but appear to be within normal tolerances (~ 0.1%). An additional unit test for units conversions is added.

@spahrenk spahrenk self-assigned this Oct 30, 2024
@spahrenk spahrenk requested a review from nealkruis October 30, 2024 15:04
@spahrenk spahrenk changed the base branch from main to develop November 4, 2024 20:08
@spahrenk spahrenk changed the base branch from develop to main November 13, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant