How to set up Runge Kutta Simulation for Numerical Vehicle Dynamics?
9 ビュー (過去 30 日間)
古いコメントを表示
Hey all, I'm struggling to set up my RK4 equations to simulate some simple vehicle dynamics. Essentially, what I want to do is to simulate the time passed, distance travelled, velocity, velocity^2 and acceleration numerically for a vehicle. The vehicle will start from stationary and travel a straight track with varying inclines until it reaches an end distance of about 1000m.
Drive Force: Engine: The engine is either on and off (depending on distance along the track, program will check 'status' between each step calculation), and if the engine is on, the force provided will be constant without delay.
The resistance forces I will have are:
Air Drag: = 0.5 * Density * Drag Area * Velocity^2 (Only Velocity^2 will change, all other variables constant)
Rolling Resistance = Mass * Gravity * Coefficient of rolling resistance (All values will be constant)
Incline = Mass * Gravity * Sine(incline in rads) (The incline will be obtained from an array which holds data for distance along track and incline at that point. Data is for every metre, therefore incline only changes every 1m)
The equation of motion on the vehicle in the direction of travel will be as follows :
Ma = FEngine - FAirDrag - FRolling - FIncline
However I struggle to realise how to turn this into Runge Kutta 4th order equations that will calculate distance travelled, velocity, velocity^2 and acceleration at each step calculation, say h = 0.1s.
I've seen examples of how it's done when there is just one force, where they use separation of variables. However I can't really get my head around doing it when there is more forces. I would think it should not be too hard given that all forces apart from AirDrag are either constant, or calculated to a numerical value from a separate data array.
Any help would be appreciated! Many thanks in advance
0 件のコメント
採用された回答
Jan
2018 年 5 月 2 日
It depends how your RK4 code is written. Remember that you have to convert the higher order equation to a system of equations of order 1 at first. In your case these are 2 equations, one for the velocity and one for the acceleration. All you "simulate" is the time, the position and the velocity. To get velocity^2 and acceleration you can simply evaluate the function with the formerly calculated position and velocity.
To do this, your RK4 must accept a vector as input. Because you did not post any code, it is hard to suggest any real code. But simply try to implement this advice and show us the code.
5 件のコメント
Ponmalar M
2021 年 7 月 23 日
編集済み: Jan
2021 年 7 月 23 日
input t in the function f(v,t) is not used? how it will be when we write for position?
Jan
2021 年 7 月 23 日
@Ponmalar M: Usually the function to be integrated is written as f(t,y), where y is a vector containing the position and the velocity as y(1) and y(2).
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
