quantities/force.rs
1// ---------------------------------------------------------------------------
2// Copyright: (c) 2022 ff. Michael Amrhein (michael@adrhinum.de)
3// License: This program is part of a larger application. For license
4// details please read the file LICENSE.TXT provided together
5// with the application.
6// ---------------------------------------------------------------------------
7// $Source: src/force.rs $
8// $Revision: 2022-04-16T08:18:48+02:00 $
9
10//! Definition of derived quantity `Force`.
11
12use crate::{acceleration::Acceleration, mass::Mass, prelude::*};
13
14#[quantity(Mass * Acceleration)]
15#[ref_unit(Newton, "N", NONE, "Reference unit of quantity `Force`")]
16#[unit(Joule_per_Meter, "J/m", NONE, 1, "J/m")]
17/// Influence that can accelerate an object with mass.
18///
19/// Definition: Mass·Acceleration = Mass·Length/Duration²
20///
21/// Reference unit: Newton ('N' = 'kg·m/s²')
22///
23/// Predefined units:
24///
25/// | Symbol | Name | Definition | Equivalent in 'N' |
26/// |--------|-------------------------|-----------------|---------------------|
27/// | J/m | Joule per Meter | J/m | 1 |
28pub struct Force {}
29
30#[cfg(test)]
31mod tests {
32 use super::*;
33 use crate::{
34 acceleration::METER_PER_SECOND_SQUARED, assert_almost_eq, mass::GRAM,
35 };
36
37 #[test]
38 fn test_mass_mul_acceleration() {
39 let am = Amnt!(75.8);
40 let m = am * GRAM;
41 let aa: AmountT = Amnt!(9.4);
42 let a = aa * METER_PER_SECOND_SQUARED;
43 let f = m * a;
44 assert_almost_eq!(f.amount(), aa * am / Amnt!(1000.));
45 assert_eq!(f.unit(), NEWTON);
46 }
47}