function dydt = car_model (time, y) %CAR_MODEL A simple dynamic model for the drive train of a car % DYDT = CAR_MODEL ( T, Y ) implements a system of two first order % differential equations that describe the forward motion of a car % % 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] % % 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 %% % this function implements the differential equation of motion for a car % 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; shift_velocity = [17 30 46]; slope = 0; % 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); 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,resist_force,force_wheel);