P2820 Final Exam F2014

Name:
Student number:

There are 3 questions for a total of 50 marks.  This is a 2-hour, open book exam.

Q1	[20 marks]

A projectile of mass m=1 is shot from ground level at a certain (fixed) initial speed v0 into the air at an elevation angle θ over a level field.  Air resistance gives a drag force of (Subscript[F, b]) = - b v. The initial speed v0 and the drag coefficient b are unknown. To find the values of v0 and b a P2820 student devises an experiment. He measures the horizontal range R traveled by the mass when thrown at different  angles 0.05<θ<1.25 rad. The results from this experiment are recorded in the following table including all observations of pairs {θ, R[θ]}:

xDist={{0.05`,1.0116010321314566`},{0.060000000000000005`,1.381547518022002`},{0.07`,1.422851146493505`},{0.08`,1.673497871661705`},{0.09`,1.8449322197363898`},{0.1`,2.0249423559662203`},{0.11`,2.180172878454263`},{0.12000000000000001`,2.405446912820338`},{0.13`,2.644995484161336`},{0.14`,2.7129347379872604`},{0.15000000000000002`,3.020853024234439`},{0.16`,3.2207144528860425`},{0.16999999999999998`,3.3840433007187483`},{0.18`,3.465898811252135`},{0.19`,3.6150541344465354`},{0.2`,3.790976396123832`},{0.21000000000000002`,4.054652815059115`},{0.22000000000000003`,4.189292473753463`},{0.22999999999999998`,4.324770529817089`},{0.24`,4.5561401505818875`},{0.25`,4.548825810938971`},{0.26`,4.882146949845632`},{0.27`,4.834101705078886`},{0.28`,5.165757604716986`},{0.29`,5.129405019403531`},{0.3`,5.277559528075965`},{0.31`,5.571167425644019`},{0.32`,5.633252106129286`},{0.33`,5.804602451595913`},{0.33999999999999997`,5.949890151890637`},{0.35`,6.063362408932551`},{0.36`,6.073166237430271`},{0.37`,6.17580748451891`},{0.38`,6.421790932144357`},{0.39`,6.593725920343295`},{0.4`,6.567747094791329`},{0.41`,6.668789021600861`},{0.42`,6.792251491134132`},{0.43`,6.971926202449814`},{0.44`,6.924437441795122`},{0.45`,7.113690580189311`},{0.46`,7.251835605869654`},{0.47`,7.242749596298699`},{0.48`,7.307965460546116`},{0.49`,7.445927137100185`},{0.5`,7.589429467454297`},{0.51`,7.564316930602532`},{0.52`,7.631021690786621`},{0.53`,7.73566533950924`},{0.54`,7.858496399488505`},{0.55`,7.864383547215359`},{0.56`,7.990707272955425`},{0.5700000000000001`,8.042773228893878`},{0.5800000000000001`,8.136132408090466`},{0.5900000000000001`,8.141381657177108`},{0.6000000000000001`,8.1677310297739`},{0.6100000000000001`,8.223958108839897`},{0.6200000000000001`,8.175088076810049`},{0.63`,8.309088598311673`},{0.64`,8.259016419074404`},{0.65`,8.308697066279299`},{0.66`,8.427739607442131`},{0.67`,8.470304841015851`},{0.68`,8.352811208922754`},{0.6900000000000001`,8.495165991227283`},{0.7000000000000001`,8.354816524280585`},{0.7100000000000001`,8.482035910832202`},{0.7200000000000001`,8.371700181515731`},{0.7300000000000001`,8.445264282871008`},{0.7400000000000001`,8.427373412898028`},{0.7500000000000001`,8.442449987511427`},{0.76`,8.524932744967685`},{0.77`,8.350150982420027`},{0.78`,8.462498377929093`},{0.79`,8.321526724643412`},{0.8`,8.324293365386767`},{0.81`,8.340822071116527`},{0.8200000000000001`,8.399956673919231`},{0.8300000000000001`,8.290654278332148`},{0.8400000000000001`,8.300765332258196`},{0.8500000000000001`,8.29154017272723`},{0.8600000000000001`,8.226802578324564`},{0.8700000000000001`,8.207548087288572`},{0.8800000000000001`,8.08857745893439`},{0.89`,8.04732350841782`},{0.9`,8.078009889569541`},{0.91`,8.027481211621655`},{0.92`,7.834130577276938`},{0.93`,7.855495211930035`},{0.9400000000000001`,7.828364017442264`},{0.9500000000000001`,7.649321967801528`},{0.9600000000000001`,7.761900474715716`},{0.9700000000000001`,7.702197017788451`},{0.9800000000000001`,7.482371351688754`},{0.9900000000000001`,7.474602924280353`},{1.`,7.488002126690163`},{1.01`,7.383355675813421`},{1.02`,7.228448988341683`},{1.03`,7.135929853569095`},{1.04`,7.11787223772107`},{1.05`,6.965060776843055`},{1.06`,6.916459506670459`},{1.07`,6.695782312950001`},{1.08`,6.627276653690919`},{1.09`,6.640501495133291`},{1.1`,6.410622478035796`},{1.11`,6.360384038753192`},{1.12`,6.359259658926957`},{1.1300000000000001`,6.159402955564148`},{1.1400000000000001`,6.0417840533780796`},{1.1500000000000001`,5.982331578041174`},{1.1600000000000001`,5.912155356723923`},{1.1700000000000002`,5.825901867887926`},{1.1800000000000002`,5.667783048805525`},{1.1900000000000002`,5.517173882126599`},{1.2000000000000002`,5.461684719819224`},{1.21`,5.359897091803788`},{1.22`,5.143896295343405`},{1.23`,5.120911552545484`},{1.24`,4.969477073322874`},{1.25`,4.6874224706374275`},{1.26`,4.53908296500306`},{1.27`,4.519075858348695`},{1.28`,4.2938977818453585`},{1.29`,4.270630607483743`},{1.3`,4.074682911957851`},{1.31`,3.9769959894859106`},{1.32`,3.9198573666940657`},{1.33`,3.7808287675625607`},{1.34`,3.510192400387396`},{1.35`,3.3561848389189572`},{1.36`,3.1916602769793223`},{1.37`,3.1420673927830767`},{1.3800000000000001`,3.076759253041022`},{1.3900000000000001`,2.8680851903574944`},{1.4000000000000001`,2.6578313468493295`},{1.4100000000000001`,2.576842078242927`},{1.4200000000000002`,2.350301040055877`},{1.4300000000000002`,2.171225468053325`},{1.4400000000000002`,2.0938343875799945`},{1.4500000000000002`,1.9904341987041836`},{1.46`,1.854167162717184`},{1.47`,1.570865514822946`},{1.48`,1.5162586002698806`},{1.49`,1.364868034038065`},{1.5`,1.2455459726473368`}};

