12.010 Computational Methods of Scientific Programming Lecturers Thomas

12.010 Computational Methods of Scientific Programming Lecturers Thomas

12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room 54-820A, [email protected] Chris Hill, Room 54-1511, [email protected] Web page http://www-gpsg.mit.edu/~tah/12.010 Review of last Lecture Examined parallel computing and MPI implementation. Today: Class project and graphics formats 12/02/2008 12.010 Lec 22 2 Class project Groups Stefan Gimmillaro

The Sodoku Master: Amanda Levy Solar Subtense Program Adrian Melia Model of an accelerating universe Eric Quintero Encryption/decryption algorithm Karen Sun and Javier Ordonez Truss Collapse Mechanism Melissa Tanner and Sean Wahl

Phase diagram generator for binary and ternary solid-state solutions Celeste Wallace Adventure Game 12/02/2008 12.010 Lec 22 3 Class Project Aim of the project is to put together everything you have learned in this course: Algorithm design User interface Numerical methods Graphics output

We will spend some time over next two lectures introducing some concepts that might assist in these projects. 12/02/2008 12.010 Lec 22 4 Ground rules Some of you will be working in groups. The role of each person in the group should be explained in the project description. There is a written and code components to the projects (see web page of requirements). You can solve the problem in any language that you want to use For those that choose Fortran, C or C++, they can choose their a graphics program to display results.

12/02/2008 12.010 Lec 22 5 Problem statement Each group should develop a problem statement that defines the problem they are trying to solve. Some projects are driven by differential equations in the acceleration and/or velocity of a body will depend on forces applied to the body We will look at the case on a gravity driven orbital problem. 12/02/2008 12.010 Lec 22 6

Governing equations for gravitytype problems Force = mass*acceleration (F=ma) Force = GM1M2/R2 where M1 and M2 are two masses and R is the distance between them. The force is directed along the vector between the bodies For multiple bodies, the force acting on each body is the vector sum of the forces from all the other bodies. What do you do with these equations? 12/02/2008 12.010 Lec 22 7 Solution to equations Given the initial positions of all the bodies, the accelerations of each body can be computed. Acceleration integrated, gives the velocity change (remember bodies are initially moving)

Velocity integrated gives position change. At the new positions, the forces will be different and therefore there will be different accelerations and velocities. How we quantity the changes in positions and velocities? 12/02/2008 12.010 Lec 22 8 Integration methods Simplest method is Eulers method: Compute accelerations; DV = A*dt; P(t+dt) = P(t) + (V(t)+Adt/2)*dt V(t+dt) = V(t) + A*dt Compute new accelerations at P(t+dt) and continue to iterate. This is simplest and most inaccurate method. Why is it inaccurate?

