Skip to main content

oxiphysics_materials/presets/
types.rs

1//! Auto-generated module
2//!
3//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
4
5#[allow(unused_imports)]
6use super::functions::*;
7#[allow(unused_imports)]
8use super::functions_2::*;
9use crate::Material;
10
11/// Extended material with full elastic constants.
12#[derive(Debug, Clone)]
13pub struct ExtendedMaterial {
14    /// Base material (density, friction, restitution).
15    pub base: Material,
16    /// Young's modulus (Pa).
17    pub young_modulus: f64,
18    /// Poisson's ratio.
19    pub poisson_ratio: f64,
20    /// Yield strength (Pa), 0 if not applicable.
21    pub yield_strength: f64,
22    /// Ultimate tensile strength (Pa), 0 if not applicable.
23    pub uts: f64,
24    /// Thermal conductivity (W/(m*K)).
25    pub thermal_conductivity: f64,
26    /// Specific heat capacity (J/(kg*K)).
27    pub specific_heat: f64,
28    /// Coefficient of thermal expansion (1/K).
29    pub thermal_expansion: f64,
30}
31impl ExtendedMaterial {
32    /// Create an extended material.
33    #[allow(clippy::too_many_arguments)]
34    pub fn new(
35        base: Material,
36        young_modulus: f64,
37        poisson_ratio: f64,
38        yield_strength: f64,
39        uts: f64,
40        thermal_conductivity: f64,
41        specific_heat: f64,
42        thermal_expansion: f64,
43    ) -> Self {
44        Self {
45            base,
46            young_modulus,
47            poisson_ratio,
48            yield_strength,
49            uts,
50            thermal_conductivity,
51            specific_heat,
52            thermal_expansion,
53        }
54    }
55    /// Bulk modulus K = E / (3*(1-2*nu)).
56    pub fn bulk_modulus(&self) -> f64 {
57        let nu = self.poisson_ratio;
58        self.young_modulus / (3.0 * (1.0 - 2.0 * nu))
59    }
60    /// Shear modulus G = E / (2*(1+nu)).
61    pub fn shear_modulus(&self) -> f64 {
62        let nu = self.poisson_ratio;
63        self.young_modulus / (2.0 * (1.0 + nu))
64    }
65    /// Specific stiffness E / rho (m^2/s^2).
66    pub fn specific_stiffness(&self) -> f64 {
67        self.young_modulus / self.base.density
68    }
69    /// Specific strength sigma_y / rho (m^2/s^2).
70    pub fn specific_strength(&self) -> f64 {
71        self.yield_strength / self.base.density
72    }
73    /// Thermal diffusivity k / (rho * cp) (m^2/s).
74    pub fn thermal_diffusivity(&self) -> f64 {
75        self.thermal_conductivity / (self.base.density * self.specific_heat)
76    }
77}
78/// Material category for filtering.
79#[derive(Debug, Clone, Copy, PartialEq)]
80pub enum MaterialCategory {
81    /// Metals and alloys.
82    Metal,
83    /// Polymers and plastics.
84    Polymer,
85    /// Ceramics.
86    Ceramic,
87    /// Composite materials.
88    Composite,
89    /// Biomaterials.
90    Biomaterial,
91    /// Building and construction materials.
92    Building,
93    /// Fluids (liquids and gases).
94    Fluid,
95    /// Sports equipment materials.
96    Sports,
97}
98/// A preset material with its category.
99pub struct CategorisedMaterial {
100    /// The material.
101    pub material: Material,
102    /// The category.
103    pub category: MaterialCategory,
104}