Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to MathCAD You can always find a solution !!

Similar presentations


Presentation on theme: "An Introduction to MathCAD You can always find a solution !!"— Presentation transcript:

1

2 An Introduction to MathCAD You can always find a solution !!

3 2 MathCAD #6  dpl 2001 When things go wrong “Result is too large to Display”

4 3 MathCAD #6  dpl 2001 Can we fix it ? Yes we can !! Force solver to work with real numbers

5 4 MathCAD #6  dpl 2001 What if its still broken ? Risky !! – OK in this case

6 5 MathCAD #6  dpl 2001 Still can’t solve it ? u Use polyroots to find roots u Use coeffs keyword on solver to get coefficients of x

7 6 MathCAD #6  dpl 2001 Still can’t solve it ? u Graph shows maxima & minima u => there must be solutions u Try guessing & using roots(f1(x),x)

8 7 MathCAD #6  dpl 2001 Solving ODEs numerically u Produce numeric solution to system of ODEs. u Must have initial conditions u Manipulate equations u Use one of several different solvers u Produces matrix of solutions

9 8 MathCAD #6  dpl 2001 First order linear ODE #1 u Radioactive decay, Newton’s law of cooling etc u A is amount of material temperature difference etc u k is rate constant

10 9 MathCAD #6  dpl 2001 First order linear ODE #2 u Define initial conditions as a vector u 1 st order so only 1 element in vector u Can’t use units in ODE solver u Call vector ‘ic’ u Element 0 = A at t=0

11 10 MathCAD #6  dpl 2001 First order linear ODE #3 u Now define ODE & manipulate for mathCAD

12 11 MathCAD #6  dpl 2001 First order linear ODE #4 u Now define range of solution Start time Finish Time Number of Points u And solve using rkfixed u Creates matrix ‘Soln’ containing solution

13 12 MathCAD #6  dpl 2001 First order linear ODE #5 Column 0 holds t values Column 1 holds A values The Solution Matrix 1 row of matrix per timestep (0..N)

14 13 MathCAD #6  dpl 2001 First order linear ODE #6 u Plot the results u Use M <> to extract columns u Use subscripting to extract rows

15 14 MathCAD #6  dpl 2001 Second Order ODE u Same steps as for first order u Slightly less obvious manipulation u Replace ODE by system of 1 st orders u Can use symbolic solver to formulate equations

16 15 MathCAD #6  dpl 2001 Second Order ODE Example #1 u Damped SHM –LCR circuit –Damped Pendulum Substitute for i & divide through by L Gives:

17 16 MathCAD #6  dpl 2001 Second Order ODE Example #2 Gives manipulated equation:

18 17 MathCAD #6  dpl 2001 Second Order ODE Example #3 u Use solver to solve for q2 u Now ready to create D(t,q) function

19 18 MathCAD #6  dpl 2001 Second Order ODE Example #4 u Equations to create D(t,q) u 2 row vector to hold D(t,q) u Change subscripts for suffixes

20 19 MathCAD #6  dpl 2001 Second Order ODE Example #5 u Specify initial conditions u For second order need 2 elements in ic vector Charge (q) at t=0 Current (dq/dt) at t=0 u Also need to specify constants in D(t,q) equations u Watch for lack of units !!

21 20 MathCAD #6  dpl 2001 Second Order ODE Example #6 u Define times and number of points as before u Call rkfixed to solve u Matrix Soln filled with solution points

22 21 MathCAD #6  dpl 2001 Second Order ODE Example #7 Column 0 holds t values Column 1 holds q values Column 2 holds dq/dt values The solution matrix

23 22 MathCAD #6  dpl 2001 Second Order ODE Example #8 u Graphing the solution

24 23 MathCAD #6  dpl 2001 Surely nothing can go wrong ? u Solution relies on numeric integration which divides timestep up into smaller chunks for integration u If system is changing much faster than timestep, solution will fail u Clues to look for: –“found a number >10^307” –Singularity at t finish

25 24 MathCAD #6  dpl 2001 Can we fix it ? u Check time constants u Try more point in solution (N) u Try smaller interval u Use a different solver –‘Stiff’ systems give problems –Special solvers for stiff systems –See Quicksheet & help system


Download ppt "An Introduction to MathCAD You can always find a solution !!"

Similar presentations


Ads by Google