For your projects, write down the basic equations and how these will be solved. 12/02/2008 12.010 Lec 22 9 Runge-Kutta integration Compare the two versions of the second-order system y = f(x,y,y) 1 yn+1 =yn +h[y + (k1 +k2 +k3)]+O(h5 ) 6 1 ' ' yn+1 =yn + [k1 +2k2 +2k3 +k4 ] 6 k1 =hf(xn,yn,yn' )

' n k2 =hf(xn +h/ 2,yn +hy'n / 2+hk1 /8, yn' +k1 / 2) k3 =hf(xn +h/2,yn +hy'n /2+hk1 /8,y'n +k2 /2) k4 =hf(xn +h,yn +hy'n +hk3 /2,y'n +k3) 12/02/2008 12.010 Lec 22 10 Form with no Velocity dependence y = f(x,y) 1 yn+1 =yn +h[y + (k1 +2k2 )]+O(h4) 6 1 2 1 '

' yn+1 =yn + k1 + k2 + k3] 6 3 6 k1 =hf(xn,yn) ' n k2 =hf(xn +h/ 2,yn +hy'n / 2+hk1 /8) k3 =hf(xn +h,yn +hy'n +hk2 /2) 12/02/2008 12.010 Lec 22 11 Graphics As we have seen some languages (Matlab and mathematica) already have graphics imbedded in them Languages such as Fortran, C and C++ do not

explicitly contain graphics but graphics routines can be included in programs if a graphics library can be found. Often graphically output needs to be included in other documents (such as reports and web pages) Quality of the display depends very much on the type of graphics used. For graphics there are too many standards 12/02/2008 12.010 Lec 22 12 Types of graphics files Graphics files fall into two basic types: Vector graphics, made of lines and objects (e.g., fonts) that can scaled. The most common of these is Postscript (in its various forms) Bitmapped graphics defined by pixels that have certain characteristics. The most common of these

is GIF (Graphics Interchange Format). These types of formats are good for images especially with continuous tone changes. Bitmapped graphics can look very bad when re-scaled. Some formats are a composite of each type (e.g. Mac PICT format). 12/02/2008 12.010 Lec 22 13 Basic Graphic formats Postscript: Comes in different versions (level 1, 2 and 3) and as encapsulated (EPS). EPS files may have a preview of image which is often displayed in WYSIWYG word processors. (The preview image may not always be displayable). Postscript is meant for printers and can maintain very high resolution Not all printers can print all levels of postscript and not

all printers understand all parts of postscript. Postscript is a graphics programming language. 12/02/2008 12.010 Lec 22 14 Other vector formats Often drawing program (opposed to painting programs) us a vector graphics format that is unique to the program (e.g, Macdraw). Advantages: Small file sizes Scalable Good for may scientific graphics plots such as line drawings 12/02/2008 12.010 Lec 22

15 Pixel formats GIF is the most common but enforcement of the patent on the compression algorithm used has raised concerned Network Portable Graphics (PNG) is an alternative but a lot of older software will not handle this. JPEG (Joint Photographic Experts Group) also common and good for image data These format represent an image as pixels which have attributes such as color. When image is resized, the pixels need to be merged and mapped to the new location. 12/02/2008 12.010 Lec 22 16

Examples: Output from Kaleidagraph in PICT format Sextant 10/00 75 2*Sun Elev (deg) 74 73 73 2*Sun Elev (deg) 72 Y = M0 + M1*x + ... M8*x8 + M9*x9 M0 -858.71 M1 113.17 M2 -3.4318

R 0.99882 72 72 71 70 15.4 12/02/2008 15.6 15.8 16.0 16.2 GMT Hrs 12.010 Lec 22

16.4 16.6 16.8 17 Bitmap format Basic bit-mapped graphic 12/02/2008 12.010 Lec 22 18 Rescaled versions PICT and bitmap Sextant 10/00

75 2*Sun Elev (deg) 74 73 73 Elev (deg) 72 Y = M0 + M1*x + ... M8*x8 + M9*x9 72 M0 M1 M2 R 72 71

70 15.4 15.6 15.8 12/02/2008 16.0 16.2 GMT Hrs -858.71 113.17 -3.4318 0.99882 16.4 16.6

16.8 12.010 Lec 22 19 JPEG Version Medium Resolution 12/02/2008 12.010 Lec 22 20 JPEG Maximum resolution 12/02/2008

12.010 Lec 22 21 Scaled versions of JPEG Effects of scaling graphics 12/02/2008 12.010 Lec 22 22 EPS Files (from Photoshop) 1.1 Mbytes (displays badly but will print very well) 12/02/2008 12.010 Lec 22 23

EPS Direct from Printing (This figure will print with high resolution but displays badly) 12/02/2008 12.010 Lec 22 24 File sizes For the different images we just looked at: Original KG figure 32K (24K no data) PICT 8K Bitmap 12K JPEG (medium) 44K

JPEG (maximum) 68K EPS (photoshop) 1.1M EPS (KG) 40K (no fonts) EPS (KG+fonts) 256K 12/02/2008 12.010 Lec 22 25 Microsoft Graphics (Object based) Sextant 10/00 75 74 2*Sun Elev (deg)

2*Sun Elev (deg) 73 73 72 + M1*x + ... M8*x M0 M1 M2 R 72 72 71 70 15.4 12/02/2008 15.6

15.8 16.0 16.2 GMT Hrs 8 16.4 12.010 Lec 22 9 + M9*x -858.71 113.17 -3.4318 0.99882 16.6

16.8 26 Issue with graphics Increasingly documents need to be prepared electronically and generating acceptable graphics is one of the biggest problems still. For electronic presentation of images, best if the original graphics is generated at 72 dots-per-inch. If the graphics is not scaled then these can print OK as well. For printing, vector graphics are most often the best. Display quality: Try antialiasing (process to smooth out edges but some times makes graphics look fuzzy. For WYSWYG word processing, encapsulated postscript generates good prints but may not be rendered in electronic versions (such as web pages). Currently: Still a lot of testing to see what works best. 12/02/2008

12.010 Lec 22 27 Graphics packages in programming There are graphics programs that can be purchased or are open source in which data can be supplied and graphics generated There are also graphics libraries that can used and incorporated into user developed software. Some packages come in both forms Example: Generic Mapping Tool (GMT) available from http://gmt.soest.hawaii.edu/ Includes program that can be scripted and routines that can be used in user developed software Caution with these programs is that calls and features can change with versions 12/02/2008 12.010 Lec 22

28 Summary of Todays class Aim of the project is to put together everything you have learned in this course: Algorithm design User interface Numerical methods Graphics output Graphics formats and issues. Class evaluation Thursday 12/04 Order of presentations will be set on Thursday as well. 12/02/2008 12.010 Lec 22 29

Recently Viewed Presentations

  • Rimonabant in Obesity - Clinical Trial Results

    Rimonabant in Obesity - Clinical Trial Results

    Primary Endpoint: Change in mean common carotid intimal medial thickness (IMT) at 1 year within each study group ARBITER-2 Trial Presented at AHA 2004 Placebo Concomitant statin therapy 167 Coronary heart disease patients with low HDL cholesterol levels (<45 mg/dl)...
  • From SMART Goals to Action! - Anciaux International

    From SMART Goals to Action! - Anciaux International

    From SMART Goals to Action! at Partnering with Families and Closing the Achievement Gap May 26, 2004 Seattle, Washington presented by Michele Anciaux Aoki, Ph.D. SMART Goals S - Specific M - Measurable A - Achievable R - Relevant T...
  • CORT Tool IPR Agenda and Slides _5 28 15

    CORT Tool IPR Agenda and Slides _5 28 15

    DA & Managers - show all contracts number for each department and make all documents available. CO, CS, QAPOC, Auditor - Show all contracts for registered DoDAACs and make all documents available. ... 7-8 Jan 2015. Critical Design Review (CDR)...
  • Die neue Agrarpolitik - EuroNatur

    Die neue Agrarpolitik - EuroNatur

    05 Landwirtschaft und Entwicklung Ländlicher Raum. 05 02 11 Sonstige (Tr.futter, POSEI) Quelle 2000 - 2002: Anhang 11 Eu-HH-Plan 2003. EAGFL-Garantie. Vollzug 2003. EAGLF-Ausrichtung . Koordinierung der Politiken, rechtliche Beratung . Raum der Freiheit, Sicherheit und Recht. 05 Landwirtschaft und...
  • slallison.weebly.com

    slallison.weebly.com

    Numeracy . St. Mary's. Sept.21, 2018. Guess My Rule. ... Where do you see yourself on this continuum? Collaboration time. In grade level groups, explore and investigate the Developing Math Fluency, Textbook and Super Source resources and, with the help...
  • RDA: Changes from AACR2 [or from AACR2 practice]

    RDA: Changes from AACR2 [or from AACR2 practice]

    Changes from AACR2 for Texts Barbara B. Tillett, Chief, Policy and Standards Division For LC Digital Futures and You Jan. 12, 2010 General overview Changes: from AACR2 or from AACR2 practice MARC 21 changes Represents LC practice for the RDA...
  • Reciprocal of a fraction

    Reciprocal of a fraction

    Bodmas The operations are performed sequentially from left to right in the order of 'BODMAS'. In BODMAS the letter B means Brackets, O means Of, D means Division, M means Multiplication, A means Addition, S means Subtraction. If more than...
  • Determination of Forward and Futures Prices

    Determination of Forward and Futures Prices

    Formula still works for an investment asset because investors who hold the asset will sell it and buy forward contracts when the forward price is too low