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

Brackets missing when there are multiple denominators in units string #1349

Closed
glyn-horsham opened this issue Jan 3, 2024 · 2 comments
Closed
Labels

Comments

@glyn-horsham
Copy link

According to the BODMAS mathematical convention, division comes before multiplication, therefore, the unit definitions where there are multiple denominators should be in brackets to avoid confusion between, say, W/m^2·C and (W/m^2)·C

For example, for heat transfer coefficients:
"Abbreviations": [ "kcal/h·m²·°C", "kcal/m²·h·°C", "kcal/hr·m²·°C", "kcal/m²·hr·°C" ]
should be
"Abbreviations": [ "kcal/(h·m²·°C)", "kcal/(m²·h·°C)", "kcal/(hr·m²·°C)", "kcal/(m²·hr·°C)" ]

This applies to multiple units in the code, from glancing though, I have found HeatTransferComponents and VolumetricHeatCapacity, but there maybe others.

@angularsen
Copy link
Owner

Thank you for reporting, would you be interested in attempting a pull request?

We can't remove abbreviations, it would be a breaking change on parsing and should be done as part of #1200 , but we can safely add the new variations and we can also change which abbreviation is first in the list of abbreviations, which is used by ToString() by default.

angularsen added a commit that referenced this issue Jul 8, 2024
Fixes #1349

Search: (Abbreviations":.*?")([^"]*?)\/((?:[^"(]*?)·(?:[^")]*?))"
Replace: $1$2/($3)"
angularsen added a commit that referenced this issue Jul 8, 2024
Fixes #1349

Wrapping multiplications in denominators with parantheses to make it
more clear.
Leaving numerators alone.

Example: `lb/ft·s` => `lb/(ft·s)`

Search: `(Abbreviations":.*?")([^"]*?)\/((?:[^"(]*?)·(?:[^")]*?))"`
Replace: `$1$2/($3)"`
@angularsen
Copy link
Owner

Fixed by #1405

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants