1use crate::material::Material;
7use crate::section::Section;
8use crate::section_properties::SectionProperties;
9
10#[derive(Debug, Clone, Copy, PartialEq)]
12pub enum FireExposure {
13 Standard,
15 Hydrocarbon,
17 External,
19 Parametric { opening_factor: f64, fire_load: f64 },
21}
22
23impl FireExposure {
24 pub fn temperature(&self, t_min: f64) -> f64 {
26 match self {
27 FireExposure::Standard => {
28 20.0 + 345.0 * (8.0 * t_min + 1.0).log10()
30 }
31 FireExposure::Hydrocarbon => {
32 20.0 + 1080.0
34 * (1.0 - 0.325 * (-0.167 * t_min).exp() - 0.675 * (-2.5 * t_min).exp())
35 }
36 FireExposure::External => {
37 20.0 + 660.0 * (1.0 - (-0.1 * t_min).exp())
39 }
40 FireExposure::Parametric {
41 opening_factor,
42 fire_load,
43 } => {
44 let t_eq = fire_load / (opening_factor * 1000.0); 20.0 + 345.0 * (8.0 * t_eq + 1.0).log10()
47 }
48 }
49 }
50}
51
52#[derive(Debug, Clone)]
54pub struct SectionFactor {
55 pub am_v: f64, pub am: f64, pub v: f64, pub shadow_factor: f64, pub box_protection: bool, }
61
62impl SectionFactor {
63 pub fn from_section(section: &Section, fire_exposure: FireExposure) -> Self {
65 let props = SectionProperties::from_section(section);
66 let v = props.area;
67
68 let am = match fire_exposure {
70 FireExposure::Standard | FireExposure::Hydrocarbon => {
71 section.heated_perimeter_3sided()
73 }
74 FireExposure::External => section.heated_perimeter_4sided(),
75 FireExposure::Parametric { .. } => section.heated_perimeter_4sided(),
76 };
77
78 let am_v = am / v;
79
80 let shadow_factor = section.shadow_factor();
82
83 Self {
84 am_v,
85 am,
86 v,
87 shadow_factor,
88 box_protection: false,
89 }
90 }
91
92 pub fn with_box_protection(mut self) -> Self {
94 self.box_protection = true;
95 self.shadow_factor = 1.0;
96 self
97 }
98
99 pub fn with_protection(
101 mut self,
102 thickness: f64,
103 conductivity: f64,
104 density: f64,
105 specific_heat: f64,
106 ) -> Self {
107 self.am_v =
108 self.am / self.v * (1.0 / (1.0 + thickness * conductivity / (density * specific_heat)));
109 self
110 }
111}
112
113#[derive(Debug, Clone)]
115pub struct TemperatureProfile {
116 pub time: f64, pub exposure: FireExposure,
118 pub temps: Vec<f64>, pub max_temp: f64,
120 pub avg_temp: f64,
121}
122
123impl TemperatureProfile {
124 pub fn uniform(temp: f64, time: f64, exposure: FireExposure) -> Self {
126 Self {
127 time,
128 exposure,
129 temps: vec![temp],
130 max_temp: temp,
131 avg_temp: temp,
132 }
133 }
134
135 pub fn from_heat_transfer(
137 _section: &Section,
138 _material: &Material,
139 _section_factor: &SectionFactor,
140 exposure: FireExposure,
141 time: f64,
142 _time_step: f64,
143 ) -> Self {
144 let t_g = match exposure {
148 FireExposure::Standard => 345.0 * (8.0 * time + 1.0).log10(),
149 _ => 20.0 + 660.0 * (1.0 - (-0.1 * time).exp()),
150 };
151
152 let temp = t_g * (1.0 - (-time / 30.0).exp()) + 20.0;
154
155 Self::uniform(temp, time, exposure)
156 }
157}
158
159#[derive(Debug, Clone)]
161pub struct MaterialPropertiesAtTemp {
162 pub temperature: f64,
163 pub ky: f64, pub kp: f64, pub ke: f64, pub thermal_elongation: f64,
167}
168
169impl MaterialPropertiesAtTemp {
170 pub fn carbon_steel(temp: f64) -> Self {
172 let (ky, kp, ke) = if temp <= 100.0 {
173 (1.0, 1.0, 1.0)
174 } else if temp <= 200.0 {
175 (1.0, 0.81, 0.9)
176 } else if temp <= 300.0 {
177 (1.0, 0.61, 0.8)
178 } else if temp <= 400.0 {
179 (1.0, 0.42, 0.7)
180 } else if temp <= 500.0 {
181 (0.78, 0.31, 0.6)
182 } else if temp <= 600.0 {
183 (0.47, 0.13, 0.31)
184 } else if temp <= 700.0 {
185 (0.23, 0.09, 0.13)
186 } else if temp <= 800.0 {
187 (0.11, 0.07, 0.09)
188 } else if temp <= 900.0 {
189 (0.06, 0.05, 0.07)
190 } else if temp <= 1000.0 {
191 (0.04, 0.04, 0.05)
192 } else {
193 (0.02, 0.02, 0.03)
194 };
195
196 let thermal_elongation = if temp <= 750.0 {
197 1.2e-5 * temp + 0.4e-8 * temp * temp - 2.416e-4
198 } else {
199 1.1e-2
200 };
201
202 Self {
203 temperature: temp,
204 ky,
205 kp,
206 ke,
207 thermal_elongation,
208 }
209 }
210
211 pub fn stainless_steel(temp: f64) -> Self {
213 let ky = if temp <= 100.0 {
215 1.0
216 } else if temp <= 500.0 {
217 0.8
218 } else if temp <= 700.0 {
219 0.5
220 } else {
221 0.2
222 };
223 let kp = if temp <= 100.0 {
224 1.0
225 } else if temp <= 500.0 {
226 0.6
227 } else if temp <= 700.0 {
228 0.3
229 } else {
230 0.1
231 };
232 let ke = if temp <= 100.0 {
233 1.0
234 } else if temp <= 500.0 {
235 0.8
236 } else if temp <= 700.0 {
237 0.4
238 } else {
239 0.2
240 };
241
242 Self {
243 temperature: temp,
244 ky,
245 kp,
246 ke,
247 thermal_elongation: 0.0,
248 }
249 }
250
251 pub fn concrete(temp: f64, _fc20: f64) -> Self {
253 let kc = if temp <= 100.0 {
254 1.0
255 } else if temp <= 200.0 {
256 0.95
257 } else if temp <= 400.0 {
258 0.75
259 } else if temp <= 600.0 {
260 0.45
261 } else if temp <= 800.0 {
262 0.25
263 } else {
264 0.1
265 };
266
267 Self {
268 temperature: temp,
269 ky: kc,
270 kp: kc,
271 ke: kc,
272 thermal_elongation: 0.0,
273 }
274 }
275}
276
277#[derive(Debug, Clone, Copy, PartialEq)]
279pub enum FireDesignMethod {
280 Simple,
282 Advanced,
284 Tabulated,
286}
287
288#[derive(Debug, Clone)]
290pub struct FireAnalysis {
291 pub section: Section,
292 pub material: Material,
293 pub exposure: FireExposure,
294 pub method: FireDesignMethod,
295 pub fire_protection: Option<FireProtection>,
296 pub critical_temp: Option<f64>,
297}
298
299#[derive(Debug, Clone)]
301pub struct FireProtection {
302 pub protection_type: ProtectionType,
303 pub thickness: f64, pub conductivity: f64, pub density: f64, pub specific_heat: f64, pub moisture_content: f64, }
309
310#[derive(Debug, Clone, Copy, PartialEq)]
311pub enum ProtectionType {
312 None,
313 Intumescent,
314 Board,
315 Spray,
316 ConcreteEncasement,
317 HollowFilled, }
319
320impl FireAnalysis {
321 pub fn new(section: Section, material: Material) -> Self {
322 Self {
323 section,
324 material,
325 exposure: FireExposure::Standard,
326 method: FireDesignMethod::Simple,
327 fire_protection: None,
328 critical_temp: None,
329 }
330 }
331
332 pub fn with_exposure(mut self, exposure: FireExposure) -> Self {
333 self.exposure = exposure;
334 self
335 }
336
337 pub fn with_method(mut self, method: FireDesignMethod) -> Self {
338 self.method = method;
339 self
340 }
341
342 pub fn with_protection(mut self, protection: FireProtection) -> Self {
343 self.fire_protection = Some(protection);
344 self
345 }
346
347 pub fn section_factor(&self) -> SectionFactor {
349 SectionFactor::from_section(&self.section, self.exposure)
350 }
351
352 pub fn critical_temperature(&self, load_ratio: f64) -> f64 {
354 if load_ratio <= 0.01 {
356 return 20.0;
357 }
358 if load_ratio >= 1.0 {
359 return 1200.0;
360 }
361
362 let mu0 = load_ratio;
365 39.19 * (1.0 / (0.9674 * mu0.powf(3.833))).ln() + 482.0
366 }
367
368 pub fn fire_resistance_time(&self, load_ratio: f64) -> f64 {
370 let theta_cr = self.critical_temperature(load_ratio);
371 let section_factor = self.section_factor();
372
373 if let Some(prot) = &self.fire_protection {
375 return self.protected_time(theta_cr, section_factor, prot);
376 }
377
378 self.unprotected_time(theta_cr, section_factor)
380 }
381
382 fn unprotected_time(&self, theta_cr: f64, sf: SectionFactor) -> f64 {
383 let dt = 1.0 / 60.0; let mut t = 0.0;
386 let mut theta_a = 20.0;
387
388 while theta_a < theta_cr && t < 300.0 {
389 let theta_g = self.exposure.temperature(t); let h_net = 25.0; let rho_a = 7850.0; let c_a = 600.0; let dtheta = h_net * sf.am_v / (rho_a * c_a) * (theta_g - theta_a) * dt * 60.0;
401 theta_a += dtheta;
402 t += dt;
403 }
404
405 t }
407
408 fn protected_time(&self, theta_cr: f64, sf: SectionFactor, prot: &FireProtection) -> f64 {
409 let dt = 1.0 / 60.0;
411 let mut t = 0.0;
412 let mut theta_a = 20.0;
413 let mut theta_p = 20.0; let rho_p = prot.density;
416 let c_p = prot.specific_heat;
417 let lambda_p = prot.conductivity;
418 let d_p = prot.thickness;
419
420 while theta_a < theta_cr && t < 300.0 {
421 let theta_g = self.exposure.temperature(t / 60.0);
422
423 let h_net = 25.0;
425 let phi = h_net * (theta_g - theta_p) / (1.0 + lambda_p / (h_net * d_p));
426
427 let dtheta_p = phi / (rho_p * c_p * d_p) * dt * 60.0;
429 theta_p += dtheta_p;
430
431 let rho_a = 7850.0;
433 let c_a = 600.0;
434 let dtheta_a = phi / (rho_a * c_a * sf.v) * dt * 60.0;
435 theta_a += dtheta_a;
436
437 t += dt;
438 }
439
440 t * 60.0
441 }
442
443 pub fn resistance_at_time(&self, t_min: f64, load_ratio: f64) -> FireResistanceResult {
445 let theta_cr = self.critical_temperature(load_ratio);
446 let theta_g = self.exposure.temperature(t_min);
447 let section_factor = self.section_factor();
448
449 let temp_profile = TemperatureProfile::from_heat_transfer(
451 &self.section,
452 &self.material,
453 §ion_factor,
454 self.exposure,
455 t_min,
456 1.0,
457 );
458
459 let theta_a = temp_profile.avg_temp;
460 let mat_props = MaterialPropertiesAtTemp::carbon_steel(theta_a);
461
462 let fy_theta = self.material.yield_strength * mat_props.ky;
464 let e_theta = self.material.youngs_modulus * mat_props.ke;
465
466 let props = SectionProperties::from_section(&self.section);
468
469 let m_rd_theta = props.ix / props.max_fiber_distance_y() * fy_theta;
471
472 let n_rd_theta = props.area * fy_theta;
474
475 let utilization = if load_ratio > 0.0 {
477 (theta_a - 20.0) / (theta_cr - 20.0)
478 } else {
479 0.0
480 };
481
482 FireResistanceResult {
483 time: t_min,
484 section_temp: theta_a,
485 gas_temp: theta_g,
486 fy_reduced: fy_theta,
487 e_reduced: e_theta,
488 moment_capacity: m_rd_theta,
489 axial_capacity: n_rd_theta,
490 utilization,
491 passed: utilization <= 1.0,
492 }
493 }
494}
495
496#[derive(Debug, Clone)]
498pub struct FireResistanceResult {
499 pub time: f64, pub section_temp: f64, pub gas_temp: f64, pub fy_reduced: f64, pub e_reduced: f64, pub moment_capacity: f64, pub axial_capacity: f64, pub utilization: f64, pub passed: bool, }
509
510pub mod composite {
512 use super::*;
513 use crate::material::Material;
514 use crate::section::Section;
515
516 pub struct CFTFireAnalysis {
518 pub steel_section: Section,
519 pub concrete_section: Section,
520 pub steel_material: Material,
521 pub concrete_material: Material,
522 pub exposure: FireExposure,
523 pub reinforcement: Option<Reinforcement>,
524 }
525
526 #[derive(Debug, Clone)]
527 pub struct Reinforcement {
528 pub area: f64,
529 pub distance_from_center: f64,
530 pub material: Material,
531 }
532
533 impl CFTFireAnalysis {
534 pub fn new(
535 steel: Section,
536 concrete: Section,
537 steel_mat: Material,
538 conc_mat: Material,
539 ) -> Self {
540 Self {
541 steel_section: steel,
542 concrete_section: concrete,
543 steel_material: steel_mat,
544 concrete_material: conc_mat,
545 exposure: FireExposure::Standard,
546 reinforcement: None,
547 }
548 }
549
550 pub fn fire_resistance(&self, n_ed: f64, m_ed: f64) -> FireResistanceResult {
552 let section_factor = SectionFactor::from_section(&self.steel_section, self.exposure);
556 let theta_cr = self.critical_temperature_composite(n_ed);
557
558 let t_fi = self.unprotected_time(theta_cr, section_factor);
560
561 FireResistanceResult {
562 time: t_fi,
563 section_temp: theta_cr,
564 gas_temp: self.exposure.temperature(t_fi / 60.0),
565 fy_reduced: self.steel_material.yield_strength * 0.5, e_reduced: self.steel_material.youngs_modulus * 0.5,
567 moment_capacity: m_ed, axial_capacity: n_ed,
569 utilization: 1.0,
570 passed: t_fi >= 30.0, }
572 }
573
574 fn critical_temperature_composite(&self, _n_ed: f64) -> f64 {
575 550.0
578 }
579
580 fn unprotected_time(&self, theta_cr: f64, sf: SectionFactor) -> f64 {
581 let dt = 1.0 / 60.0;
582 let mut t = 0.0;
583 let mut theta_a = 20.0;
584
585 while theta_a < theta_cr && t < 300.0 {
586 let theta_g = self.exposure.temperature(t / 60.0);
587 let h_net = 25.0;
588 let rho_a = 7850.0;
589 let c_a = 600.0;
590 let dtheta = h_net * sf.am_v / (rho_a * c_a) * (theta_g - theta_a) * dt * 60.0;
591 theta_a += dtheta;
592 t += dt;
593 }
594 t * 60.0
595 }
596 }
597}
598
599trait SectionFireProps {
600 fn heated_perimeter_3sided(&self) -> f64;
601 fn heated_perimeter_4sided(&self) -> f64;
602 fn shadow_factor(&self) -> f64;
603}
604
605impl SectionFireProps for Section {
606 fn heated_perimeter_3sided(&self) -> f64 {
607 let bounds = self.bounds();
609 let h = bounds.3 - bounds.2; let mut perimeter = 0.0;
612
613 for i in 0..self.outer.vertices.len() {
614 let v1 = self.outer.vertices[i];
615 let v2 = self.outer.vertices[(i + 1) % self.outer.vertices.len()];
616
617 let mid_y = (v1.y + v2.y) / 2.0;
618 if mid_y > bounds.2 + 0.01 * h {
619 let dx = v2.x - v1.x;
620 let dy = v2.y - v1.y;
621 perimeter += (dx * dx + dy * dy).sqrt();
622 }
623 }
624
625 perimeter.max(0.01)
626 }
627
628 fn heated_perimeter_4sided(&self) -> f64 {
629 let mut perimeter = 0.0;
630
631 for i in 0..self.outer.vertices.len() {
632 let v1 = self.outer.vertices[i];
633 let v2 = self.outer.vertices[(i + 1) % self.outer.vertices.len()];
634 let dx = v2.x - v1.x;
635 let dy = v2.y - v1.y;
636 perimeter += (dx * dx + dy * dy).sqrt();
637 }
638
639 perimeter
640 }
641
642 fn shadow_factor(&self) -> f64 {
643 let bounds = self.bounds();
646 let h = bounds.3 - bounds.2;
647 let b = bounds.1 - bounds.0;
648
649 if h > b * 2.0 {
650 0.9
652 } else {
653 1.0
654 }
655 }
656}
657
658#[cfg(test)]
659mod tests {
660 use super::*;
661
662 use crate::material::presets::STEEL_S355;
663
664 use crate::section_library::ParametricSection;
665
666 #[test]
667 fn section_factor_i_section() {
668 let i = crate::section_library::steel::ISection::from_designation("IPE300").unwrap();
669 let section = i.build();
670
671 let sf = SectionFactor::from_section(§ion, FireExposure::Standard);
672
673 assert!(sf.am_v > 0.0);
674 assert!(sf.am > 0.0);
675 assert!(sf.v > 0.0);
676 }
677
678 #[test]
679 fn section_factor_hollow() {
680 let rhs = crate::section_library::steel::RectangularHollowSection::new(
681 0.2, 0.1, 0.005, 0.008, 0.003,
682 );
683 let section = rhs.build();
684
685 let sf = SectionFactor::from_section(§ion, FireExposure::Standard);
686
687 assert!(sf.am_v < 300.0);
689 }
690
691 #[test]
692 fn critical_temperature() {
693 let i = crate::section_library::steel::ISection::from_designation("IPE300").unwrap();
694 let section = i.build();
695
696 let analysis = FireAnalysis::new(section, STEEL_S355);
697
698 let theta_cr_low = analysis.critical_temperature(0.1);
700 let theta_cr_high = analysis.critical_temperature(0.7);
701
702 assert!(theta_cr_low > theta_cr_high);
703 assert!(theta_cr_low > 600.0);
704 assert!(theta_cr_high < 600.0);
705 }
706
707 #[test]
708 fn fire_resistance_time() {
709 let i = crate::section_library::steel::ISection::from_designation("IPE300").unwrap();
710 let section = i.build();
711
712 let analysis = FireAnalysis::new(section, STEEL_S355);
713 let t_fi = analysis.fire_resistance_time(0.5);
714
715 assert!(t_fi > 10.0);
717 assert!(t_fi < 60.0);
718 }
719
720 #[test]
721 fn fire_protection() {
722 let i = crate::section_library::steel::ISection::from_designation("IPE300").unwrap();
723 let section = i.build();
724
725 let protection = FireProtection {
726 protection_type: ProtectionType::Board,
727 thickness: 0.02, conductivity: 0.2,
729 density: 800.0,
730 specific_heat: 1000.0,
731 moisture_content: 0.0,
732 };
733
734 let analysis = FireAnalysis::new(section, STEEL_S355).with_protection(protection);
735 let t_fi = analysis.fire_resistance_time(0.5);
736
737 assert!(t_fi > 45.0);
739 }
740
741 #[test]
742 fn material_props_at_temp() {
743 let props_20 = MaterialPropertiesAtTemp::carbon_steel(20.0);
744 assert_eq!(props_20.ky, 1.0);
745 assert_eq!(props_20.ke, 1.0);
746
747 let props_600 = MaterialPropertiesAtTemp::carbon_steel(600.0);
748 assert!(props_600.ky < 0.5);
749 assert!(props_600.ke < 0.5);
750 }
751
752 #[test]
753 fn concrete_material_props() {
754 let props = MaterialPropertiesAtTemp::concrete(400.0, 30e6);
755 assert!(props.ky < 1.0 && props.ky > 0.0);
756 }
757
758 #[test]
759 fn composite_column() {
760 let steel = crate::section_library::steel::CircularHollowSectionLib::new(0.219, 0.008);
761 let concrete = crate::section_library::concrete::CircularConcreteSection::new(0.203);
762
763 let cft = composite::CFTFireAnalysis::new(
764 steel.build(),
765 concrete.build(),
766 STEEL_S355,
767 crate::material::presets::CONCRETE_C30_37,
768 );
769
770 let result = cft.fire_resistance(500e3, 10e3);
771 assert!(result.time > 0.0);
772 }
773
774 #[test]
775 fn shadow_factor_i_section_depth_gt_2x_width() {
776 let i = crate::section_library::steel::ISection::new(0.3, 0.1, 0.008, 0.01, 0.012);
780 let section = i.build();
781 let sf = section.shadow_factor();
782 assert!(
783 (sf - 0.9).abs() < 1e-10,
784 "shadow_factor should be 0.9 for I-section with depth > 2*width, got {}",
785 sf
786 );
787 }
788}