Presentation is loading. Please wait.

Presentation is loading. Please wait.

PH36010 Numerical Methods Solving Differential Equations using MATHCAD.

Similar presentations


Presentation on theme: "PH36010 Numerical Methods Solving Differential Equations using MATHCAD."— Presentation transcript:

1

2 PH36010 Numerical Methods Solving Differential Equations using MATHCAD

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

4 Steps to solving ODEs Scale equations, parameters & initial conditions to remove unitsScale equations, parameters & initial conditions to remove units Manipulate equations to give vector of derivativesManipulate equations to give vector of derivatives Give vector of initial conditionsGive vector of initial conditions Call solverCall solver Plot resultsPlot results

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

12 More complex first order system Double decayDouble decay A => B => CA => B => C K1 K2 K1 K2

13 Forming the derivative vector

14 Initial Conditions System of 2 DEsSystem of 2 DEs –2 members in D(t,F) vector –2 members in ic vector F 0 refers to A => ic 0F 0 refers to A => ic 0 F 1 refers to B => ic 1F 1 refers to B => ic 1 Initially 100% of A, 0% of B

15 Form Solution of Double Decay system Solution parameters as beforeSolution parameters as before Call rkfixed() as before to create matrixCall rkfixed() as before to create matrix

16 Plot results of double decay

17 Second Order System Damped SHM Rewrite as system of first order equationsRewrite as system of first order equations Solve as beforeSolve as before

18 Second Order system LCR Circuit Kirchoff’s Voltage Law =>

19 Second order System Forming the equations Use dq/dt=i and divide by L coil To get homogeneous equation in q

20 Second Order System Writing standard form #1 Rewrite again, getting rid of d/dt

21 Second Order System Writing standard form #2 Use symbolic solver to get q2

22 Second Order System Fill in D vector Have expressions for q1 & q2Have expressions for q1 & q2 Now fill in D(t,q) vectorNow fill in D(t,q) vector ReplaceReplace –q0  q 0,q1  q 1,q2  q 2

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…

29 Forcing function Drive with sinusoidal waveformDrive with sinusoidal waveform Substitute to give…Substitute to give…

30 Derivative Vector for Forced SHM No initial charge or currentNo initial charge or current

31 Form solution Use rkfixed as before…Use rkfixed as before…

32 Extract values & plot

33 Phase Plot Plot Current (q1) vs Charge (q0)Plot Current (q1) vs Charge (q0)


Download ppt "PH36010 Numerical Methods Solving Differential Equations using MATHCAD."

Similar presentations


Ads by Google