Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/notebooks/oem.ipynb
Views: 531
Modeling and Simulation in Python
Case study.
Copyright 2017 Allen Downey
Electric car
Olin Electric Motorsports is a club at Olin College that designs and builds electric cars, and participates in the Formula SAE Electric competition.
The goal of this case study is to use simulation to guide the design of a car intended to accelerate from standing to 100 kph as quickly as possible. The world record for this event, using a car that meets the competition requirements, is 1.513 seconds.
We'll start with a simple model that takes into account the characteristics of the motor and vehicle:
The motor is an Emrax 228 high voltage axial flux synchronous permanent magnet motor; according to the data sheet, its maximum torque is 240 Nm, at 0 rpm. But maximum torque decreases with motor speed; at 5000 rpm, maximum torque is 216 Nm.
The motor is connected to the drive axle with a chain drive with speed ratio 13:60 or 1:4.6; that is, the axle rotates once for each 4.6 rotations of the motor.
The radius of the tires is 0.26 meters.
The weight of the vehicle, including driver, is 300 kg.
To start, we will assume no slipping between the tires and the road surface, no air resistance, and no rolling resistance. Then we will relax these assumptions one at a time.
First we'll add drag, assuming that the frontal area of the vehicle is 0.6 square meters, with coefficient of drag 0.6.
Next we'll add rolling resistance, assuming a coefficient of 0.2.
Finally we'll compute the peak acceleration to see if the "no slip" assumption is credible.
We'll use this model to estimate the potential benefit of possible design improvements, including decreasing drag and rolling resistance, or increasing the speed ratio.
I'll start by loading the units we need.
And store the parameters in a Params
object.
make_system
creates the initial state, init
, and constructs an interp1d
object that represents torque as a function of motor speed.
Testing make_system
Torque and speed
The relationship between torque and motor speed is taken from the Emrax 228 data sheet. The following functions reproduce the red dotted line that represents peak torque, which can only be sustained for a few seconds before the motor overheats.
Plot the whole curve.
Simulation
Here's the slope function that computes the maximum possible acceleration of the car as a function of it current speed.
Testing slope_func
at linear velocity 10 m/s.
Now we can run the simulation.
And look at the results.
After 3 seconds, the vehicle could be at 40 meters per second, in theory, which is 144 kph.
Plotting x
Plotting v
Stopping at 100 kph
We'll use an event function to stop the simulation when we reach 100 kph.
Here's what the results look like.
According to this model, we should be able to make this run in just over 2 seconds.
At the end of the run, the car has gone about 28 meters.
If we send the final state back to the slope function, we can see that the final acceleration is about 13 , which is about 1.3 times the acceleration of gravity.
It's not easy for a vehicle to accelerate faster than g
, because that implies a coefficient of friction between the wheels and the road surface that's greater than 1. But racing tires on dry asphalt can do that; the OEM team at Olin has tested their tires and found a peak coefficient near 1.5.
So it's possible that our no slip assumption is valid, but only under ideal conditions, where weight is distributed equally on four tires, and all tires are driving.
Exercise: How much time do we lose because maximum torque decreases as motor speed increases? Run the model again with no drop off in torque and see how much time it saves.
Drag
In this section we'll see how much effect drag has on the results.
Here's a function to compute drag force, as we saw in Chapter 21.
We can test it with a velocity of 20 m/s.
Here's the resulting acceleration of the vehicle due to drag.
We can see that the effect of drag is not huge, compared to the acceleration we computed in the previous section, but it is not negligible.
Here's a modified slope function that takes drag into account.
And here's the next run.
The time to reach 100 kph is a bit higher.
But the total effect of drag is only about 2/100 seconds.
That's not huge, which suggests we might not be able to save much time by decreasing the frontal area, or coefficient of drag, of the car.
Rolling resistance
Next we'll consider rolling resistance, which the force that resists the motion of the car as it rolls on tires. The cofficient of rolling resistance, C_rr
, is the ratio of rolling resistance to the normal force between the car and the ground (in that way it is similar to a coefficient of friction).
The following function computes rolling resistance.
The acceleration due to rolling resistance is 0.2 (it is not a coincidence that it equals C_rr
).
Here's a modified slope function that includes drag and rolling resistance.
And here's the run.
The final time is a little higher, but the total cost of rolling resistance is only 3/100 seconds.
So, again, there is probably not much to be gained by decreasing rolling resistance.
In fact, it is hard to decrease rolling resistance without also decreasing traction, so that might not help at all.
Optimal gear ratio
The gear ratio 13:60 is intended to maximize the acceleration of the car without causing the tires to slip. In this section, we'll consider other gear ratios and estimate their effects on acceleration and time to reach 100 kph.
Here's a function that takes a speed ratio as a parameter and returns time to reach 100 kph.
We can test it with the default ratio:
Now we can try it with different numbers of teeth on the motor gear (assuming that the axle gear has 60 teeth):
Wow! The speed ratio has a big effect on the results. At first glance, it looks like we could break the world record (1.513 seconds) just by decreasing the number of teeth.
But before we try it, let's see what effect that has on peak acceleration.
Here are the results:
As we decrease the speed ratio, the peak acceleration increases. With 8 teeth on the motor gear, we could break the world record, but only if we can accelerate at 2.3 times the acceleration of gravity, which is impossible without very sticky ties and a vehicle that generates a lot of downforce.
These results suggest that the most promising way to improve the performance of the car (for this event) would be to improve traction.