1 / 9

12.010 Computational Methods of Scientific Programming

12.010 Computational Methods of Scientific Programming. Lecturers Thomas A Herring, Room 54-618, tah@mit.edu Chris Hill, Room 54-1511, cnh@gulf.mit.edu Web page http://www-gpsg.mit.edu/~tah/12.010. Overview Today. Review some aspects of Homework 4 (Mathematica).

hank
Download Presentation

12.010 Computational Methods of Scientific Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room 54-618, tah@mit.edu Chris Hill, Room 54-1511, cnh@gulf.mit.edu Web page http://www-gpsg.mit.edu/~tah/12.010

  2. Overview Today • Review some aspects of Homework 4 (Mathematica). • Look at formatting of question 1 • Look at FindRoot and NDSolve for Question 3. • Final Project: Examine Matlab N-body project to show: • methods Animation • Solution using odeXX differential equation solver in Matlab • End by looking at some graphics packages 12.010 Lec 20

  3. Mathematica Homework • Question 1: Formatting output was tricky:The notebook 12.010_Lec20_Mathematica.nb gives examples for some solutions • Question 2: OK, features from 5.2 Mathematica used • Question 3: NDSolve was the way to solve this problem along with FindRoot 12.010 Lec 20

  4. Final Project: • Example case for N-body problem: • N-body planetary problem that use Runge-Kutta numerical integration with variable step size. • Demonstrate basic use of this program (tar file on web site) • Graphics usage in gui-form: Basic methods can be used in your projects. 12.010 Lec 20

  5. Graphics real-time output in Matlab • In Matlab: we can consider “real time” out put the results • When a plot is made you can set an “EraseMode” • Options are: • none — leaves all points on the screen • background — paints old points with background color. Erases old points but also erases any other information such as grid lines and text • xor — Exclusive or. Erases just the previously plotted points, leaves the background intact 12.010 Lec 20

  6. Generating animated sequence with Matlab • Basic mode of use: • Plot first point keeping the graphics handle • p = plot3(x,y,z,’.’, ‘EraseMode’,’xor’); • Set the axis limits: (Need to think of values to use here. • axis([-100 100 -100 100 -100 100]); • hold on • Now generate the sequence of points • Loop over time steps, compute new x y z • set(p,’Xdata’,x,’Ydata’,y,’Zdata’,z) • Drawnow • These ideas were demonstrated in Matlab M-file 12.010 Lec 20

  7. ODE Solvers • Use of ODE Solvers in Matlab (demonstrated in class) • Vector y is 2-d position and velocity (1:4). y0 = [0.0; 0.0; vx; vz]; [t,y,te,ye,ie] = ode23(@bacc,[0:1:tmax],y0,options); • The bacc routine computes accelerations. dy/dt is returned so that dy[1]=d(pos)/dt=y[3]; dy[2]=y[4]; and dy[3] and dy[4] are new accelerations function dy = bacc(t, y) % acc: Computes accelerations • Options sets ability to detect event such as hitting ground options = odeset('AbsTol',[terr 1 1 1],'Events','hit'); function [value,isterminal,direction] = hit(t,y) Value returns the height. • Look through Matlab help and use demo program 12.010 Lec 20

  8. Graphics Programs • Basic data plotting programs: • There a number of programs which fall into this basic category: • KaleidaGraph — commercial program runs on PC and Mac (~$150) (web http://www.synergy.com) • Tecplot — Available on Athena (Unix and PC) ($1300) (web http://www.amtec.com/) • Grace -- Similar to KaleidaGraph available free for Unix systems. The old version is called xmgr. (http://plasma-gate.weizmann.ac.il/Grace/ • Demo of basic features of these types of programs 12.010 Lec 20

  9. Summary • Looked at Mathematica homework solution • Example of 3-D Numerical integration Project • Graphics packages • Matlab homework due Thursday Dec 1. 12.010 Lec 20

More Related