Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }

Implementations§

Source§

impl Engine

Source

pub fn new(file_name: &str, gas: &Gas) -> Result<Engine, String>

Source

pub fn advance(&mut self, dt: f64)

Source

pub fn calc_operational_param( &mut self, press: Vec<ArrayView1<'_, f64>>, vol: Vec<ArrayView1<'_, f64>>, )

Source

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}
Source

pub fn update_cylinders_flow_ratio( &mut self, flow_ratio: Vec<Vec<(&str, &FlowRatio)>>, )

Source

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}
Source

pub fn set_displacement(&mut self, disp: f64)

Set engine displacement, input in cm³

Source

pub fn set_compression_ratio_of(&mut self, cyl: &str, comp_ratio: f64)

Set cylinder cyl compression ratio

Source

pub fn set_combustion_model(&mut self, comb: &Box<dyn Combustion>)

Set combustion model for all cylinders

Source

pub fn set_air_fuel_ratio(&mut self, afr: f64)

Set injectors relative air-fuel ratio, input between 0 and 1

Source

pub fn store_species(&mut self, state: bool)

Set if the species inside the cylinder should be storable

Source

pub fn cylinders<'a>(&'a self) -> &'a Vec<Cylinder>

Returns a reference to the cylinders in the engine

Source

pub fn valves<'a>(&'a self) -> &'a Vec<Valve>

Returns a reference to the valves in the engine

Source

pub fn bore(&self) -> f64

Returns cylinders bore in mm

Source

pub fn firing_order(&self) -> String

Returns the firing order of the cylinders

Source

pub fn eccentricity(&self) -> f64

Returns cylinders eccentricity in mm

Source

pub fn combustion_model(&self) -> String

Returns the combustion model name

Source

pub fn injector(&self) -> Option<&Injector>

Source

pub fn sec_to_rad(&self) -> f64

Returns the constant multiplier to change from seconds to crank-angle degrees

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.