Skip to content

Use a proper expression parser for unit conversions #154

@Luthaf

Description

@Luthaf

Currently, only units explicitly defined in the code are supported for models inputs and outputs. This is starting to be problematic, and will become more and more problematic as we increase the number of supported outputs and supported units.

We should replace the current unit_conversion_factor(quantity, from_unit, to_unit) function with just unit_conversion_factor(from_unit, to_unit). The function would then parse the unit expressions to make sure both units have the same dimensionality, and return the conversion factor between them.

I have an example of unit parsing code here https://github.com/lumol-org/lumol/blob/master/lumol-core/src/units.rs that we could re-use pretty easily.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions