unitforge/quantities/
stress_squared.rs

1use crate::impl_macros::macros::*;
2use crate::prelude::*;
3use ndarray::{Array1, Array2, ArrayView1, ArrayView2};
4use num_traits::identities::Zero;
5use num_traits::FromPrimitive;
6#[cfg(feature = "pyo3")]
7use pyo3::pyclass;
8#[cfg(feature = "serde")]
9use serde::{Deserialize, Serialize};
10use std::cmp::Ordering;
11use std::fmt;
12use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
13#[cfg(feature = "strum")]
14use strum_macros::EnumIter;
15
16#[cfg_attr(feature = "strum", derive(EnumIter))]
17#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18#[derive(Copy, Clone, PartialEq, Debug)]
19#[cfg_attr(feature = "pyo3", pyclass(eq, eq_int))]
20pub enum StressSquaredUnit {
21    Nsq_mmhc,
22}
23
24impl PhysicsUnit for StressSquaredUnit {
25    fn name(&self) -> &str {
26        match &self {
27            StressSquaredUnit::Nsq_mmhc => "N²/m⁴",
28        }
29    }
30
31    fn base_per_x(&self) -> (f64, i32) {
32        match self {
33            StressSquaredUnit::Nsq_mmhc => (1., 0),
34        }
35    }
36}
37
38impl_quantity!(
39    StressSquared,
40    StressSquaredUnit,
41    [StressSquaredUnit::Nsq_mmhc]
42);
43impl_div_with_self_to_f64!(StressSquared);