V20 MR MR

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 11

/*

{
"engine":{
"es_version":"V0.1.14A",
"name":"4.7L V20 Engine",
"catalog_id":94355,
"yt_handle":"348r8uwtdfg",
"enable_update":true,
"description":[hello, This is the V20 Engine

]
}
}
*/

// Engine Sim V0.1.12A


// 4.7L V20 Engine
// V20
// Created by grubhub3457893
// Native order 1-4-9-12-3-16-11-8-15-14-7-6-13-2-5-10
// Native cylinder numbering
// back
// 16 | 15
// 14 | 13
// 12 | 11
// 10 | 9
// 8 | 7
// 6 | 5
// 4 | 3
// 2 | 1
// v20 1-5-2-6-8-4-7-3
// 1-11-5-9-2-13-6-10-8-14-4-16-7-12-3-15

import "engine_sim.mr"

units units()
constants constants()
impulse_response_library ir_lib()

label vee(140.4 * units.deg)


label bore(100.63)
label stroke(82.67)
label compression_ratio(888)
label con_rod(888.888)
label intake_valve_lift(88.88)
label exhaust_valve_lift(8888.8888)
label compression_height(88 * units.mm) // ?
label intake_valve_diameter(88.8)
label exhaust_valve_diameter(88.888)
label intake_valves(8.88)
label exhaust_valves(8.88)

label ci(888.8)
label redline(10000.0)
label intake_cfm((ci * redline * 8.85) / 8888.8)
label exhaust_cfm((redline * 88888) * ci / 8.8)

label cyl(20.0)
label row(8.0)
label cycle(8.0 * 360.0 * units.deg)
label rot(2.0 * (360.0 / cyl) * units.deg)
label rot90(90.0 * units.deg)
label rot180(180.0 * units.deg)
label rot360(360.0 * units.deg)

//valve timings
label IVO(8.0 * units.deg) //BTDC
label IVC(28.0 * units.deg) //ABDC
label EVO(44.0 * units.deg) //BBDC
label EVC(12.0 * units.deg) //ATDC

label intake_duration(IVO + IVC + rot180)


label exhaust_duration(EVO + EVC + rot180)

label ILC((-IVO + rot180 + IVC) / 2.0 + rot360)


label ELC((rot180 - EVO + EVC + rot360) / 2.0)

label con_rod_mass(695.357103) // g
label crank_mass(42.0) // ? kg
label flywheel_mass(10.0) // kg

label exhaust_delay_coeff(1.8)

public node engine_distributor {


input wires;
input timing_curve;
input rev_limit: 4500 * units.rpm;
input limiter_duration: 0.0001;
alias output __out:
ignition_module(timing_curve: timing_curve, rev_limit: rev_limit,
limiter_duration: limiter_duration)
.connect_wire(wires.wire1, (0.0/cyl) * cycle)
.connect_wire(wires.wire5, (2.0/cyl) * cycle)
.connect_wire(wires.wire2, (4.0/cyl) * cycle)
.connect_wire(wires.wire6, (6.0/cyl) * cycle)
.connect_wire(wires.wire8, (8.0/cyl) * cycle)
.connect_wire(wires.wire4, (10.0/cyl) * cycle)
.connect_wire(wires.wire7, (12.0/cyl) * cycle)
.connect_wire(wires.wire3, (14.0/cyl) * cycle)
.connect_wire(wires.wire9, (0.0/cyl) * cycle + vee)
.connect_wire(wires.wire13, (2.0/cyl) * cycle + vee)
.connect_wire(wires.wire10, (4.0/cyl) * cycle + vee)
.connect_wire(wires.wire14, (6.0/cyl) * cycle + vee)
.connect_wire(wires.wire16, (8.0/cyl) * cycle + vee)
.connect_wire(wires.wire12, (10.0/cyl) * cycle + vee)
.connect_wire(wires.wire15, (12.0/cyl) * cycle + vee)
.connect_wire(wires.wire11, (14.0/cyl) * cycle + vee);
}

private node wires {


output wire1: ignition_wire();
output wire2: ignition_wire();
output wire3: ignition_wire();
output wire4: ignition_wire();
output wire5: ignition_wire();
output wire6: ignition_wire();
output wire7: ignition_wire();
output wire8: ignition_wire();
output wire9: ignition_wire();
output wire10: ignition_wire();
output wire11: ignition_wire();
output wire12: ignition_wire();
output wire13: ignition_wire();
output wire14: ignition_wire();
output wire15: ignition_wire();
output wire16: ignition_wire();
}

public node eng_lobe_profile_int {


alias output __out:
harmonic_cam_lobe(
duration_at_50_thou: intake_duration,
gamma: 2.0,
lift: intake_valve_lift * units.mm,
steps: 100
);
}

