-
Notifications
You must be signed in to change notification settings - Fork 26
Support for selected unit product and ratio in quantity library #52
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
base: develop
Are you sure you want to change the base?
Support for selected unit product and ratio in quantity library #52
Conversation
…ities. They provide direct information about the base unit of a quantity, interval, point or unit.
…rent value type Idiomatically mean to explicitly allow for narrowing assignments (e.g. by explicitly converting a double-based quantity intoa float-based one before assignment).
…ects Allows multiplicative math between two quantity objects (for example a millivolt quantity could be divided by a kiloohm one, resulting into a microampere one). Only binary operations are supported (e.g. no N/m/m = Pa). Each quantity relation needs to be explicitly enabled.
Also introduced a unit test for them, and some relations among them and optionally (when all relevant headers are included) relation RC = t.
Added support of product of quantities resulting into a scalar.
It now accepts extended units (e.g. "millisecond") too.
|
A new Pull Request was created by @PetrilloAtWork (Gianluca Petrillo) for develop. It involves the following packages: lardataalg @LArSoft/level-2-managers, @LArSoft/level-1-managers can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
|
The code-checks are being triggered in jenkins. |
|
+code-checks |
|
@PetrilloAtWork, is there an intention for the units to be used within LArSoft itself and not just ICARUS (or SBN)? |
|
I haven't been aware of any people intending to use them, part of the problem being that people don't know about them. |
|
Pull request #52 was updated. @LArSoft/level-1-managers, @LArSoft/level-2-managers can you please check and sign again. |
|
The code-checks are being triggered in jenkins. |
|
+code-checks |
This PR contains an update of the quantity library in
lardataalg.The quantity library supports the creation of data types bound to a measure unit (e.g.
Second) and handles scale conversions and consistency (for example, it is not allowed to add a pure number to autil::quantities::millisecondvariable, and addition has severe restrictions). Including extensions in FHiCL parsing, it allows consistent variable dimensions from configuration to the inner code.This PR allows the definition of operations between quantities with two different units, enabling math like the ratio of a voltage by a current (to yield a resistance type) or the product of a frequency and a time (yielding a pure number). Only quantity types are currently supported: point and interval types from this library are not (because I haven't gone through the thinking needed to understand what is correct and what not in that case).
Relationship between units must be explicitly declared.
Parsing is extended so that full unit names can be used in configuration (e.g.
"5 millisecond"is now equivalent to"5 ms").In addition, new quantities are added to
electromagnetism.h, based onOhm,AmpereandFarad. Added relations areOhm×Ampere(Volt) andFarad×Volt(Coulomb).Inter-header quantities relations are declared in both involved headers, conditionally to the fact that both headers are included by the user (e.g. to use the frequency × time operation, both
spacetime.handfrequency.hneed to be included; butauto f = 1 / 2_mswill fail iffrequency.his not loaded).Unit tests exercising the new features and units are included, and Doxygen documentation is updated.
These features are going to be used in some of the ICARUS electronics simulation code currently in development.
Breaking change:
util::quantities::concepts::details::is_quantity_vhas been promoted to interface (util::quantities::concepts::is_quantity_v). This should not be an issue since normally user code does not dip fingers intodetailsnamespaces;lardataalgcode is updated to reflect the change.This code was developed and is based on version 10.00.06 (LArSoft
v10_06_00).