(a) Use DSolve to solve equations of (2^nd) Newton's law for the projectile motion with initial speed v0, elevation angle θ, and drag coefficient b. Assume g=9.81m/(s^2).

vyi=v0 Sin[θ];
vxi=v0 Cos[θ];
m=1;g=9.81;
eq1=m*y''[t]==-m*g-b*y'[t];eq2=m*x''[t]==-b*x'[t];
sol=DSolve[{eq1,x[0]==0,x'[0]==vxi,eq2,y[0]==0,y'[0]==vyi},{x[t],y[t]},t]//Simplify

X[t_]=x[t]/.sol[[1]]
Y[t_]=y[t]/.sol[[1]]

(c) Determine the time it will take for the mass to hit the ground as function of b, v0 and θ.

tsol=Solve[Y[t]==0,t];
tg=t/.tsol[[1]]

(d) Define the maximum horizontal distance R[θ], or range of the projectile, traveled by the mass as function of θ.

R[θ_]=X[tg]

(e) Use  nonlinm NonlinearModelFit to fit the solution R[θ] for the range of the projectile with the observations xDist and find values of b and v0. The student estimated roughly the the value of v0 to be about 5 m/s and assume b is close to 0.1. You can use these values to define the first approximation of the two parameters in NonlinearModelFit:

nonlinm=NonlinearModelFit[xDist,R[θ],{{b,0.1},{v0,5}},θ]

(f) Report the values of b and (Subscript[v, 0]) and the standard errors of their estimation.

nonlinm["ParameterTable"]

Q2	[20 marks]

A mass of m=3 kg is attached to a non-ideal spring with potential energy (in J) given by 
U(x) =(1/2) k (x^(2 ))+ β (x^4), 
where x is the position of the mass, k=3 (N/m), β=2(N/(m^3)).  Additionally, there is a oscillating external driving force given by, 
F(t)= (Subscript[F, 0])*Sin( ω t),  ω=(1/4)(Sqrt[(k/m)]) 
as well as a drag force of magnitude γ (v^2) (acting in the opposite direction to the motion of the mass), where v is the velocity of the mass and γ=0.5.

Remove["Global`*"]

a) What is the (conservative) force on the particle due to the potential energy?  Write a function that returns this conservative force as a function of the position of the mass. Plot potential energy and conservative force as functions of spatial coordinate x:

m=3;k=3;β=2;ω=1/4 Sqrt[k/m];γ=0.5;

U[x_]=1/2 k x^2+ β x^4

Fc[x_]=-D[U[x],x]

Plot[U[x],{x,-10,10}]

Plot[Fc[x],{x,-4,3}]

b) What is the net force on the particle?  Write a function that returns the net force as a function of the position of the mass, its velocity, amplitude of external force (Subscript[F, 0]) and the time. Use your function to report the initial force on the particle, given that at t=0 its position is  xinit = 3 m, (Subscript[F, 0])=0 and its velocity is vinit = -10 m/s.

Fnet[x_,v_,t_,F0_]:=Fc[x]+F0*Sin[ω t]-γ*v*Abs[v]
xinit=3;vinit=-10;tinit=0;F0=0;
Fnet[xinit,vinit,tinit,F0]

c) Assume (Subscript[F, 0])=0. Use Mathematica’s built-in ODE solving capability to find the mass’s position as
   a function of time up to tf = 80s.  Plot the position as a function of time.

