Skip to content

Commit 39ba4d2

Browse files
committed
fixed warnings
1 parent 92e0a82 commit 39ba4d2

6 files changed

Lines changed: 43 additions & 24 deletions

File tree

oscps-lib/src/blocks.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@
77
//! MassBalance trait but not the EnergyBalance.
88
//!
99
10-
11-
use uom::si::f64::{Energy};
12-
use uom::si::f64::{Mass};
10+
use uom::si::f64::Energy;
11+
use uom::si::f64::Mass;
1312
use uom::si::mass::kilogram;
1413
use uom::si::energy::joule;
15-
use crate::component::ChemicalIdentifier;
16-
use crate::{component, connector};
14+
use crate::connector;
1715
use once_cell::sync::Lazy;
1816

1917
//Initiallizing a global variable for the tolerance for the energy balance
18+
#[allow(dead_code)]
2019
static TOLERENCE_ENERGY: Lazy<Energy> = Lazy::new(|| Energy::new::<joule>(5.0));
2120

2221
//Initiallizing a global variable for the tolerance for the mass balance
22+
#[allow(dead_code)]
2323
static TOLERENCE_MASS: Lazy<Mass> = Lazy::new(|| Mass::new::<kilogram>(5.0));
2424

2525
//Initiallizing a global variable for the tolerance for the element balance
2626

