1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/// module for classical thermodynamics and chemical equilibrium
/// handlers for different formats of thermodynamics and heat-mass transfer data
///
/// heat-mass transfer data agregator
/// # Examples 1
/// ```
/// use KiThe::Thermodynamics::DBhandlers::thermo_api::ThermoCalculator;
/// use KiThe::Thermodynamics::DBhandlers::transport_api::TransportCalculator;
/// use KiThe::Thermodynamics::User_substances::{CalculatorType, WhatIsFound};
/// use KiThe::Thermodynamics::User_substances::{DataType, LibraryPriority, SubsData};
/// use std::collections::HashMap;
/// // Create a new SubsData instance with test substances
/// let substances = vec!["CO".to_string(), "H2O".to_string()];
/// let mut user_subs = SubsData::new();
/// user_subs.substances = substances.clone();
///
/// // Set library priorities
/// user_subs.set_multiple_library_priorities(
/// vec!["NASA_gas".to_string()],
/// LibraryPriority::Priority,
/// );
/// user_subs.set_multiple_library_priorities(
/// vec!["Aramco_transport".to_string()],
/// LibraryPriority::Priority,
/// );
///
/// // Perform the search
/// user_subs.search_substances();
/// user_subs.extract_thermal_coeffs("CO", 400.0).unwrap();
/// user_subs.extract_thermal_coeffs("H2O", 400.0).unwrap();
///
/// // Test thermo calculations
/// let (cp, dh, ds) = user_subs.calculate_thermo_properties("CO", 400.0).unwrap();
/// println!("CO Thermo properties at 400K:");
/// println!("Cp: {}, dH: {}, dS: {}", cp, dh, ds);
/// let (cp, dh, ds) = user_subs.calculate_thermo_properties("H2O", 400.0).unwrap();
/// println!("H2O Thermo properties at 400K:");
/// println!("Cp: {}, dH: {}, dS: {}", cp, dh, ds);
/// let Cp = 33.8;
/// // Test transport calculations
/// println!("\n \n Transport properties:");
/// user_subs.set_M(
/// HashMap::from([("H2O".to_string(), 18.0), ("CO".to_string(), 32.0)]),
/// None,
/// );
/// user_subs.set_P(1e5, None);
/// user_subs
/// .extract_thermal_coeffs(substances[0].as_str(), 400.0)
/// .unwrap();
/// user_subs
/// .extract_thermal_coeffs(substances[1].as_str(), 400.0)
/// .unwrap();
/// let (lambda, viscosity) = user_subs
/// .calculate_transport_properties("H2O", 400.0, Some(Cp), None)
/// .unwrap();
/// println!("H2O Transport properties at 400K:");
/// println!("Lambda: {}, Viscosity: {}", lambda, viscosity);
/// // Test transport calculations
///
/// // Print full summary
/// user_subs.print_search_summary();
/// ```
/// heat-mass transfer data agregator
/// # Examples 2
/// ```
/// use KiThe::Thermodynamics::DBhandlers::thermo_api::ThermoCalculator;
/// use KiThe::Thermodynamics::DBhandlers::transport_api::TransportCalculator;
/// use KiThe::Thermodynamics::User_substances::{CalculatorType, WhatIsFound};
/// use KiThe::Thermodynamics::User_substances::{DataType, LibraryPriority, SubsData};
/// use std::collections::HashMap;
/// // Create a new SubsData instance with test substances
/// let substances = vec!["CO".to_string(), "H2O".to_string()];
/// let mut user_subs = SubsData::new();
/// user_subs.substances = substances;
///
/// // Set library priorities
/// user_subs.set_multiple_library_priorities(
/// vec!["NASA_gas".to_string()],
/// LibraryPriority::Priority,
/// );
/// user_subs.set_multiple_library_priorities(
/// vec!["Aramco_transport".to_string()],
/// LibraryPriority::Priority,
/// );
///
/// // Perform the search
/// user_subs.search_substances();
/// user_subs.extract_thermal_coeffs("CO", 400.0).unwrap();
/// user_subs.extract_thermal_coeffs("H2O", 400.0).unwrap();
/// // Print full summary
/// user_subs.print_search_summary();
/// let datamap = user_subs.get_substance_result("CO").unwrap();
/// let Thermo = datamap.get(&WhatIsFound::Thermo).unwrap().as_ref().unwrap();
/// let Calculator = Thermo.calculator.as_ref().unwrap();
/// let Cp;
/// match Calculator {
/// CalculatorType::Thermo(thermo) => {
/// // Test thermo calculations
/// let mut thermo = thermo.clone();
/// thermo.extract_model_coefficients(400.0).unwrap();
/// if let Ok(()) = thermo.calculate_Cp_dH_dS(400.0) {
/// let (cp, dh, ds) = (
/// thermo.get_Cp().unwrap(),
/// thermo.get_dh().unwrap(),
/// thermo.get_ds().unwrap(),
/// ); //thermo.get_Cp().unwrap();
/// println!("CO Thermo properties at 400K:");
/// println!("Cp: {}, dH: {}, dS: {}", cp, dh, ds);
/// Cp = cp;
/// assert!(cp > 0.0);
/// } else {
/// panic!("Failed to calculate CO properties");
/// }
/// }
/// _ => {
/// panic!("Failed to calculate CO properties");
/// }
/// }
/// let Transport = datamap
/// .get(&WhatIsFound::Transport)
/// .unwrap()
/// .as_ref()
/// .unwrap();
/// let Calculator = Transport.calculator.as_ref().unwrap();
/// match Calculator {
/// CalculatorType::Transport(transport) => {
/// // Test transport calculations
/// let mut transport = transport.clone();
/// let _ = transport.set_M(32.0, None);
/// let _ = transport.set_P(1e5, None);
/// transport.extract_coefficients(400.0).unwrap();
/// if let Ok(L) = transport.calculate_lambda(Some(Cp), None, 400.0) {
/// println!("CO Transport properties at 400K:");
/// println!("Lambda: {}", L);
/// assert!(L > 0.0);
/// } else {
/// panic!("Failed to calculate H2O properties");
/// }
/// }
/// _ => {
/// panic!("Failed to calculate CO properties");
/// }
/// }
/// user_subs.print_search_summary();
/// ```
/// Error handling for User_substances modules
/// Error handling tests
/// tests
/// main functionality to open thermodynamics and heat-mass transfer libraries
/// calculations of thermodynamic properties, creating closures and symbolic expressions
/// calculations of heat-mass transfer properties, creating closures and symbolic expressions