public node eng_lobe_profile_exh {


alias output __out:
harmonic_cam_lobe(
duration_at_50_thou: exhaust_duration,
gamma: 2.0,
lift: exhaust_valve_lift * units.mm,
steps: 100
);
}

public node engine_camshaft_builder {


output intake_cam_0: _intake_cam_0;
output exhaust_cam_0: _exhaust_cam_0;

output intake_cam_1: _intake_cam_1;


output exhaust_cam_1: _exhaust_cam_1;

camshaft_parameters params(
advance: 0.0 * units.deg,
base_radius: 1.8 * units.cm
)

camshaft _intake_cam_0(params, lobe_profile: eng_lobe_profile_int())


camshaft _exhaust_cam_0(params, lobe_profile: eng_lobe_profile_exh())

camshaft _intake_cam_1(params, lobe_profile: eng_lobe_profile_int())


camshaft _exhaust_cam_1(params, lobe_profile: eng_lobe_profile_exh())

label rot(2.0 * (360.0 / cyl) * units.deg)

_intake_cam_0
.add_lobe(ILC + 0 * rot)
.add_lobe(ILC + 4 * rot)
.add_lobe(ILC + 14 * rot)
.add_lobe(ILC + 10 * rot)
.add_lobe(ILC + 2 * rot)
.add_lobe(ILC + 6 * rot)
.add_lobe(ILC + 12 * rot)
.add_lobe(ILC + 8 * rot)
_exhaust_cam_0
.add_lobe(ELC + 0 * rot)
.add_lobe(ELC + 4 * rot)
.add_lobe(ELC + 14 * rot)
.add_lobe(ELC + 10 * rot)
.add_lobe(ELC + 2 * rot)
.add_lobe(ELC + 6 * rot)
.add_lobe(ELC + 12 * rot)
.add_lobe(ELC + 8 * rot)

_intake_cam_1
.add_lobe(ILC + 0 * rot + vee)
.add_lobe(ILC + 4 * rot + vee)
.add_lobe(ILC + 14 * rot + vee)
.add_lobe(ILC + 10 * rot + vee)
.add_lobe(ILC + 2 * rot + vee)
.add_lobe(ILC + 6 * rot + vee)
.add_lobe(ILC + 12 * rot + vee)
.add_lobe(ILC + 8 * rot + vee)
_exhaust_cam_1
.add_lobe(ELC + 0 * rot + vee)
.add_lobe(ELC + 4 * rot + vee)
.add_lobe(ELC + 14 * rot + vee)
.add_lobe(ELC + 10 * rot + vee)
.add_lobe(ELC + 2 * rot + vee)
.add_lobe(ELC + 6 * rot + vee)
.add_lobe(ELC + 12 * rot + vee)
.add_lobe(ELC + 8 * rot + vee)
}

private node add_flow_sample {


input lift;
input flow;
input this;
alias output __out: this;

this.add_sample(lift * units.mm, k_28inH2O(flow))


}

public node eng_head {


input intake_camshaft;
input exhaust_camshaft;
input flip_display: false;

alias output __out: head;

label bore_radius(bore / 2.0)

// port_flow.py v0.2
// intake H: 38.1 L: 7.366 N: 1.0
// exhaust H: 34.925 L: 7.6708 N: 1.0
// intake port area: 969.078 mm2; saturated lift: 8.261 mm
// exhaust port area: 814.295 mm2; saturated lift: 7.573 mm
// cylinder volume: 441.816 cc; engine volume: 7069.051 cc
// 32 harmonic intake runner length: 13.153 cm; diameter: 3.007 cm
// primary length: 181.892 cm, area: 4.686 cm2, diameter: 2.443 cm
// collector diameter: 4.885 cm, area: 18.743 cm2
// target power: 3600 RPM, torque: 2376 RPM
function intake_flow(0.737 * units.mm)
intake_flow
.add_flow_sample(0.0, 0.0)
.add_flow_sample(0.737, 18.049)
.add_flow_sample(1.473, 32.535)
.add_flow_sample(2.210, 45.676)
.add_flow_sample(2.946, 57.944)
.add_flow_sample(3.683, 69.563)
.add_flow_sample(4.420, 80.664)
.add_flow_sample(5.156, 91.334)
.add_flow_sample(5.893, 101.636)
.add_flow_sample(6.629, 111.616)
.add_flow_sample(7.366, 121.310)

function exhaust_flow(0.767 * units.mm)


exhaust_flow
.add_flow_sample(0.0, 0.0)
.add_flow_sample(0.767, 16.917)
.add_flow_sample(1.534, 30.432)
.add_flow_sample(2.301, 42.664)
.add_flow_sample(3.068, 54.062)
.add_flow_sample(3.835, 64.839)
.add_flow_sample(4.602, 75.123)
.add_flow_sample(5.370, 84.997)
.add_flow_sample(6.137, 94.518)
.add_flow_sample(6.904, 103.732)
.add_flow_sample(7.671, 111.558)

cylinder_head head(
chamber_volume: (circle_area(bore_radius) * stroke / compression_ratio) /
1000.0 * units.cc,
intake_runner_volume: 93.384 * units.cc,
intake_runner_cross_section_area: 7.100 * units.cm2,
exhaust_runner_volume: 31.128 * units.cc,
exhaust_runner_cross_section_area: 4.686 * units.cm2,

intake_port_flow: intake_flow,
exhaust_port_flow: exhaust_flow,
intake_camshaft: intake_camshaft,
exhaust_camshaft: exhaust_camshaft,
flip_display: flip_display
)
}

