//! Physics parameters for MRE tissue modeling use serde::{Deserialize, Serialize}; use std::f32::consts::PI; /// Physical properties of tissue for MRE simulation #[derive(Debug, Clone, Copy, Serialize, Deserialize)] pub struct TissueProperties { /// Tissue density in kg/m^3 /// Typical soft tissue: ~1000 kg/m^3 pub density: f32, /// Mechanical excitation frequency in Hz /// Typical MRE frequencies: 50-200 Hz pub excitation_frequency_hz: f32, } impl TissueProperties { /// Create properties for soft tissue at standard MRE frequency #[must_use] pub fn soft_tissue() -> Self { Self { density: 1000.0, // kg/m^3, similar to water excitation_frequency_hz: 60.0, // Hz, common MRE frequency } } /// Create properties for liver tissue #[must_use] pub fn liver() -> Self { Self { density: 1050.0, // Slightly denser than water excitation_frequency_hz: 60.0, } } /// Get angular frequency omega = 2*pi*f #[must_use] pub fn omega(&self) -> f32 { 2.0 * PI * self.excitation_frequency_hz } /// Get omega squared (commonly used in Helmholtz equation) #[must_use] pub fn omega_squared(&self) -> f32 { let omega = self.omega(); omega * omega } /// Calculate wavelength in tissue with given stiffness /// lambda = sqrt(mu/rho) / f #[must_use] pub fn wavelength(&self, stiffness_pa: f32) -> f32 { let shear_velocity = (stiffness_pa / self.density).sqrt(); shear_velocity / self.excitation_frequency_hz } /// Calculate wavenumber k = omega * sqrt(rho/mu) #[must_use] pub fn wavenumber(&self, stiffness_pa: f32) -> f32 { self.omega() * (self.density / stiffness_pa).sqrt() } } impl Default for TissueProperties { fn default() -> Self { Self::soft_tissue() } } #[cfg(test)] mod tests { use super::*; #[test] fn test_omega() { let tissue = TissueProperties::soft_tissue(); let expected = 2.0 * PI * 60.0; assert!((tissue.omega() - expected).abs() < 1e-6); } #[test] fn test_wavelength() { let tissue = TissueProperties { density: 1000.0, excitation_frequency_hz: 60.0, }; // For mu = 3600 Pa: v = sqrt(3600/1000) = 1.897 m/s // lambda = 1.897 / 60 = 0.0316 m let lambda = tissue.wavelength(3600.0); assert!((lambda - 0.0316).abs() < 0.001); } }