diff options
| author | sam-anthony <samanthony6@protonmail.com> | 2022-01-15 20:31:04 -0330 |
|---|---|---|
| committer | sam-anthony <samanthony6@protonmail.com> | 2022-01-15 20:31:04 -0330 |
| commit | ef3980225a0a0ed5bea0d748709c1f227e33c851 (patch) | |
| tree | eafe6e82c02224ea62b5c7acdf75ae2fd93f2187 /src/flow_rate.rs | |
| download | volute-ef3980225a0a0ed5bea0d748709c1f227e33c851.zip | |
units of measurement
Diffstat (limited to 'src/flow_rate.rs')
| -rw-r--r-- | src/flow_rate.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/flow_rate.rs b/src/flow_rate.rs new file mode 100644 index 0000000..f8e15e0 --- /dev/null +++ b/src/flow_rate.rs @@ -0,0 +1,32 @@ +use crate::{mass::Mass, volume::Volume}; +use std::time::Duration; + +pub struct MassFlowRate { + pub mass: Mass, + pub duration: Duration, +} + +impl MassFlowRate { + pub fn as_kilograms_per_minute(&self) -> f64 { + self.mass.as_kilograms() / (self.duration.as_secs() as f64 / 60.) + } + + pub fn as_pounds_per_minute(&self) -> f64 { + self.mass.as_pounds() / (self.duration.as_secs() as f64 / 60.) + } +} + +pub struct VolumetricFlowRate { + pub volume: Volume, + pub duration: Duration, +} + +impl VolumetricFlowRate { + pub fn as_cubic_metres_per_second(&self) -> f64 { + self.volume.as_cubic_metres() / self.duration.as_secs() as f64 + } + + pub fn as_cubic_feet_per_minute(&self) -> f64 { + self.volume.as_cubic_feet() / (self.duration.as_secs() as f64 / 60.) + } +} |