public node eng {


alias output __out: engine;

engine engine(
name: "Cadillac 38-90 V16",
starter_torque: 120 * units.lb_ft,
starter_speed: 350 * units.rpm,
redline: redline * units.rpm,
fuel: fuel(
max_turbulence_effect: 3.0,
burning_efficiency_randomness: 0.2,
max_burning_efficiency: 0.88
),
throttle_gamma: 1.5,
jitter: 1.0,
noise: 1.0,
simulation_frequency: 4500
)

wires wires()

piston_parameters piston_params(
mass: 599.195521 * units.g,
blowby: k_28inH2O(0.1),
compression_height: compression_height,
wrist_pin_position: 0.0,
displacement: 0.0
)

connecting_rod_parameters cr_params(
mass: con_rod_mass * units.g,
moment_of_inertia: rod_moment_of_inertia(
mass: con_rod_mass * units.g,
length: con_rod * units.mm
),
center_of_mass: 0.0,
length: con_rod * units.mm
)

label crank_moment(
disk_moment_of_inertia(mass: crank_mass * units.kg, radius: (stroke / 2.0)
* units.mm)
)
label flywheel_moment(
disk_moment_of_inertia(mass: flywheel_mass * units.kg, radius: (stroke *
3.5) * units.mm)
)
label other_moment(
disk_moment_of_inertia(mass: 1 * units.kg, radius: 1.0 * units.cm)
)

crankshaft c0(
throw: (stroke / 2.0) * units.mm,
flywheel_mass: flywheel_mass * units.kg,
mass: crank_mass * units.kg,
friction_torque: 10.0 * units.Nm,
moment_of_inertia: crank_moment + flywheel_moment + other_moment,
position_x: 0.0,
position_y: 0.0,
tdc: 0.0
)

rod_journal rj0(angle: (0.0 / cyl) * cycle + rot90 + vee / 2)


rod_journal rj1(angle: (4.0 / cyl) * cycle + rot90 + vee / 2)
rod_journal rj2(angle: (14.0 / cyl) * cycle + rot90 + vee / 2)
rod_journal rj3(angle: (10.0 / cyl) * cycle + rot90 + vee / 2)
rod_journal rj4(angle: (2.0 / cyl) * cycle + rot90 + vee / 2)
rod_journal rj5(angle: (6.0 / cyl) * cycle + rot90 + vee / 2)
rod_journal rj6(angle: (12.0 / cyl) * cycle + rot90 + vee / 2)
rod_journal rj7(angle: (8.0 / cyl) * cycle + rot90 + vee / 2)

c0
.add_rod_journal(rj0)
.add_rod_journal(rj1)
.add_rod_journal(rj2)
.add_rod_journal(rj3)
.add_rod_journal(rj4)
.add_rod_journal(rj5)
.add_rod_journal(rj6)
.add_rod_journal(rj7)

cylinder_bank_parameters bank_params(
bore: bore * units.mm,
deck_height: (con_rod + stroke / 2.0) * units.mm + compression_height
)

label intake_valve_circ(intake_valve_diameter * constants.pi)


label intake_valve_area(intake_valve_circ * intake_valve_lift / 100.0) // cm2

label intake_plenum_area(intake_valve_area * cyl * intake_valves) // cm2


label exhaust_crossection_area(18.743 * 2.0) // cm2

label exhaust_pipe_length_0(400.0) // cm
label exhaust_volume_0(exhaust_crossection_area * exhaust_pipe_length_0 /
100.0) // Litres

label spacing_factor(1.15)
label flange_density(1.0 * exhaust_delay_coeff)
label primary_tube_length(181.892)

intake intake(
plenum_volume: 2.0 * units.L,
plenum_cross_section_area: intake_plenum_area * units.cm2,
intake_flow_rate: k_carb(intake_cfm),
idle_flow_rate: k_carb(0.04),
idle_throttle_plate_position: 0.995,
runner_flow_rate: k_carb(intake_cfm / (cyl / 2.0)),
runner_length: 13.153 * units.cm,
velocity_decay: 0.05
)

exhaust_system_parameters es_params0(
outlet_flow_rate: k_carb(exhaust_cfm),
collector_cross_section_area: exhaust_crossection_area * units.cm2,
length: exhaust_pipe_length_0 * units.cm,
primary_tube_length: primary_tube_length * units.cm,
primary_flow_rate: k_carb(exhaust_cfm / (cyl / 2.0)),
velocity_decay: 1.0,
volume: (exhaust_volume_0 + 3.0) * units.L
)

exhaust_system exhaust0(es_params0, impulse_response: ir_lib.default_0,


audio_volume: 10.0)

cylinder_bank b0(bank_params, angle: vee / 2)


cylinder_bank b1(bank_params, angle: -vee / 2)

label sh((12.0 / exhaust_delay_coeff) * units.cm)


label pl0 ((7.00 * bore * spacing_factor / flange_density) * units.mm)
label pl1 ((5.25 * bore * spacing_factor / flange_density) * units.mm)
label pl2 ((4.75 * bore * spacing_factor / flange_density) * units.mm)
label pl3 ((3.00 * bore * spacing_factor / flange_density) * units.mm)
label pl4 ((2.50 * bore * spacing_factor / flange_density) * units.mm)
label pl5 ((1.00 * bore * spacing_factor / flange_density) * units.mm)
label pl6 ((1.00 * bore * spacing_factor / flange_density) * units.mm)
label pl7 ((2.50 * bore * spacing_factor / flange_density) * units.mm)

b0
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj0,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl0 + sh,
ignition_wire: wires.wire1
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj1,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl1 + sh,
ignition_wire: wires.wire2
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj2,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl2 + sh,
ignition_wire: wires.wire3
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj3,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl3 + sh,
ignition_wire: wires.wire4
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj4,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl4 + sh,
ignition_wire: wires.wire5
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj5,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl5 + sh,
ignition_wire: wires.wire6
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj6,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl6 + sh,
ignition_wire: wires.wire7
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj7,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl7 + sh,
ignition_wire: wires.wire8
)

b1
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj0,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl0,
ignition_wire: wires.wire9
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj1,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl1,
ignition_wire: wires.wire10
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj2,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl2,
ignition_wire: wires.wire11
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj3,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl3,
ignition_wire: wires.wire12
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj4,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl4,
ignition_wire: wires.wire13
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj5,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl5,
ignition_wire: wires.wire14
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj6,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl6,
ignition_wire: wires.wire15
)
.add_cylinder(
piston: piston(piston_params),
connecting_rod: connecting_rod(cr_params),
rod_journal: rj7,
intake: intake,
exhaust_system: exhaust0,
primary_length: pl7,
ignition_wire: wires.wire16
)

engine
.add_cylinder_bank(b0)
.add_cylinder_bank(b1)

engine.add_crankshaft(c0)

engine_camshaft_builder camshaft()

b0.set_cylinder_head (
eng_head(
intake_camshaft: camshaft.intake_cam_0,
exhaust_camshaft: camshaft.exhaust_cam_0,
flip_display: true
)
)
b1.set_cylinder_head (
eng_head(
intake_camshaft: camshaft.intake_cam_1,
exhaust_camshaft: camshaft.exhaust_cam_1
)
)

// ignition_timing.py v0.1 r = 1.3


function timing_curve(1000 * units.rpm)
timing_curve
.add_sample(0000 * units.rpm, 5.0 * units.deg)
.add_sample(1000 * units.rpm, 6.5 * units.deg)
.add_sample(2000 * units.rpm, 8.5 * units.deg)
.add_sample(3000 * units.rpm, 11.0 * units.deg)
.add_sample(4000 * units.rpm, 14.3 * units.deg)

engine.add_ignition_module(
engine_distributor(
wires: wires,
timing_curve: timing_curve
)
)
}

// Cadillac V16 1932


public node veh {
alias output __out: vehicle;
vehicle vehicle(
mass: 2272.0 * units.kg,
drag_coefficient: 0.42,
cross_sectional_area: (1890 * units.mm) * (1700 * units.mm),
diff_ratio: 3.47,
tire_radius: (787.4 / 2) * units.mm, // 7.5 x 16
rolling_resistance: 20
)
}

// Cadillac V16 1932


private node trn {
alias output __out:
transmission(
max_clutch_torque: 500 * units.Nm,
max_clutch_flex: 10 * units.deg,
limit_clutch_flex: true,
clutch_stiffness: 20 * units.Nm / units.deg,
clutch_damping: 2.0,
simulate_flex: true
)
.add_gear(2.39)
.add_gear(1.53)
.add_gear(1.0);
}

run(
engine: eng(),
transmission: trn(),
vehicle: veh()
)

You might also like