Wednesday, April 23, 2014

Chapter 1

1.1 Use calculus to solve Eq. (1.9) for the case where the initial
velocity, v(0) is nonzero.

This took a while. I asked a few math professors and googled a bunch. I am thinking I should have taken linear algebra before taking this class. This is the result from wolframalpha.com as its is the nicest output I can make.

(1.9) is: dv / dt = g − (c / m) v




1.2 Repeat Example 1.2. Compute the velocity to t = 10 s, with a
step size of (a) 1 and (b) 0.5 s. Can you make any statement regarding
the errors of the calculation based on the results?

This is the algorithm I am going to use, in the book it is annotated as (1.12)


g = 9.8 m/s
m = 68.1 kg (parachutist's mass)
c = 12.5 kg/s (drag coefficient)

I made a program that does this for me in java.

public static LinkedList<BigDecimal> parachutist(double step, double time){
LinkedList<BigDecimal> list = new LinkedList<BigDecimal>();
list.add(new BigDecimal(0));
double g = 9.8, m = 68.1, c = 12.5;
for(double i = (0.0 + step); i <= time; i += step){
double vi = list.getLast().doubleValue();
list.add( new BigDecimal(
vi + (g - ((c/m) * vi)) * step
));
}
return list;
}

I also make a function in matlab to come up with similar answers:

function [ output ] = eulers( s )
g = 9.8; m=68.1;c=12.5;l = length(s) - 1; v = zeros(1,l + 1);
for i = 1:l
v(2:l+1) = v(1:l) + (g-((c*v(1:l))/ m)) * (s(2) - s(1));
end
output = v;
end

a) the results for t = 10 and step size = 1
t, s v, m/s
0.0 0
1.0 9.800000000000000710542735760100185871124267578125
2.0 17.80117474302496560767394839785993099212646484375
3.0 24.3337050765372708838185644708573818206787109375
4.0 29.6671659655722805837285704910755157470703125
5.0 34.02165092049660444217806798405945301055908203125
6.0 37.57685449602953298153806827031075954437255859375
7.0 40.47948766489341920760125503875315189361572265625
8.0 42.84933207295262747038577799685299396514892578125
9.0 44.784183014040621628737426362931728363037109375
10.0 46.3638851039744253057506284676492214202880859375

in matlab:
>> eulers(0:10)

ans =

         0    9.8000   17.8012   24.3337   29.6672   34.0217   37.5769   40.4795   42.8493   44.7842   46.3639


b) results for t = 10 and step = .5:
t, s v, m/s
0.0 0
0.5 4.9000000000000003552713678800500929355621337890625
1.0 9.35029368575624175718985497951507568359375
1.5 13.3921536632015207857193672680296003818511962890625
2.0 17.06306467061694576159425196237862110137939453125
2.5 20.39707121699938596748324926011264324188232421875
3.0 23.42509331529239346991744241677224636077880859375
3.5 26.17521323863193316583419800736010074615478515625
4.0 28.67293595902180669554581982083618640899658203125
4.5 30.941425683781186961596176843158900737762451171875
5.0 33.00172068343416498237274936400353908538818359375
5.5 34.87292840338330535132627119310200214385986328125
6.0 36.57240266885840895838555297814309597015380859375
6.5 38.115904626562297607961227186024188995361328125
7.0 39.51774891560760494257920072413980960845947265625
7.5 40.79093642335286773459301912225782871246337890625
8.0 41.94727485733296390435498324222862720489501953125
8.5 42.997488251483758858739747665822505950927734375
9.0 43.95131642223598333885092870332300662994384765625
9.5 44.8176052968472191651017055846750736236572265625
10.0 45.60438895168869777307918411679565906524658203125

in matlab:
>> eulers(0:.5:10)

ans =

  Columns 1 through 12

         0    4.9000    9.3503   13.3922   17.0631   20.3971   23.4251   26.1752   28.6729   30.9414   33.0017   34.8729

  Columns 13 through 21

   36.5724   38.1159   39.5177   40.7909   41.9473   42.9975   43.9513   44.8176   45.6044



1.4 For the free-falling parachutist with linear drag, assume a first
jumper is 70 kg and has a drag coefficient of 12 kg/s. If a second
jumper has a drag coefficient of 15 kg/s and a mass of 75 kg, how
long will it take him to reach the same velocity the first jumper
reached in 10 s?

this was my java answer:
At t = 15.684 the second parachutist has the same velocity as the first one after 10s.
I wrote a program to do this for me:

this is my matlab answer:
>> tps(0:.01:30) ans = 15.7100 >> tps(0:.001:30) ans = 15.6840

Here is the java code:
public static void main(String[] args) {
double step = 0.001, timeTo = 10.0;
LinkedList<BigDecimal> list = new LinkedList<BigDecimal>();
LinkedList<BigDecimal> list2 = new LinkedList<BigDecimal>();
list.add(new BigDecimal(0.0));
list2.add(new BigDecimal(0.0));
list = EulersMethod.parachutist(list, 0.0, step, timeTo, 70.0, 12.0);
list2 = EulersMethod.parachutist(list2, 0.0, step, 30.0, 75.0, 15.0);

for(int i = 0; i < list2.size(); i++){
if(list2.get(i).doubleValue() >= list.getLast().doubleValue()){
System.out.println("At t = " + (i * step) + " the second"
+ " parachutist has the same velocity as the first one after 10s." );
return;
}
}
}