tf=80;
m=3.2;F0=0;
sol=NDSolve[{m x''[t]==Fnet[x[t],x'[t],t,F0],x[0]==xinit,x'[0]==vinit},x[t],{t,0,tf}];
X[t_]=x[t]/.sol[[1]];
Plot[X[t], {t, 0, tf}]

d) Plot the evolution of the oscillator in a coordinate system where velocity is ploted as a function
      of position (Hint: Use ParametericPlot).

ParametricPlot[{X[t],X'[t]},{t,0,tf},{PlotRange->All}]

e) Repeat part c) and  d), except now set (Subscript[F, 0])=5N and use the midpoint scheme or  4th-order Runge-Kutta algorithm from class.  Use a timestep of Δt=0.05.

Δt=0.05;F0=5;
nmax=Round[tf/Δt];
x[1]=xinit;
u[1]=vinit;
t[1]=tinit;
fx[x_,u_,t_]:=u;
fu[x_,u_,t_]:=Fnet[x,u,t,F0]/m;
Do[t[n+1]=t[n]+Δt;
sx1=fx[x[n],u[n],t[n]];
su1=fu[x[n],u[n],t[n]];
xtmp=x[n]+Δt sx1/2;
utmp=u[n]+Δt su1/2;
sx2=fx[xtmp,utmp,t[n]+Δt/2];
su2=fu[xtmp,utmp,t[n]+Δt/2];
xtmp=x[n]+Δt sx2/2;
utmp=u[n]+Δt su2/2;
sx3=fx[xtmp,utmp,t[n]+Δt/2];
su3=fu[xtmp,utmp,t[n]+Δt/2];
xtmp=x[n]+Δt sx3;
utmp=u[n]+Δt su3;
sx4=fx[xtmp,utmp,t[n]+Δt];
su4=fu[xtmp,utmp,t[n]+Δt];
x[n+1]=x[n]+Δt (sx1+2 sx2+2 sx3+sx4)/6;
u[n+1]=u[n]+Δt (su1+2 su2+2 su3+su4)/6,{n,1,nmax}]
xN=Interpolation[Table[{t[n],x[n]},{n,1,nmax+1}]];
uN=Interpolation[Table[{t[n],u[n]},{n,1,nmax+1}]];
Plot[xN[t],{t,0,tf},PlotRange->All]

ParametricPlot[{xN[t],uN[t]},{t,0,tf},{PlotRange->All}]

Q3	[10 marks]

Consider heat conduction along a straight, insulated bar.  The time evolution of the temperature η along the bar (x is a position along the bar) satisfies a PDE called the heat equation,
		((∂ η)/(∂ t))=α(((∂^2) η)/(∂ (x^2)))
on x ϵ [0, L], t ϵ [0, 15s], where α=0.1(m^2)/s is the thermal diffusivity of the bar, L=3m is the length of the bar, and initial and boundary conditions are given by

	η(x,t=0)=300 Exp[-(((x-L/4)^2)/0.05)]  (initial temperature profile in degrees celsius)
	
	η(x=0,t)=0;                                              η(x=L,t)=0
	

	
The boundary conditions mean that no heat enters or leaves the bar.

Remove["Global`*"]

(a) Use NDSolve to solve for the temperature of the bar as a function of position and time. Plot the solution. (Hint: use  ContourPlot).

c=0.1; L=3;T=15;
u[x_, t_] = η[x, t] /. NDSolve[{(∂_t)η[x,t] == c (∂_(x,x))η[x,t], η[x,
        0] == 300 Exp[-((x - 1)^2/0.05)], η[0, t] == 
      0, η[L, t] == 0}, η[x, t], {x, 0, L}, {t, 0, T}][[1]];
ContourPlot[u[x,t],{x,0,3},{t,0,3},PlotRange->All]

(b) Repeat (a) except now use the numerical algorithm from class. Discretize the equation by using a backward difference scheme for the ∂η/∂t and centered scheme for (∂^2)η/∂(x^2). Solve the equation numerically.  Use a timestep of Δt=0.05s and Δx=0.1m. Plot the solution. (Hint: Use ListContourPlot)

(*Grid size and timestep*)Δx=0.1;
Δt=0.05;
nmax=Round[T/Δt];
imax=Round[L/Δx]+1;
A=300;λ=0.05;
η0=0;
Do[x[i]=(i-1) Δx,{i,1,imax}];
t[1]=0;
Do[η[i,n]=A Exp[-((x[i]-1)^2/λ)],{i,1,imax},{n,0,1}];
Do[{t[n+1]=n Δt,η[i,n+1]=Δt*c ((η[i+1,n]-2 η[i,n]+η[i-1,n])/Δx^2)+η[i,n],η[1,n+1]=η[2,n+1],η[imax,n+1]=η[imax-1,n+1]},{n,1,nmax},{i,2,imax-1}]
Nsol=Table[η[i,n],{n,1,nmax},{i,1,imax}];

ListContourPlot[Nsol,DataRange->{{0,L},{0,T}},FrameLabel->{"x (m)","t(s)"},ColorFunction->Hue]