pysim models - vehicle model¶
Simulation model : Vehicle¶
Description¶
- Simulate vehicle dynamics of EV
Modules summary¶
- Body module - simulate dynamics of drivetrain
- Drivetrain_config - configure drive train Parameters
- Lon_equivalence - calculate rotational dynamics of equivalent vehicle
- Driveshaft_dynamics - calculate rotational dynamics of drive shaft
- Tire_dynamics - calculate rotational dynamics of tire
- Motor_dynamics - calculate rotational dynamics of motor out
- Vehicle module - contain
power moduleandbody module, simulate vehicle behavior - Veh_init_config - configure initial vehicle state, position, velocity
- Veh_config - configure vehicle parameters
- Veh_position_update - update vehicle position according to speed and steering
- Veh_driven - calculate vehicle velocity and wheel theta
- Veh_lon_driven - simulate longitudinal vehicle behavior (include
Mod_Power(Motor_driven),Mod_Body(Lon_equivalence)) - Veh_lon_dynamics - calculate vehicle acceleration according to traction force and drag force
- Acc_system - determine desired torque set according to acceleration pedal position
- Brake_system - determine brake torque set according to brake pedal position
- Drag_system - determine air and rolling resistance force
- Veh_lon_driven - simulate longitudinal vehicle behavior (include
- Veh_lat_driven - simulate lateral vehicle behavior
- Veh_lat_dynamics - calculate tire wheel dynamics according to steering input
- Vehicle module - contain
Module diagram:
Veh_driven( Veh_lon_driven, Veh_lat_driven ) >> Veh_lon_driven( Veh_lon_dynamics, Acc_system, Brake_system, Drag_system, Motor_driven, Lon_equivalence ) >> Lon_equivalence in Mod_Body >> Motor_driven in Mod_Power >> Veh_lat_driven( Veh_lat_dynamics )
Update¶
- [18/05/31] - Initial release - Kyunghan
- [18/06/01] - Seperate powertrain class in new file - Kyuhwan
- [18/06/11] - Modification - Kyunghan - Modify drivetrain module to body module - Modify model configurations - Add regeneration module in body.brake_system
- [18/08/08] - Restructure - Kyunghan - Modify drive train module - Modify tire module - Modify drag force module
-
class
pysim.models.model_vehicle.Mod_Body[source]¶ Bases:
object- Body module
-
Driveshaft_dynamics(t_shaft_in, t_shaft_out, w_shaft)[source]¶ Calculate rotational dynamics of shaft
- Args:
- t_shaft_in: shaft in torque = motor_out torque - mechanical loss [Nm]
- t_shaft_out: shaft out torque [Nm]
- w_shaft: previous rotational speed of shaft [rad/s]
- Return:
- w_shaft: updated rotational speed of shaft [rad/s]
-
Drivetrain_config(conf_rd_wheel=0.301, conf_jw_wheel=0.1431, conf_jw_diff_in=0.015, conf_jw_diff_out=0.015, conf_jw_trns_out=0.015, conf_jw_trns_in=0.01, conf_jw_mot=0.005, conf_eff_trns=0.96, conf_eff_diff=0.9796, conf_eff_diff_neg=0.9587, conf_gear=6.058, conf_mass_veh=1200, conf_mass_add=0)[source]¶ Drivetrain and body parameter configuration Parameters not specified are declared as default values If you want set a specific parameter don’t use this function, just type:
Mod_Body.conf_veh_len = 2 ...
- Parameters:
- Vehicle mass Wheel radius Momentum of inertia: shaft, wheel Drive shaft efficiency, gear ratio
-
Lon_equivalence(t_mot, t_brk, t_drag)[source]¶ Calculate equivalent rotational dynamics of vhielce
Equivalet component: Motor + Shaft + Wheel + Vehicle
Dynamics:
w_vehicle_dot = (t_motor - t_drag - t_brake) / j_veh ...
- Args:
- t_mot: motor torque [Nm]
- t_brk: brake torque [Nm]
- t_drag: equivalent drag torque [Nm]
- Return:
- load torque: load torque of each component [Nm]
- f_lon: longitudinal traction force [N]
-
Motor_dynamics(t_mot, t_mot_load, w_motor)[source]¶ Calculate rotational dynamics of motor
- Args:
- t_mot: motor generated torque [Nm]
- t_mot_load: motor load torque to shaft [Nm]
- w_shaft: previous rotational speed of motor [rad/s]
- Return:
- w_shaft: updated rotational speed of motor [rad/s]
-
Tire_dynamics(t_wheel_load, t_wheel_traction_f, t_brk, w_wheel)[source]¶ Calculate rotational dynamics of wheel
- Args:
- t_wheel_load: wheel in torque = shaft out torque [Nm]
- t_wheel_traction_f: wheel out torque to traction force [Nm]
- t_brk: brake torque [Nm]
- w_shaft: previous rotational speed of wheel [rad/s]
- Return:
- w_shaft: updated rotational speed of wheel [rad/s]
-
class
pysim.models.model_vehicle.Mod_Veh(powertrain_model, drivetrain_model)[source]¶ Bases:
object- Vehicle module: Set the
powerandbodymodel when initialization
-
Acc_system(u_acc)[source]¶ Determine desired motor torque
- Args:
- u_acc: acceleration pedal of driver [-]
- Return:
- t_mot_des: desired motor torque [Nm]
-
Brake_system(u_brake, t_reg_set=0)[source]¶ Determine brake torque
Regen control:
swtRegCtl = 0 # Meachanical braking swtRegCtl = 1 # Transfer braking torque to regenerative motor torque swtRegCtl = 2 # Set the specific regenerative motor torque
- Args:
- u_brake: acceleration pedal of driver [-]
- t_reg_set: Regenerative torque set [-]
- Return:
- t_brake: Braking torque [Nm]
- t_mot_reg: Regenerative motor torque [Nm]
-
Drag_system(vel_veh)[source]¶ Calculate drag torque
Air drag:
f_drag_air = 0.5*1.25*self.conf_drag_air_coef*vel_veh**2
Rolling resistance:
f_drag_roll = self.conf_drag_ca + self.conf_drag_cc*vel_veh**2
- Args:
- vel_veh: vehicle velocity [m/s]
- Return:
- t_drag: total drag torque [Nm]
- f_drag: total drag force [N]
-
Veh_config(conf_drag_air_coef=0, conf_add_weight=0, conf_drag_ca=143.06, conf_drag_cc=0.4405, conf_veh_len=2, conf_acc_trq_fac=82.76, conf_brk_trq_fac=501.8, conf_motreg_max=100)[source]¶ Vehicle parameter configuration Parameters not specified are declared as default values If you want set a specific parameter don’t use this function, just type:
>>> Mod_Body.conf_veh_len = 2 ...
- Parameters:
- Vehicle size
- Air drag coefficient
- Rolling resistance coefficient
- Acceleration, Brake coefficient
-
Veh_driven(u_acc, u_brake, u_steer=0)[source]¶ Simulate vehicle behavior according to driver’s input
- Args:
- u_acc: Acceleration pedal position [-]
- u_brake: Brake pedal position [-]
- u_steer: Steering wheel angle [-]
- Return:
- vel_veh: Vehicle velocity [m/s]
- the_wheel: Wheel heading angle [rad]
- Include:
Mod_Veh(Veh_lon_driven,Veh_lat_driven): Simulate vehicle behavior
-
Veh_init_config(x_veh=0, y_veh=0, s_veh=0, n_veh=0, psi_veh=0, vel_veh=0, theta_wheel=0)[source]¶ Initialize vehicle state
- State:
- Vehicle position on environment
- Velocity
- Heading angle
-
Veh_lat_driven(u_steer)[source]¶ Simulate lateral vehicle behavior according to driver’s input
- Args:
- u_steer: steering input [-]
- Return:
- the_wheel: wheel heading angle [rad]
- Include:
Mod_Veh(Veh_lat_dynamics): Calculate wheel dynamics
-
Veh_lat_dynamics(the_wheel, u_steer)[source]¶ Calculate lateral vehicle dynamics
Dynamics:
the_wheel_dot = (u_steer - the_wheel) / lat_dynamic_coeff ...
- Args:
- u_steer: steering input of driver [-]
- the_wheel: longitudinal drag force from Drag_system, Brake_system [N]
- Return:
- the_wheel: vehicle velocity [m/s]
-
Veh_lon_driven(u_acc, u_brake)[source]¶ Simulate longitudinal vehicle behavior according to driver’s input
Calculate total drag force from Drag_system in vehicle module
Determine driven force from Acc_system and Brake_system in vehicle module
Drive Lon_equivalence function in body module
- Args:
- u_acc: Acceleration pedal position [-]
- u_brake: Brake pedal position [-]
- Return:
- veh_vel: Vehicle velocity [m/s]
- s, n position: Road relative vehicle position [m]
- psi_veh: Vehicle heading angle [rad]
- Include:
Mod_Veh(Acc_system, Brake_system, Drag_system, Veh_lon_dynamics): Determine driven torqueMod_Body(Lon_equivalence): Calculate vehicle rotational dynamicsMod_Power(Motor_driven): Determine motor driven torque
-
Veh_lon_dynamics(f_lon, f_drag, vel_veh)[source]¶ Calculate longitudinal vehicle dynamics
Equivalet component: Motor + Shaft + Wheel + Vehicle
Dynamics:
veh_acc = (f_lon - f_drag) / m_veh ...
- Args:
- f_lon: longitudinal driven force from Lon_equivalence [N]
- f_drag: longitudinal drag force from Drag_system, Brake_system [N]
- Return:
- veh_vel: vehicle velocity [m/s]
-
Veh_position_update(vel_veh=0, the_wheel=0)[source]¶ Update vehicle position on environment
- Args:
- vel_veh: Vehicle velocity [m/s]
- the_wheel: Wheel angle [rad]
- Return:
- x, y position: Absolute vehicle coordinate [m]
- s, n position: Road relative vehicle position [m]
- psi_veh: Vehicle heading angle [rad]
- Vehicle module: Set the
-
pysim.models.model_vehicle.Ts= 0.01¶ global vairable: simulation sampling timeself.
you can declare other sampling time in application as vairable
Ts