function dydt = car_model_w_parameters (time, y, differential_ratio) %CAR_MODEL_W_PARAMETERS A simple dynamic model for the drive train of a car % DYDT = CAR_MODEL_W_PARAMETERS ( T, Y, DIFFERENTIAL_RATIO ) implements a % system of two first order differential equations that describe the % forward motion of a car. The gear ratio of the differential can be % provided as an additional input. The shift velocities are updated % based on the differential_ratio to make sure maximum engine power is % maintained at all times. % % Inputs: % T: A time value at which the derivatives are computed % (not used, since the differential equation is % time-independent) % Y: The state vector at which the derivatives are computed. % The state vector consists of two elements; Y(1) is the % car velocity in [m/s] and Y(2) is the car position in [m] % DIFFERENTIAL_RATIO: The gear ratio of the differential % [dimensionless] % % Outputs: % DYDT: A column vector with the derivative of the state vector; % DYDT(1) is the acceleration of the car in [m/s2] and % DYDT(2) is the velocity of the car in [m/s] % % Assumptions: % - The transmission and differential are loss-free % - The load consists only of air and tire resistance % - The car is driven at full throttle % - A torque converter is included in the model % - the tires don't slip % %% ME 2016 %% Fall 2007 %% %% AUTHOR: Chris Paredis %% % keep track of the number of times this function is called -- to answer % question 4 of the assignment global num_model_evals; num_model_evals = num_model_evals + 1; % define all the parameters mass = 1650; wheel_radius = 0.332; % in [m] gear_ratios = [2.77 1.54 1 0.69]; % differential_ratio = 4.266; -- now provided as input slope = 0; % IMPORTANT: to make the car perform well for different differential % ratios, the shift velocities need to be updated. The optimal shift % velocities change linearly with the differential ratio nominal_differential_ratio = 4.266; nominal_shift_velocity = [61.6459 109.5366 166.3211]/3.6; % in [m/s] shift_velocity = nominal_shift_velocity * nominal_differential_ratio ... /differential_ratio; % the state y consists of position and velocity of the car car_vel_ms = y(1); car_position = y(2); % not used anywhere % determine the total ratio (transmission + differential + wheel) if car_vel_ms > shift_velocity(3) transmission_ratio = gear_ratios(4); elseif car_vel_ms > shift_velocity(2) transmission_ratio = gear_ratios(3); elseif car_vel_ms > shift_velocity(1) transmission_ratio = gear_ratios(2); else transmission_ratio = gear_ratios(1); end total_ratio = transmission_ratio*differential_ratio/wheel_radius; % convert velocity into engine speed, into engine torque and back to force % on the car omega_tc = car_vel_ms * total_ratio; %torque_tc = engine_w_torque_converter( omega_tc); torque_tc = interp_engine_w_torque_converter( omega_tc); force_wheel = torque_tc * total_ratio; % combine everything in the car's differential equation resistance_force = resistance_force_CJP(car_vel_ms,slope); dvdt = (force_wheel - resistance_force)/mass; dydt = [dvdt; car_vel_ms]; % for debugging purposes, uncomment the next line %fprintf('%12g %12g %12g %12g %12g\n',time,car_vel_ms*3.6,transmission_ratio,resistance_force,force_wheel);