qualia_core_db/specialized_libs/engineering_analysis/
model.rs1use super::*;
2
3#[derive(Debug, Clone)]
5pub struct EngineeringPerformanceMetrics {
6 pub total_analyses: u64,
7 pub average_computation_time: f64,
8 pub average_accuracy: Option<f64>,
12 pub convergence_rate: Option<f64>,
13}
14
15#[derive(Debug, Clone)]
17pub struct EngineeringOperationResult<T> {
18 pub result: T,
19 pub execution_time: u64,
20 pub computational_cost: f64,
21 pub accuracy: Option<f64>,
24 pub convergence_info: ConvergenceInfo,
25}
26
27#[derive(Debug, Clone)]
29pub struct ConvergenceInfo {
30 pub converged: bool,
31 pub iterations: u32,
32 pub convergence_criterion: f64,
33 pub final_error: f64,
34}
35
36#[derive(Debug, Clone)]
38pub struct EngineeringModel {
39 pub model_id: String,
40 pub model_name: String,
41 pub model_type: ModelType,
42 pub geometry: Geometry,
43 pub materials: HashMap<String, Material>,
44 pub boundary_conditions: Vec<BoundaryCondition>,
45 pub loads: Vec<Load>,
46}
47
48#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
50pub enum ModelType {
51 Structural,
52 Mechanical,
53 Thermal,
54 Fluid,
55 Multiphysics,
56}
57
58#[derive(Debug, Clone)]
60pub struct Geometry {
61 pub geometry_type: GeometryType,
62 pub dimensions: Vec<f64>,
63 pub features: Vec<GeometricFeature>,
64}
65
66#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
68pub enum GeometryType {
69 Beam,
70 Plate,
71 Shell,
72 Solid,
73 Custom(String),
74}
75
76#[derive(Debug, Clone)]
78pub struct GeometricFeature {
79 pub feature_id: String,
80 pub feature_type: FeatureType,
81 pub feature_parameters: HashMap<String, f64>,
82}
83
84#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
86pub enum FeatureType {
87 Hole,
88 Fillet,
89 Chamfer,
90 Rib,
91}
92
93#[derive(Debug, Clone)]
95pub struct Material {
96 pub material_id: String,
97 pub material_name: String,
98 pub material_properties: MaterialProperties,
99}
100
101#[derive(Debug, Clone)]
103pub struct BoundaryCondition {
104 pub condition_id: String,
105 pub condition_type: BoundaryConditionType,
106 pub condition_value: f64,
107}
108
109#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
111pub enum BoundaryConditionType {
112 Fixed,
113 Pinned,
114 Roller,
115 Displacement,
116 Force,
117 Pressure,
118 Temperature,
119 HeatFlux,
120}
121
122#[derive(Debug, Clone)]
124pub struct Load {
125 pub load_id: String,
126 pub load_type: LoadType,
127 pub load_magnitude: f64,
128 pub load_direction: Vec<f64>,
129 pub application_point: Vec<f64>,
130}
131
132#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
134pub enum LoadDistributionType {
135 Point,
136 Distributed,
137 Moment,
138 Pressure,
139 Thermal,
140 Dynamic,
141}
142
143#[derive(Debug, Clone)]
145pub struct AnalysisResults {
146 pub results_id: String,
147 pub analysis_type: AnalysisType,
148 pub displacement_field: Vec<f64>,
149 pub stress_field: Vec<f64>,
150 pub strain_field: Vec<f64>,
151 pub reaction_forces: Vec<f64>,
152 pub safety_factor: f64,
153 pub temperature_field: Vec<f64>,
156 pub heat_flux_field: Vec<f64>,
159}
160impl EngineeringModel {
163 pub fn new() -> Self {
165 Self {
166 model_id: "model_1".to_string(),
167 model_name: "Test Model".to_string(),
168 model_type: ModelType::Structural,
169 geometry: Geometry::new(),
170 materials: HashMap::new(),
171 boundary_conditions: Vec::new(),
172 loads: Vec::new(),
173 }
174 }
175}
176
177impl Geometry {
178 pub fn new() -> Self {
180 Self {
181 geometry_type: GeometryType::Beam,
182 dimensions: vec![1.0, 0.1, 0.1],
183 features: Vec::new(),
184 }
185 }
186}
187
188impl GeometricFeature {
189 pub fn new() -> Self {
191 Self {
192 feature_id: "feature_1".to_string(),
193 feature_type: FeatureType::Hole,
194 feature_parameters: HashMap::new(),
195 }
196 }
197}
198
199impl Material {
200 pub fn new() -> Self {
202 Self {
203 material_id: "steel_1".to_string(),
204 material_name: "Steel".to_string(),
205 material_properties: MaterialProperties::new(),
206 }
207 }
208}
209
210impl MaterialProperties {
211 pub fn new() -> Self {
213 Self {
214 youngs_modulus: 200000.0,
215 poissons_ratio: 0.3,
216 density: 7850.0,
217 thermal_expansion: 12e-6,
218 thermal_conductivity: 50.0,
219 specific_heat: 500.0,
220 yield_strength: 250.0,
221 ultimate_strength: 400.0,
222 }
223 }
224}
225
226impl BoundaryCondition {
227 pub fn new() -> Self {
229 Self {
230 condition_id: "bc_1".to_string(),
231 condition_type: BoundaryConditionType::Fixed,
232 condition_value: 0.0,
233 }
234 }
235}
236
237impl Load {
238 pub fn new() -> Self {
240 Self {
241 load_id: "load_1".to_string(),
242 load_type: LoadType::Point,
243 load_magnitude: 1000.0,
244 load_direction: vec![0.0, -1.0, 0.0],
245 application_point: vec![1.0, 0.0, 0.0],
246 }
247 }
248}
249
250impl AnalysisResults {
251 pub fn new() -> Self {
253 Self {
254 results_id: "results_1".to_string(),
255 analysis_type: AnalysisType::LinearStatic,
256 displacement_field: Vec::new(),
257 stress_field: Vec::new(),
258 strain_field: Vec::new(),
259 reaction_forces: Vec::new(),
260 safety_factor: 0.0,
262 temperature_field: Vec::new(),
263 heat_flux_field: Vec::new(),
264 }
265 }
266}
267
268impl ReliabilityResults {
269 pub fn new() -> Self {
271 Self {
272 results_id: "reliability_1".to_string(),
273 reliability_index: 0.95,
274 failure_probability: 0.05,
275 mean_time_to_failure: 10000.0,
276 maintenance_interval: 30,
277 }
278 }
279}
280
281impl EngineeringPerformanceMetrics {
282 pub fn new() -> Self {
284 Self {
285 total_analyses: 0,
286 average_computation_time: 0.0,
287 average_accuracy: None,
288 convergence_rate: None,
289 }
290 }
291}