1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Recursive model for body in fluid

  1. Jul 31, 2013 #1
    Good evening,

    I've been trying to wrap my head around this problem for some time and I just can't seem to get it straight.

    What I am trying to achieve:
    I want to program a recursive model that calculates the position of a moving body in a fluid after a certain time.

    What i have done already
    I got as far as to simulate the movement due to a force applied at the center of the object.
    In pseudo-code
    for the speed at t = n
    //calculate the drag force due to vn-1 Wikipedia reference
    Fd = 0.5*ρ*vn-12*Cd*A //
    // add any external force that may have been applied when n-1<=t<n and the gravitational force
    Ftot= Fd+Fext+Fg
    // calculate the acceleration of the object at n
    an=Ftot/m
    // assume the acceleration constant for dt so the velocity becomes
    v = vn-1 + an*dt
    // calculate the new coordinates of the object based on vn

    This works fine as long as the time step dt is small enough (0<dt<0.00001)
    The amount of calculations is too high. So i decided to approximate some more by limiting the rate of change of the drag force Fd.est = MAX(const,Fd)
    This leads to a decent approximation with about a factor 100 less calculations per second (0<dt<0.001), which i think is sufficient. I observed a 10% disparity between the original and the approximation after 10^7 iterations.

    What i'm struggling with
    1) I'm stumped on how to model the angular motion when a force is applied a distance d from the center of the object
    2) Is there a way to make the approximate the whole model more precisely but with the same dt = 0.001

    If anyone has tips on how I can improve I would greatly appreciate it.

    MrsTMouse
     
  2. jcsd
  3. Jul 31, 2013 #2
    For off-center forces, you will have to compute the produced torques and solve another equation for angular motion.

    To compute things more efficiently, you will need to learn some numerical methods for ordinary differential equations. Your method, by the way, is known as Euler's method.
     
  4. Aug 1, 2013 #3
    My dynamics are not what they ought to be. Could you provide an example calculation for the torque and the angular motion equations?
    Is there a numerical method for ODE s that I can readily apply or if not, is there free literature I can read up in?

    Thanks for the help, much appreciated.
     
  5. Aug 1, 2013 #4
    First, you need to determine the center of mass and the moment(s) of inertia of your body. Then you need to determine the net torque of the forces (relative the center of mass). Then you will have an equation very similar to Newton's second law. Look up the details on Wikipedia, if unclear, ask for help here.

    To solve an ODE, I would try by default one of the Runge-Kutta integrators. Wikipedia is your friend again.
     
  6. Aug 1, 2013 #5
    So for the off-center forces:
    // calculate all moments due to forces that apply on the body (drag, external, gravity = 0 due to symmetry)
    Fd= 0.5*A*Cd*ρ*ωn-12
    Mdrag = Fd*r where r = radius of the object(assuming the object is symmetrical)
    Mext = Fext*x where x is the distance to to centre of mass
    // calculate angular acceleration
    α = Mtot/I
    // calculate angular speed
    ωnn-1+α*dt
    // calculate new angle of the body
    θnn-1n*dt

    For the runge kutta methods. If I understood correctly I would want to calculate the (angular) velocity with it by doing above calculations 4 times with
    k1 : euler
    k2 : dt = dt/2 and vn-1 = vn-1 + k1*dt/2
    k3 : dt = dt/2 and vn-1 = vn-1 + k2*dt/2
    k4 : dt = dt and vn-1 = vn-1 + k3*dt

    and then vn = vn-1 + dt/6(k1+2k2+2k3+k4)

    and the new coordinates are then pn = pn-1 + vn*dt
     
  7. Aug 1, 2013 #6

    AlephZero

    User Avatar
    Science Advisor
    Homework Helper

    The first part of that looks OK, but the last part
    pn = pn-1 + vn*dt

    is throwing all improved accuracy away, because it is just the same as Euler's forward difference method!

    You need to rewrite your second-order differential equation as two coupled first order equations and then solve both of them together using R-K. Any examples of solving equations of motion usiing R-K (on the web or in a textbook) should show you how to do it right. (Or search PF for other threads about RK, this sort of question comes up fairly often).

    Also, it's not obvious from your equations that you will always have the correct sign for the drag force. Remember the force changes direction if the velocity is reversed, but ##v^2## does mot change sign when ##v## goes from positive to negative. Maybe you want to calcule ##v | v | ## instead (i.e. ##v## times the absolute value of ##v##.)
     
  8. Aug 2, 2013 #7
    If your object is a sphere, then drag should not have any torque.

    Secondly, a rotating body, even a sphere, produces greater drag, but I do not remember any details on that.
     
  9. Aug 2, 2013 #8
    I made my calculations for a ring. So surface fri tion is much smaller than the drag.

    I will try to rewrite my ode s as coupled first order equations as soon as I get some free time.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook