-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add atomic units of energy, mass, length, electric charge and current. #324
Add atomic units of energy, mass, length, electric charge and current. #324
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get very far in this review. Comments about using "elementary charge" which seems more common than "atomic units"? Especially since the 2019 redefinition which uses "elementary charge" to define the ampere.
I included a possible change that has both elementary charge and atomic unit of charge.
3771803
to
1a3d634
Compare
Thanks, completely agree with elementary charge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple more questions about some of the constants that seem to be used as units. Otherwise close to merging!
src/si/electric_charge.rs
Outdated
@@ -98,6 +102,8 @@ mod tests { | |||
test::<i::abampere, t::second, q::abcoulomb>(); | |||
test::<i::statampere, t::second, q::statcoulomb>(); | |||
|
|||
test::<i::atomic_unit_of_charge_per_second, t::second, q::atomic_unit_of_charge>(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github won't let me use the full context for the changes, so I had to paste a diff below.
Put the elementary charge and atomic unit of charge tests in the same order as the unit definitions. For elementary charge possibly use elementary charge per second (see electric current review) or fallback to atomic unit of charge per second.
diff --git a/src/si/electric_charge.rs b/src/si/electric_charge.rs
index c749ec6..ea7406b 100644
--- a/src/si/electric_charge.rs
+++ b/src/si/electric_charge.rs
@@ -98,12 +98,12 @@ mod tests {
test::<i::zeptoampere, t::second, q::zeptocoulomb>();
test::<i::yoctoampere, t::second, q::yoctocoulomb>();
+ test::<i::elementary_charge_per_second, t::second, q::elementary_charge>();
+ test::<i::atomic_unit_of_charge_per_second, t::second, q::atomic_unit_of_charge>();
test::<i::ampere, t::hour, q::ampere_hour>();
test::<i::abampere, t::second, q::abcoulomb>();
test::<i::statampere, t::second, q::statcoulomb>();
- test::<i::atomic_unit_of_charge_per_second, t::second, q::atomic_unit_of_charge>();
-
fn test<I: i::Conversion<V>, T: t::Conversion<V>, Q: q::Conversion<V>>() {
Test::assert_approx_eq(&ElectricCharge::new::<Q>(V::one()),
&(ElectricCurrent::new::<I>(V::one()) * Time::new::<T>(V::one())));
9d7f3a9
to
57f5d2a
Compare
Thanks a lot for these suggestions!
|
Co-authored-by: Mike Boutin <mike.boutin@gmail.com>
00110c9
to
072daec
Compare
Thanks so much for this PR! I just returned from vacation and will get back to working on the rest of your PRs. |
Thank you very much! I apologize for this heap of PRs, and hope it will help improving usability of this great library. Starting using uom, I found it extremely useful in protecting me from various errors, including using wrong dimension for a given quantity. Now I'm "dimensionalizing" all my computational scripts, adding PRs for the quantities and units that are missing. |
Adding