Rocketry Analysis

download Rocketry Analysis

of 47

Transcript of Rocketry Analysis

  • 7/27/2019 Rocketry Analysis

    1/47

    Rocketry Theory, Part 2:More Numerical Analysis and MATLAB

    Tim BretlUniversity of Illinois at Urbana-Champaign

    AE100SDOctober 7, 2010

    http://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    2/47

    Deriving Euler Integration

    http://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    3/47

    The equation of rocket motion

    We derived the following:

    mRvR=TmRg kv2R

    Some terms may be functions of time:

    the rocket velocity vR

    the rocket mass mR

    the thrust T

    Some terms will always be assumed constant:

    the acceleration of gravity g

    the drag constant k= 12airARCD

    http://find/
  • 7/27/2019 Rocketry Analysis

    4/47

    Solving the rocket equation in simple cases

    Neglect drag and assume T and mRare constant:

    mRvR=TmRg

    Rearrange:

    vR= T

    mR g

    Integrate:

    vR(t) =vR(0) +

    t0

    T

    mR g

    ds

    = 0 +TmR

    g t=

    T

    mR g

    t

    http://find/
  • 7/27/2019 Rocketry Analysis

    5/47

    Solving the rocket equation in less simple cases (1)

    Restore drag but still assume T and mRare constant:

    mRvR=TmRg kv2RRearrange:

    vR= TmR

    g kmR

    v2R

    Integrate:

    vR(t

    ) =vR(0) +

    t0 TmR

    g

    k

    mRvR

    2 dsThat doesnt look right!

    http://find/
  • 7/27/2019 Rocketry Analysis

    6/47

    Solving the rocket equation in less simple cases (2)

    Its actually still possible to integrate this:

    vR= TmR

    g kmR

    v2R

    But we need to use some tricks from calculus:

    vRv=0

    TmR g

    k

    mRv21

    dv= ts=0

    ds

    The result can be found in a table of integrals:

    mRtanh1 k

    T

    mRg

    vRk(TmRg)

    =t

    vR(t) =

    TmRgk

    tanh

    tk(TmRg)

    mR

    http://find/
  • 7/27/2019 Rocketry Analysis

    7/47

    A different approach

    This is an ordinary differential equation:

    vR= T

    mR g k

    mRv2R

    It has a standard form:x=f(t, x)

    Equations of this form are, in general, easy to solvenumerically

    using a tool like MATLAB.

    http://find/
  • 7/27/2019 Rocketry Analysis

    8/47

    The basis for numerical integration

    t0 t

    x(t0)

    x(t)

    t t0

    x(t) x(t0) + x(t0) (t t0)

    x(t0) (t

    t0)

    error

    http://find/
  • 7/27/2019 Rocketry Analysis

    9/47

    Where it comes from

    The following is a good approximation when t t0:x(t) x(t0) + x(t0) (t t0)

    This is the linear part of a Taylors series expansion:

    x(t) =x(t0) + x(t0) (t t0) +12x(t0) (t t0)2 +

    It also corresponds to our notion of what a derivativeis:

    x(t0) = limtt0

    x(t) x(t0)t t0

    http://goforward/http://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    10/47

    How we use it

    Given x(0) and a fixed time step t, iterate:

    x(t+ t) x(t) +f(t, x(t))tThis algorithm is calledEuler integration.

    http://find/
  • 7/27/2019 Rocketry Analysis

    11/47

    Application to the rocket equation

    Assume T= 20, mR= 1, g= 10, and k= 1:

    vR= T

    mR g k

    mRv2R

    = 10 v2RChoose the time step t= 0.1 and iterate:

    vR(0.1) =vR(0) +

    10 vR(0)2

    t

    = 0 + (10 0) 0.1= 1

    vR(0.2) =vR(0.1) +

    10 vR(0.1)2

    t

    = 1 + (10 1) 0.1= 1.9

    http://find/
  • 7/27/2019 Rocketry Analysis

    12/47

    Compare to the exact expression

    We have found:

    vR(0.1) = 1vR(0.2) = 1.9

    The exact solution was:

    vR(t) =

    TmRgk

    tanhtk(TmRg)

    mR

    =

    10 tanht

    10

    Plug in to find the exact values:

    vR(0.1) = 0.968

    vR(0.2) = 1.770

    http://find/
  • 7/27/2019 Rocketry Analysis

    13/47

    Implementing Euler Integration Using MATLAB(see example.m)

    http://find/
  • 7/27/2019 Rocketry Analysis

    14/47

    % Clean up the workspace.

    clear;

    clc;

    What it means:

    Forget all previously defined variables Erase the command window

    In other words,give me a new sheet of paper.

    Why:

    Dont accidentally reference an old variable (doing so now willcause an error, so it will be easy to debug)

    Dont get confused looking at the results of old scripts

    http://find/
  • 7/27/2019 Rocketry Analysis

    15/47

    % Define constants.

    T = 2 0 ;

    m R = 1 ;

    g = 1 0 ;k = 1 ;

    % Choose a time step.

    dt = 0.1;

    % Choose a time horizon.

    tmax = 1;

    What it means:

    Assign a value of 20 to the variable T, etc.

    You can now write Tinstead of 20 whenever you want

    Why:

    Makes code easier to read (matches formula on paper)

    Changing the value ofT is easy

    http://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    16/47

    % Define an array of times.

    t = 0:dt:tmax;

    What it means:

    Create a list of numbers

    0 t 1 t 2 t N t

    such that N t tmax and (N+ 1) t>tmax Its anarray, or arow vector, or amatrix of size 1 N

    Why:

    Define it b/c its a compact way to store a lot of numbers

    Define it this way b/c t(1) = 0 t, t(2) = 1 t, etc., istedious and error-prone

    http://find/
  • 7/27/2019 Rocketry Analysis

    17/47

    % Define the initial condition.

    vR(1) = 0;

    % Iterate to use Euler integration.

    for i=2:length(t)vR(i) = vR(i-1) + ((T/mR)-g-((k/mR)*vR(i-1)2))*dt;

    end

    What it means (Euler integration):

    Given vR(0) = 0 and a fixed time step t, iterate:

    vR(t+ t) vR(t) +T

    mR g k

    mRv2R

    t

    NOTE:() means a different thing for us vs. MATLAB!Why:

    The use offorallows you torepeat exactly the sameprocessmany times but write it only once

    Less tedious, fewer errors, easier to changeanddebug

    http://find/
  • 7/27/2019 Rocketry Analysis

    18/47

    These things are equivalent:

    % Define the initial condition.vR(1) = 0;

    % Iterate to use Euler integration.

    for i=2:length(t)

    vR(i) = vR(i-1) + ((T/mR)-g-((k/mR)*vR(i-1)2))*dt;

    end

    % Define the initial condition.

    vR(1) = 0;

    % Iterate to use Euler integration.

    vR(2) = vR(1) + ((T/mR)-g-((k/mR)*vR(1)2))*dt;vR(3) = vR(2) + ((T/mR)-g-((k/mR)*vR(2)2))*dt;

    vR(4) = vR(3) + ((T/mR)-g-((k/mR)*vR(3)2))*dt;

    % etc.

    http://find/
  • 7/27/2019 Rocketry Analysis

    19/47

    % Compute the exact values for comparison.

    vR Exact = sqrt((T-mR*g)/k)*tanh(t*sqrt(k*(T-mR*g))/mR);

    What it means:

    Evaluate

    vR(t) =

    TmRg

    k tanh

    tk(T mRg)

    mR

    at every value of t in our list t, and put the result in a new

    list called vR Exact We call this anelement-wiseoperation

    Both t and vR Exact will have the same size

    http://find/
  • 7/27/2019 Rocketry Analysis

    20/47

    % Display the results as text.

    [t' vR' vR Exact']

    What it means:

    Take the row vectors t, vR, and vR Exact, transpose them to

    get column vectors, and insert these side-by-side in a matrix If each row vector is 1 N, the matrix is N 3

    Why:

    Column vectors are easier to view in the command window

    Putting data side-by-side makes it easier to compare

    Eyeballing the data is one way to debug

    http://find/
  • 7/27/2019 Rocketry Analysis

    21/47

    % Plot the results.

    figure(1);

    clf;

    plot(t,vR,'r.-',t,vR Exact,'ko-');

    xlabel('time');ylabel('velocity');

    legend('Euler','Exact');

    axis([0,tmax,0,5]);

    grid on;

    http://find/
  • 7/27/2019 Rocketry Analysis

    22/47

    % Plot the results.

    figure(1);

    clf;

    plot(t,vR,'r.-',t,vR Exact,'ko-');

    What it means:

    Switch to the figure named 1 if it exists, otherwise create it

    Erase everything in this figure

    Plot the approximate value ofvR(t) as a red line, with eachdata point as a red dot

    Plot the exact value ofvR(t) as a black line, with each datapoint as a black circle

    http://find/
  • 7/27/2019 Rocketry Analysis

    23/47

    xlabel('time');

    ylabel('velocity');

    legend('Euler','Exact');

    axis([0,tmax,0,5]);

    grid on;

    What it means:

    Label the xaxis time

    Label the yaxis velocity

    Add a legend that says the red line is approximate (from Eulerintegration) and the black line is exact

    Make the xaxis run from 0 to tmax

    Make the yaxis run from 0 to 5

    Draw a grid, making it easier to interpret the results

    http://find/
  • 7/27/2019 Rocketry Analysis

    24/47

    Dropping Assumptions

    Making thrust a function of time (1)

    http://find/
  • 7/27/2019 Rocketry Analysis

    25/47

    Making thrust a function of time (1)

    Time (s)

    Thrust (N)266110

    0.1 1.7 1.8Figure: A typical thrust profile for motors like ours. It is piecewise-linear,with a totalburn timeof 1.8 seconds.

    Making thrust a function of time (2)

    http://find/
  • 7/27/2019 Rocketry Analysis

    26/47

    Making thrust a function of time (2)

    Time(s)

    Thrust (N)266110

    0.1 1.7 1.8

    T =

    0 +26600.10

    (t 0) if 0 t

  • 7/27/2019 Rocketry Analysis

    27/47

    Making thrust a function of time (3)

    T =

    0 + 26600.10 (t0) if 0

    t

  • 7/27/2019 Rocketry Analysis

    28/47

    Making mass a function of time

    mR=

    mrocket+mpropellant

    1 t

    1.8

    if t

  • 7/27/2019 Rocketry Analysis

    29/47

    Making drag point in the right direction (1)

    The drag term is

    D= k

    mRv2

    R

    where

    k=1

    2AIRARCD,

    i.e., its a force that points down. This is only correct if the rocketis going up! In general

    D=

    k

    mRv2R ifvR 0

    kmR

    v2R ifvR

  • 7/27/2019 Rocketry Analysis

    30/47

    Making drag point in the right direction (2)

    D=

    kmR

    v2R ifvR

    0

    kmR

    v2R ifvR= 0)

    D = -(k/mR)*(vR(i-1)2)

    elseD = (k/mR)*(vR(i-1)2)

    end

    D= kmRv2R vR

    |vR|

    D = -(k/mR)*(vR(i-1)2)*(vR(i-1)/abs(vR(i-1)))

    Other assumptions

    http://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    31/47

    Other assumptions

    We have made other assumptions along the way:

    gravity is constant with altitude

    air density is constant with altitude

    motion is entirely vertical

    no wind (at least, none that affects vertical motion)

    etc.

    Effects are negligible, so we will continue to ignore them.

    http://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    32/47

    Uncertain Parameters and Real Data

    The exact value ofCD is unknown

    http://find/
  • 7/27/2019 Rocketry Analysis

    33/47

    D

    The drag term is

    D= k

    mRv2R

    vR

    |vR|

    where

    k=1

    2AIRARCD.

    The coefficient of drag CDis hard to predict exactly, and in many

    cases must be estimated from experimental data. How?

    A similar but simpler problem

    http://find/
  • 7/27/2019 Rocketry Analysis

    34/47

    p p

    Say the position xof an object as a function of time t is

    x(t) = sin (ct) ,

    where c is an unknown constant in the range

    cmin c cmax.

    Given experimental data

    xmeas(t1), . . . , xmeas(tn)

    collected at times t1, . . . , tn, how might we estimate c?

    What makes for a good estimate of c?

    http://find/
  • 7/27/2019 Rocketry Analysis

    35/47

    g

    A guess at cgives us the prediction

    x(t1) = sin (ct1) , . . . , x(tn) = sin (ctn) .

    Define theprediction errorassociated with this guess by

    (x(t1) xmeas(t1))2

    + + (x(tn) xmeas(tn))2

    ,

    or in other words by

    n

    i=1

    (x(ti)xmeas(ti))

    2 .

    A good guess is one that results in minimum prediction error.

    Some notation

    http://find/
  • 7/27/2019 Rocketry Analysis

    36/47

    Make the dependence of prediction error on cclear by writing

    x(t, c) = sin(ct)

    and

    e(c) =

    ni=1

    (x(ti, c) xmeas(ti))2 .

    An algorithm to find a good estimate of c

    http://find/
  • 7/27/2019 Rocketry Analysis

    37/47

    1. Sample m guesses according to

    ck=cmin+

    k 1m 1

    cmax

    fork= 1, . . . ,m

    2. Compute the prediction error

    e(ck) =n

    i=1

    (x(ti, ck) xmeas(ti))2

    associated with each guess3. Choose the estimate c=ck, where

    k = arg minke(ck)

    How to implement this algorithm in MATLAB (1)

    http://find/
  • 7/27/2019 Rocketry Analysis

    38/47

    Sample m guesses according to

    ck=cmin+

    k 1m 1

    cmax

    fork= 1, . . . ,m

    % Define the possible range of c values

    cmin = 0;

    cmax = 10;

    % Define the number of guesses to make

    m = 5 0 ;% Generate m guesses, equally spaced from cmin to cmax

    c = linspace(cmin,cmax,m);

    How to implement this algorithm in MATLAB (2)

    http://find/
  • 7/27/2019 Rocketry Analysis

    39/47

    Compute the prediction error

    e(ck) =

    ni=1

    (x(ti, ck) xmeas(ti))2

    associated with each guess

    % Load the experimental data

    % (first column is time, second column is position)

    load sinusoid.data

    t = sinusoid(:,1);

    xmeas = sinusoid(:,2);

    % Loop to compute the prediction errorfor k=1:m

    x = sin(c(k)*t);

    e(k) = sum((x-xmeas).2);

    end

    How to implement this algorithm in MATLAB (3)

    http://find/
  • 7/27/2019 Rocketry Analysis

    40/47

    Choose the estimate c=ck, where

    k = arg minke(ck)

    % Find the value of c giving minimum error

    [emin,kmin] = min(e);

    cest = c(kmin)

    Example results (see parameter.m)

    http://find/
  • 7/27/2019 Rocketry Analysis

    41/47

    0 0.2 0.4 0.6 0.8 12

    1.5

    1

    0.5

    0

    0.5

    1

    1.5

    2Results of Best Fit: c=5.95

    time

    position

    predicted

    measured

    0 2 4 6 8 100

    10

    20

    30

    40

    50

    60

    70

    80

    90

    100Error for Different Values of c

    c

    predictione

    rror

    An important note

    http://find/
  • 7/27/2019 Rocketry Analysis

    42/47

    This approach only makes sense for certain assumptions about the

    data, which we will not discuss.

    http://find/
  • 7/27/2019 Rocketry Analysis

    43/47

    Homework

    Problem 1

    http://find/
  • 7/27/2019 Rocketry Analysis

    44/47

    The data in decay.data was generated by the process

    x(t) =ebt sin(ct) ,

    where c= 6 but b is known only to be between 0 and 5. Write aMATLAB script that estimates the value ofband produces two

    sub-plots showing the results of the best fit and the error fordifferent values ofb, just as in the example parameter.m.

    Name your script netidP1.m, where netid is your NetID (i.e.,

    the start of your @illinois.edu

    email address). Attach it to anemail and send it to Shreyas Narsipur ([email protected])by Monday, October 25.

    Problem 2

    http://localhost/var/www/apps/conversion/tmp/scratch_3/[email protected]://localhost/var/www/apps/conversion/tmp/scratch_3/[email protected]://find/
  • 7/27/2019 Rocketry Analysis

    45/47

    The data in rocket.data is from a rocket with parameters

    Duration of burn tb= 1.8s

    Time delay after burn is over before parachute opens td= 13s Mass of rocket mrocket= 1.8934kg

    Mass of propellant mpropellant= 0.178kg

    Acceleration of gravity g= 9.81m/s2

    Air density AIR = 1.23kg/m3

    Rocket diameter d= 3 inches

    Thrust:

    Time (s)

    Thrust (N)266110

    0.1 1.7 1.8

    Problem 2, cont.

    http://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    46/47

    Write a MATLAB script that estimates the value ofCD andproduces two sub-plots showing the results of the best fit and theerror for different values ofCD, just as in the previous problem.

    Name your script netidP2.m, where netid is your NetID (i.e.,the start of your @illinois.edu email address). Attach it to anemail and send it to Shreyas Narsipur ([email protected])by Monday, October 25.

    Collaboration

    http://localhost/var/www/apps/conversion/tmp/scratch_3/[email protected]://localhost/var/www/apps/conversion/tmp/scratch_3/[email protected]://find/http://goback/
  • 7/27/2019 Rocketry Analysis

    47/47

    You are encouraged to work together on these problems, but pleasestate explicitly (in your MATLAB scripts) who you worked with andwhat each person did. Each of you must submit a script separately.

    http://goforward/http://find/http://goback/