2727
/// Trait for ensuring the overall mass balance is maintained in a flowsheet.
2828
///
2929
/// This trait can be implemented by any block that needs to ensure mass conservation.
30+
#[allow(dead_code)]
3031
pub trait MassBalance {
3132
// total mass in - total mass out < tolerance
3233
fn mass_balance_check(&self, mass_in : Mass, mass_out : Mass) -> bool {
@@ -44,6 +45,7 @@ pub trait MassBalance {
4445
/// This trait ensures that blocks in the flowsheet adhere to energy conservation principles.
4546
///
4647
/// This is useful for distinguishing between "dynamic" and "steady state" simulations.
48+
#[allow(dead_code)]
4749
pub trait EnergyBalance {
4850

4951
// total energy in - total energy out < tolerance
@@ -63,12 +65,12 @@ pub trait EnergyBalance {
6365
}
6466
}
6567

66-
6768
/// # Mixer Block
6869
///
6970
/// A block used for simple stream mixing operations.
7071
///
7172
/// This struct requires the implementation of both EnergyBalance and MassBalance traits to ensure proper conservation principles are followed.
73+
#[allow(dead_code)]
7274
pub struct Mixer {
7375
pub block_id : String,
7476
pub x_cord : i32,
@@ -86,12 +88,13 @@ impl MassBalance for Mixer {}
8688
// Applying the energy balance trait to the Mixer Block
8789
impl EnergyBalance for Mixer {}
8890

91+
#[allow(dead_code)]
8992
impl Mixer {
9093
pub fn new(id : String, x_cord : i32, y_cord : i32, in_streams_mass : Vec<connector::Mconnector>, in_streams_energy : Vec<connector::Econnector>) -> Mixer {
9194
return Mixer {
9295
block_id : id,
93-
x_cord : x_cord,
94-
y_cord : y_cord,
96+
x_cord,
97+
y_cord,
9598
input_streams_mass : in_streams_mass,
9699
input_streams_energy : in_streams_energy,
97100
outlet_stream_mass : None,
@@ -115,7 +118,7 @@ impl Mixer {
115118
///
116119
/// A Mass quantity (uom object) that holds the outlet mass flow
117120
fn compute_total_outlet_mass_flow(&self) -> Option<f64> {
118-
// steps to implement function:
121+
// TODO: steps to implement function:
119122
// Need to loop through each of the connector structures and add up the mass flows
120123
// During this process, need to make sure that all the mass flows are in the same units
121124
// Use the UOM package to help with this part...
@@ -138,7 +141,6 @@ impl Mixer {
138141
return Some(energy_flow_sum);
139142
}
140143

141-
142144
fn compute_outlet_phase_fractions(&self) {
143145

144146
}
@@ -158,7 +160,7 @@ mod block_tests {
158160
use crate::connector::{Mconnector, Econnector};
159161

160162
use super::*;
161-
use std::io;
163+
// use std::io;
162164
use uom::si::f64::Energy;
163165
use uom::si::energy::kilojoule;
164166
use uom::si::mass::pound;

oscps-lib/src/component.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
//! # Component
2-
32
extern crate uom;
43

54
extern crate pubchem;
65
use anyhow::Result;
76

87
/// This will hold the list of chemicals used within the simulation
8+
#[allow(dead_code)]
99
pub struct ChemicalList {
1010
chemical_list : Vec<pubchem::Compound>
1111
}
1212

13-
14-
1513
/// A struct to store information regarding the chemical properties of a particular substance.
1614
/// The "Chemical" struct is a wrapper for the pubchem::Compound object
15+
#[allow(dead_code)]
1716
pub struct Chemical {
1817
/// The (PubChem)[https://pubchem.ncbi.nlm.nih.gov/] CID of a compound.
1918
pub pubchem_obj : pubchem::Compound,
@@ -22,11 +21,13 @@ pub struct Chemical {
2221

2322
/// This enum will be used by the "Chemical" struct to create the pubchem::Compound obj based on
2423
/// either the chemical name or the pubchem id of the chemical
24+
#[allow(dead_code)]
2525
pub enum ChemicalIdentifier {
2626
PubchemID(u32),
2727
CompoundName(String),
2828
}
2929

30+
#[allow(dead_code)]
3031
impl Chemical {
3132

3233
/// constructor
@@ -60,6 +61,7 @@ impl Chemical {
6061
}
6162
}
6263

64+
#[allow(dead_code)]
6365
pub struct ChemicalProperties {
6466
pub molar_mass: f64, // kg/mol
6567
pub critical_temp: f64, // K
@@ -80,11 +82,9 @@ impl ChemicalProperties {
8082

8183
}
8284

83-
8485
#[cfg(test)]
8586
mod chemical_species_tests {
8687
use crate::component::{Chemical,ChemicalIdentifier};
87-
use std::io;
8888

8989
#[test]
9090
fn test_create_chemical_from_pubchem_id() {

oscps-lib/src/connector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
//!here we will have 2 connector structs
22
//!- Mass Streams
33
//!- Energy Streams
4+
#[allow(dead_code)]
45
pub struct Mconnector{
56
pub m_conn_id: String,
67
pub m_flow_total: f64
78
}
89

10+
#[allow(dead_code)]
911
impl Mconnector {
1012

1113
pub fn new(id : String) -> Mconnector {
@@ -16,15 +18,13 @@ impl Mconnector {
1618
}
1719
}
1820

19-
20-
21+
#[allow(dead_code)]
2122
pub struct Econnector{
2223
pub e_conn_id: String,
2324
pub energy_flow_total: f64
2425
}
2526

26-
27-
27+
#[allow(dead_code)]
2828
impl Econnector {
2929

3030
pub fn new(id : String) -> Econnector {

oscps-lib/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ mod component;
44
mod simulation;
55
mod thermodynamics;
66

7-
pub fn hello() -> String {
7+
pub fn hello() -> String {
88
"Hello, world!".to_string()
99
}

oscps-lib/src/simulation.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
// use std::collections::HashMap;
22

3-
// #[derive(Debug, Clone)]
3+
// fn compute_outlet_phase_fractions(&self) {
4+
5+
// }
6+
7+
// fn compute_outlet_temperature(&self) {
8+
9+
// }
10+
11+
// fn compute_outlet_pressure(&self) {
12+
13+
// }
14+
// #[derive(Debug, Clone)]
415
// struct Settings {
516
// // Add fields as needed
617
// }

oscps-lib/src/thermodynamics.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ use uom::si::thermodynamic_temperature::kelvin;
1010
use uom::si::pressure::pascal;
1111
use crate::component::Chemical;
1212

13+
#[allow(dead_code)]
1314
pub enum ThermodynamicConstants {
1415
UniversalGasConstant, // R
1516
StandardTemperature, // T_0
1617
StandardPressure, // P_0
1718
AvogadroNumber, // N_A
1819
}
1920

21+
#[allow(dead_code)]
2022
/// Enum for representing different types of thermodynamic constant values
2123
pub enum ConstantValue {
2224
Pressure(Pressure),
2325
Temperature(ThermodynamicTemperature),
2426
Dimensionless(f64),
2527
}
2628

29+
#[allow(dead_code)]
2730
impl ThermodynamicConstants {
2831
/// Returns the value of the thermodynamic constant with its appropriate type.
2932
pub fn value(&self) -> ConstantValue {
@@ -44,17 +47,20 @@ impl ThermodynamicConstants {
4447
}
4548
}
4649

50+
#[allow(dead_code)]
4751
pub struct ThermoState {
4852
pub pressure: Pressure, // Pressure in Pascals
4953
pub temperature: ThermodynamicTemperature, // Temperature in Kelvin
5054
pub mass_list: Vec<SpeciesListPair>, // Mole fractions, typically unitless
5155
}
5256

57+
#[allow(dead_code)]
5358
pub struct SpeciesListPair {
5459
pub chemical_species : Chemical,
5560
pub mass_quantity : Mass
5661
}
5762

63+
#[allow(dead_code)]
5864
impl ThermoState {
5965
// Constructor for creating a ThermoState
6066
pub fn new(
@@ -150,7 +156,7 @@ mod thermo_tests {
150156
},
151157
};
152158

153-
let Anisdine = Chemical {
159+
let anisdine = Chemical {
154160
pubchem_obj : pubchem::Compound::new(7732),
155161
properties : ChemicalProperties {
156162
molar_mass: 123.155, // g/mol, converting to kg/mol = 123.155 / 1000
@@ -168,7 +174,7 @@ mod thermo_tests {
168174

169175
let anisidine_mass = Mass::new::<kilogram>(8.0);
170176
let anisidine_species_pair = SpeciesListPair {
171-
chemical_species : Anisdine,
177+
chemical_species : anisdine,
172178
mass_quantity : anisidine_mass
173179
};
174180

0 commit comments

Comments
 (0)