public class EulersMethod {
public static LinkedList<BigDecimal> parachutist(LinkedList<BigDecimal> list, double startTime, double step, double timeTo, double m, double c){
double g = 9.8;
for(double i = (startTime + step); i <= timeTo; i += step){
double vi = list.getLast().doubleValue();
list.add( new BigDecimal(
vi + (g - ((c/m) * vi)) * step
));
}
return list;
}
}

here is the matlab code:
function [ output ] = tps( s )
    l = length(s) - 1;
    %f = 1;
    v1 = zeros(1,10/s(2));
    m = 75;
    c = 15;
    v = zeros(1,l);
    fp = eulers(v1, 0:s(2):10, 70, 12, 1);
    g = 9.8;
    i = 1;
    while (fp(length(fp)) > v(i))
        v(2:l+1) = v(1:l) + (g-((c*v(1:l))/ m)) * s(2);
        i = i + 1;
    end
    output = s(i);
end

function [ output ] = eulers( v, s, m, c, f )
    g = 9.8;
    l = length(s) - 1;
    for i = f:l
        v(f+1:l+1) = v(f:l) + (g-((c*v(f:l))/ m)) * (s(2) - s(f));
    end
    output = v;
end

1.5 Compute the velocity of a free-falling parachutist using Euler’s
method for the case where m = 80 kg and c = 10 kg/s. Perform the
calculation from t = 0 to 20 s with a step size of 1 s. Use an initial
condition that the parachutist has an upward velocity of 20 m/s at
t = 0. At t = 10 s, assume that the chute is instantaneously deployed
so that the drag coefficient jumps to 50 kg/s.

I wrote a program to do this for me:
EulersMethod.parachutist is the same code as the last question.

public static void main(String[] args) {
double step = 1.0;
LinkedList<BigDecimal> list = new LinkedList<BigDecimal>();
list.add(new BigDecimal(-20.0));
list = EulersMethod.parachutist(list, 0.0, step, 9.0, 80.0, 10.0);
list = EulersMethod.parachutist(list, 0.0, step, 11.0, 80.0, 50.0);

System.out.println("t, s\tv, m/s");
for(int i = 0; i < list.size(); i++)
System.out.println(i + "\t" + list.get(i));
}

output:
t, s v, m/s
0 -20
1 -7.699999999999999289457264239899814128875732421875
2 3.0625000000000017763568394002504646778106689453125
3 12.4796875000000024868995751603506505489349365234375
4 20.719726562500003552713678800500929355621337890625
5 27.92976074218750426325641456060111522674560546875
6 34.23854064941406960542735760100185871124267578125
7 39.75872306823730895075641456060111522674560546875
8 44.58888268470764870698985760100185871124267578125
9 48.81527234911919066462360206060111522674560546875
10 28.10572713091969632159816683270037174224853515625
11 20.339647674094887719320468022488057613372802734375
12 17.4273678777855849375555408187210559844970703125
13 16.3352629541695932857692241668701171875
14 15.925723607813598192706194822676479816436767578125
15 15.77214635293010047689676866866648197174072265625
16 15.714554882348789277557443710975348949432373046875
17 15.692958080880796245537567301653325557708740234375
18 15.6848592803302988585301136481575667858123779296875
19 15.68182223012386344862534315325319766998291015625
20 15.680683336296450391955659142695367336273193359375

matlab answer:
function [ output ] = eulers( v, s, m, c, f)
    g = 9.8;
    for i = f:length(s) - 1
        v(i+1) = v(i) + (g-((c*v(i))/ m));
    end
    output = v;
end

>> v = zeros(1,20);
>> v(1) = -20;
>> eulers(eulers(v, 1:20, 80, 10, 1), 1:20, 80,50,10)

ans =

  Columns 1 through 12

  -20.0000   -7.7000    3.0625   12.4797   20.7197   27.9298   34.2385   39.7587   44.5889   48.8153   28.1057   20.3396

  Columns 13 through 20

   17.4274   16.3353   15.9257   15.7721   15.7146   15.6930   15.6849   15.6818


1.6 The amount of a uniformly distributed radioactive contaminant
contained in a closed reactor is measured by its concentration c
(becquerel/liter or Bq/L). The contaminant decreases at a decay
rate proportional to its concentration—that is
decay rate = −kc
where k is a constant with units of day−1. Therefore, according to
Eq. (1.13), a mass balance for the reactor can be written as
dc
dt
= −kc

change
in mass

=

decrease
by decay

(a) Use Euler’s method to solve this equation from t = 0 to 1 d
with k = 0.2d−1. Employ a step size of t = 0.1. The concentration
at t = 0 is 10 Bq/L.
(b) Plot the solution on a semilog graph (i.e., ln c versus t) and determine
the slope. Interpret your results.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home