pub struct Engine { /* private fields */ }Implementations§
Source§impl Engine
impl Engine
pub fn new(file_name: &str, gas: &Gas) -> Result<Engine, String>
pub fn advance(&mut self, dt: f64)
pub fn calc_operational_param( &mut self, press: Vec<ArrayView1<'_, f64>>, vol: Vec<ArrayView1<'_, f64>>, )
Sourcepub fn write_performance_to(&self, file_name: &str)
pub fn write_performance_to(&self, file_name: &str)
Examples found in repository?
examples/Ryobi_26_engine.rs (line 47)
4fn main() {
5
6 let gas = Gas::new("air.json");
7 let gas_intake = Gas::new("air.json");
8 let mut gas_exhaust = Gas::new("air.json");
9 gas_exhaust.TPX(500.0, 101325.0, "N2:0.662586, H2O:0.202449, CO2:0.134965");
10
11 let mut builder = lmb::SystemBuilder::new();
12 builder.add_engine("engine_Ryobi.json", &gas)
13 .add_environment("ambient", &gas)
14 .add_reservoir("int_plenum", 250.0, &gas_intake)
15 .add_reservoir("int_port", 2.04, &gas_intake)
16 .add_reservoir("exh_port", 2.04, &gas_exhaust)
17 .add_reservoir("exh_plenum_1", 95.0, &gas_exhaust)
18 .add_reservoir("exh_plenum_2", 158.0, &gas_exhaust)
19 .add_orifice("int_plenum -> amb 1", 9.5, 0.92, vec!["ambient", "int_plenum"])
20 .add_orifice("int_plenum -> amb 2", 9.5, 0.92, vec!["ambient", "int_plenum"])
21 .add_orifice("int_plenum -> int_port", 6.5, 0.78, vec!["int_plenum", "int_port"])
22 .add_orifice("exh_plenum_2 -> amb", 8.9, 0.78, vec!["exh_plenum_2", "ambient"])
23 .add_orifice("exh_plenum_1 -> exh_plenum_2", 12.7, 0.78, vec!["exh_plenum_1", "exh_plenum_2"])
24 .add_orifice("exh_port -> exh_plenum_1", 10.8, 0.78, vec!["exh_port", "exh_plenum_1"])
25 .connect_from_to("valve_int", "int_port")
26 .connect_from_to("valve_exh", "exh_port");
27
28 let mut system = builder.build_system();
29
30 // Calculating
31 for speed in vec![5000.0, 5500.0, 6000.0, 6500.0, 7000.0, 7500.0, 8000.0, 8500.0, 9000.0] {
32 system.engine_mut().unwrap().set_speed(speed);
33 system.advance_to_steady_state();
34
35 // Writting data
36 let folder_name = format!("./Ryobi_26_results/{:.0}_", speed);
37 system.write_to_file( &(folder_name.clone() + "cylinder.txt"), "cyl_1", None);
38 system.write_to_file(&(folder_name.clone() + "int_plenum.txt"), "int_plenum", None);
39 system.write_to_file(&(folder_name.clone() + "int_port.txt"), "int_port", None);
40 system.write_to_file(&(folder_name.clone() + "exh_port.txt"), "exh_port", None);
41 system.write_to_file(&(folder_name.clone() + "exh_plenum_1.txt"), "exh_plenum_1", None);
42 system.write_to_file(&(folder_name.clone() + "exh_plenum_2.txt"), "exh_plenum_2", None);
43 system.write_to_file(&(folder_name.clone() + "int_valve.txt"), "valve_int", None);
44 system.write_to_file(&(folder_name.clone() + "exh_valve.txt"), "valve_exh", None);
45 }
46
47 system.engine().unwrap().write_performance_to("./Ryobi_26_results/engine_performance.txt");
48
49}pub fn update_cylinders_flow_ratio( &mut self, flow_ratio: Vec<Vec<(&str, &FlowRatio)>>, )
Sourcepub fn set_speed(&mut self, speed: f64)
pub fn set_speed(&mut self, speed: f64)
Set engine speed, input in RPM
Examples found in repository?
examples/Ryobi_26_engine.rs (line 32)
4fn main() {
5
6 let gas = Gas::new("air.json");
7 let gas_intake = Gas::new("air.json");
8 let mut gas_exhaust = Gas::new("air.json");
9 gas_exhaust.TPX(500.0, 101325.0, "N2:0.662586, H2O:0.202449, CO2:0.134965");
10
11 let mut builder = lmb::SystemBuilder::new();
12 builder.add_engine("engine_Ryobi.json", &gas)
13 .add_environment("ambient", &gas)
14 .add_reservoir("int_plenum", 250.0, &gas_intake)
15 .add_reservoir("int_port", 2.04, &gas_intake)
16 .add_reservoir("exh_port", 2.04, &gas_exhaust)
17 .add_reservoir("exh_plenum_1", 95.0, &gas_exhaust)
18 .add_reservoir("exh_plenum_2", 158.0, &gas_exhaust)
19 .add_orifice("int_plenum -> amb 1", 9.5, 0.92, vec!["ambient", "int_plenum"])
20 .add_orifice("int_plenum -> amb 2", 9.5, 0.92, vec!["ambient", "int_plenum"])
21 .add_orifice("int_plenum -> int_port", 6.5, 0.78, vec!["int_plenum", "int_port"])
22 .add_orifice("exh_plenum_2 -> amb", 8.9, 0.78, vec!["exh_plenum_2", "ambient"])
23 .add_orifice("exh_plenum_1 -> exh_plenum_2", 12.7, 0.78, vec!["exh_plenum_1", "exh_plenum_2"])
24 .add_orifice("exh_port -> exh_plenum_1", 10.8, 0.78, vec!["exh_port", "exh_plenum_1"])
25 .connect_from_to("valve_int", "int_port")
26 .connect_from_to("valve_exh", "exh_port");
27
28 let mut system = builder.build_system();
29
30 // Calculating
31 for speed in vec![5000.0, 5500.0, 6000.0, 6500.0, 7000.0, 7500.0, 8000.0, 8500.0, 9000.0] {
32 system.engine_mut().unwrap().set_speed(speed);
33 system.advance_to_steady_state();
34
35 // Writting data
36 let folder_name = format!("./Ryobi_26_results/{:.0}_", speed);
37 system.write_to_file( &(folder_name.clone() + "cylinder.txt"), "cyl_1", None);
38 system.write_to_file(&(folder_name.clone() + "int_plenum.txt"), "int_plenum", None);
39 system.write_to_file(&(folder_name.clone() + "int_port.txt"), "int_port", None);
40 system.write_to_file(&(folder_name.clone() + "exh_port.txt"), "exh_port", None);
41 system.write_to_file(&(folder_name.clone() + "exh_plenum_1.txt"), "exh_plenum_1", None);
42 system.write_to_file(&(folder_name.clone() + "exh_plenum_2.txt"), "exh_plenum_2", None);
43 system.write_to_file(&(folder_name.clone() + "int_valve.txt"), "valve_int", None);
44 system.write_to_file(&(folder_name.clone() + "exh_valve.txt"), "valve_exh", None);
45 }
46
47 system.engine().unwrap().write_performance_to("./Ryobi_26_results/engine_performance.txt");
48
49}Sourcepub fn set_displacement(&mut self, disp: f64)
pub fn set_displacement(&mut self, disp: f64)
Set engine displacement, input in cm³
Sourcepub fn set_compression_ratio_of(&mut self, cyl: &str, comp_ratio: f64)
pub fn set_compression_ratio_of(&mut self, cyl: &str, comp_ratio: f64)
Set cylinder cyl compression ratio
Sourcepub fn set_combustion_model(&mut self, comb: &Box<dyn Combustion>)
pub fn set_combustion_model(&mut self, comb: &Box<dyn Combustion>)
Set combustion model for all cylinders
Sourcepub fn set_air_fuel_ratio(&mut self, afr: f64)
pub fn set_air_fuel_ratio(&mut self, afr: f64)
Set injectors relative air-fuel ratio, input between 0 and 1
Sourcepub fn store_species(&mut self, state: bool)
pub fn store_species(&mut self, state: bool)
Set if the species inside the cylinder should be storable
Sourcepub fn cylinders<'a>(&'a self) -> &'a Vec<Cylinder>
pub fn cylinders<'a>(&'a self) -> &'a Vec<Cylinder>
Returns a reference to the cylinders in the engine
Sourcepub fn firing_order(&self) -> String
pub fn firing_order(&self) -> String
Returns the firing order of the cylinders
Sourcepub fn eccentricity(&self) -> f64
pub fn eccentricity(&self) -> f64
Returns cylinders eccentricity in mm
Sourcepub fn combustion_model(&self) -> String
pub fn combustion_model(&self) -> String
Returns the combustion model name
pub fn injector(&self) -> Option<&Injector>
Sourcepub fn sec_to_rad(&self) -> f64
pub fn sec_to_rad(&self) -> f64
Returns the constant multiplier to change from seconds to crank-angle degrees
pub fn operat_param(&self) -> &OperationalParameters
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl !Send for Engine
impl !Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more