330 likes | 517 Views
Plasma Application Modeling POSTECH. EECE490O. How to solve ODEs using MATHEMATICA. 2006. 03. 22. Gan-Young Park and Jae-Koo Lee Department of Electronic and Electrical Engineering, POSTECH. Plasma Application Modeling POSTECH. Contents. Basic usages of MATHEMATICA Solving ODEs
E N D
Plasma Application Modeling POSTECH EECE490O How to solve ODEs using MATHEMATICA 2006. 03. 22 Gan-Young Park and Jae-Koo Lee Department of Electronic and Electrical Engineering, POSTECH
Plasma Application Modeling POSTECH Contents • Basic usages of MATHEMATICA • Solving ODEs • - Euler’s method • - Predictor-Corrector method ( second-order ) • - Forth-order Runge-Kutta method • - Tridiagonal matrix method
Plasma Application Modeling POSTECH References • Textbook • - ‘Numerical and Analytical Methods for Scientists and Engineers Using Mathematica’, Daniel Dubin, Wiley, 2003 • Web Lecture • : http://www.mathought.com/main.htm
Plasma Application Modeling POSTECH Notebook : working window ( *.nb ) Standard Screen Palettes ( File – Palettes - ) : a collection of numerical expressions or characters
Plasma Application Modeling POSTECH Basic Usages (1) • Shift + enter : Execution (shift + enter) (shift + enter) • In[1] indicates input contents in the line. • Out[1] indicates the result of In[1] • % : a symbol indicating the result obtained right before.
Plasma Application Modeling POSTECH • Font size • : Format - Size - Basic Usages (2) • application of Palettes
Plasma Application Modeling POSTECH Basic Usages (3) • The names of most of functions included start with a capital letter. • included constants • - π→ Pi • - ∞ → Infinite • - e → E • - i = → I • ? (function) or ?? (function) • : shows the usage of function or options
Plasma Application Modeling POSTECH Basic Usages (4) • symbol calculation • The symbol “ * ” for a product can be replaced by “ blank”.
Plasma Application Modeling POSTECH Common feature Different feature Basic Usages (5) • == ( equality ), = ( substitution ), := ( definition ) < g[x] = eq. & g[x] := eq. >
Plasma Application Modeling POSTECH Common feature Different feature Basic Usages (6) < g[x_] = eq. & f[x_] := eq. >
Plasma Application Modeling POSTECH Basic Usages (7) • Plot[ function, {variable, a, b}, options] : drawing 2-D graph between a and b
Plasma Application Modeling POSTECH Basic Usages (8) • PlotStyle : a option for coloring • Input - Color Selector
Basic Usages (9) • PlotLabel : a option for labeling at top of graph • AxesLabel : a option for labeling at axes • AspectRatio : a option for adjusting the ratio of vertical to horizontal • PlotRange : a option for restricting range to plot
Plasma Application Modeling POSTECH Basic Usages (10) • DisplayFunction → Identity : a option for not showing a graph, just memorizing it. • Show : a function to display graphs which have been shown or memorized • DisplayFunction -> $DisplayFunction : a option for showing a graph memorized.
Plasma Application Modeling POSTECH • Since path is assigned up to StandardPackages, just sub-paths • should be written. • The symbol ` is used in Mathematica instead of \. Basic Usages (11) • Package
Plasma Application Modeling POSTECH Basic Usages (12) • Table [contents, {range of loop}]
Plasma Application Modeling POSTECH • Since Do, For, While don’t show results and save results, functions such as Print[] should be used for checking results. • That’s a difference among Table and above functions. Basic Usages (13) • Do [exp, {i,min,max,d}] • For [start, test, i++, body] • While [test, body]
Plasma Application Modeling POSTECH Basic Usages (14) • Module [ {local variables}, contents ] • : The variables written at {} in Module[ ] are used as local variables which doesn’t affect global variables with same characters and can’t be used out of Module[ ].
Plasma Application Modeling POSTECH Solving ODEs - Euler’s method - Predictor-Corrector method ( second-order ) - Forth-order Runge-Kutta method - Solving tridiagonal matrix
Plasma Application Modeling POSTECH Euler’s method (1)
Plasma Application Modeling POSTECH Euler’s method (2)
Plasma Application Modeling POSTECH Forth-order Runge-Kutta method ( based on the Simpson’s 1/3 rule )
Plasma Application Modeling POSTECH , y(0)=1, y’(0)=0 Changing 2nd order ODE to 1st order ODE, y(0)=1 (1) z(0)=0 (2) Program 9-1 ( Nakamura )
Plasma Application Modeling POSTECH Program 9-1 ( Nakamura ) To solve 2nd-order ODE using second-order Runge-Kutta method
Plasma Application Modeling POSTECH y(0)=1 y(0)=0 Program 9-2 ( Nakamura ) To solve ODE using fourth-order Runge-Kutta method
Program 10-1 ( Nakamura ) Plasma Application Modeling POSTECH Solve difference equation, With the boundary conditions, x = 0 1 2 9 10 i = 0 1 2 9 10 known y(0)=1 Especially for i = 1,
Program 10-1 ( Nakamura ) For i = 10, Summarizing the difference equations obtained, we write Tridiagonal matrix
Plasma Application Modeling POSTECH Solution Algorithm for Tridiagonal Equations (1) R2 Based on Gauss elimination R3
Plasma Application Modeling POSTECH Solution Algorithm for Tridiagonal Equations (2)
Plasma Application Modeling POSTECH Program 10-1 ( Nakamura ) To solve boundary-value problem using tridiagonal method