Similar presentations

3
Solving ODEs numerically Produce numeric solution to system of ODEs.Produce numeric solution to system of ODEs. Must have initial conditionsMust have initial conditions Use one of several different solversUse one of several different solvers Produces matrix of solutionsProduces matrix of solutions

5
Radioactive decay, Newton’s law of cooling etcRadioactive decay, Newton’s law of cooling etc A is amount of material, temperature difference, etcA is amount of material, temperature difference, etc k is rate constantk is rate constant Solution of First Order ODE

6
Forming the derivative vector “The derivative of A with respect to t is –k times A”“The derivative of A with respect to t is –k times A”

7
Initial Conditions First order ODEFirst order ODE –1 member of D(t,A) vector –1 member of ic vector Although only 1 member, still needs to be a vector

8
Solution parameters TStart and TFinish timesTStart and TFinish times Number of points, NNumber of points, N

9
Create Solution Matrix Use rkfixed() functionUse rkfixed() function Return matrix with 1 column per DE + 1 for independent variableReturn matrix with 1 column per DE + 1 for independent variable Use column operator to strip off columnsUse column operator to strip off columns

10
Plot Results

11
What can go wrong Found number greater than 10^307Found number greater than 10^307 –Use more points –Reduce TFinish Can’t have anything with dimensions hereCan’t have anything with dimensions here –Strip units from system before solution

23
Second Order System Define Initial Conditions Start with 1V across capacitor & no current flowingStart with 1V across capacitor & no current flowing

24
Second Order System Create Solution Examine over 0.1sExamine over 0.1s Use 1000 pointsUse 1000 points

25
Second Order System Plot Solution

26
Driven Systems So far all systems have been ‘Relaxation to steady state’So far all systems have been ‘Relaxation to steady state’ Can also model systems driven by ‘Forcing Function’Can also model systems driven by ‘Forcing Function’

27
Forcing Function for LCR circuit Enables us to see resonanceEnables us to see resonance Put voltage source in loopPut voltage source in loop

28
Solution for Forced Oscillation Use symbolic solver to solve for q2 as beforeUse symbolic solver to solve for q2 as before Compare with undriven case…Compare with undriven case…