Model Task 4: Time stepping and the leapfrog scheme ATM 562 Fall 2015 Fovell (see updated course notes, Chapter 12) 1.

Slides:



Advertisements
Similar presentations
Lecture 14 User-defined functions Function: concept, syntax, and examples © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Advertisements

Slides for Parallel Programming Techniques & Applications Using Networked Workstations & Parallel Computers 2nd ed., by B. Wilkinson & M
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Yingcai Xiao Chapter 6 Fundamental Algorithms. Types of Visualization Transformation Types 1.Data (Attribute Transformation) 2.Topology (Topological Transformation)
Inpainting Assigment – Tips and Hints Outline how to design a good test plan selection of dimensions to test along selection of values for each dimension.
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
CSC1016 Coursework Clarification Derek Mortimer March 2010.
Program Design and Development
Lecture 3 IAT 800. Sept 15, Fall 2006IAT 8002 Suggestions on learning to program  Spend a lot of time fiddling around with code –Programming is something.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software.
Google SketchUp Castle
Finite Difference Time Domain Method (FDTD)
Chapter 2: Algorithm Discovery and Design
Finite Difference Methods Or Computational Calculus.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
Games and Simulations O-O Programming in Java The Walker School
Testbed: Exercises.
Programming For Nuclear Engineers Lecture 12 MATLAB (3) 1.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 3 Computing with Numbers.
Programmer Defined Functions Matthew Verleger. Windows It’s estimated that Window’s XP contains 45 million lines of code (and it’s over 10 years old).
JS Arrays, Functions, Events Week 5 INFM 603. Agenda Arrays Functions Event-Driven Programming.
Guidelines for the CMM coding project 5 October 2006 (or, “How to make your life easier in the long run”)
Dynamic and Buoyancy Pressure A rising thermal plus… Unix basics.
Nonvisual Arrays and Recursion by Chris Brown under Prof. Susan Rodger Duke University June 2012.
CHAPTER TEN AUTHORING.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
Chapter 13 Recursion. Learning Objectives Recursive void Functions – Tracing recursive calls – Infinite recursion, overflows Recursive Functions that.
Hans-Peter Plag November 6, 2014 Session 4 (Programming Languages) (Data Types and Variables) Expressions and Operators Flow Control.
Introduction to MATLAB 7 Engineering 161 Engineering Practices II Joe Mixsell Spring 2010.
To return to the chapter summary click Escape or close this document. Chapter Resources Click on one of the following icons to go to that resource. Image.
Model Task 0A: Programming the 1D upstream scheme ATM 562 Fall 2015 Fovell 1.
Model Task 2: Calculating CAPE and CIN ATM 562 Fall 2015 Fovell (see updated course notes, Chapter 10) 1.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
CSE 381 – Advanced Game Programming GLSL Lighting.
Model Task 0B: Implementing different schemes ATM 562 Fall 2015 Fovell 1.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
REVIEW A relation is a set of ordered pairs. {(2,3), (-1,5), (4,-2), (9,9), (0,-6)} This is a relation The domain is the set of all x values.
Some Fortran programming tips ATM 562 Fall 2015 Fovell (see also PDF file on class page) 1.
5 1 Data Files CGI/Perl Programming By Diane Zak.
Introduction to MATLAB 7 MATLAB Programming for Engineer Hassan Migdadi Spring 2013.
Engineering Analysis – Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Beginning Fortran Fortran (77) Advanced 29 October 2009 *Black text on white background provided for easy printing.
Model Task 3: Grid setup, initial condition and visualization ATM 562 Fall 2015 Fovell (see updated course notes, Chapter 11) 1.
Model Task 5: Implementing the 2D model ATM 562 Fall 2015 Fovell (see updated course notes, Chapter 13) 1.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
1 One Dimensional Arrays Chapter 11 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores :
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
1 Project designed and created by M. Shajith Kumar.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Fall 2006AE6382 Design Computing1 Advanced Matrix Applications in Matlab Now we’ll show a few relatively simple examples to illustrate some of the powerful.
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
The story so far… ATM 562 Fovell Fall, Convergence We will deploy finite difference (FD) approximations to our model partial differential equations.
Introduction to: Python and OpenSesame FOR PROS. OpenSesame In OpenSesame you can add Python in-line codes which enables complex experiment. We will go.
CSC 212 – Data Structures Lecture 15: Big-Oh Notation.
Model Task 1: Setting up the base state ATM 562 Fall 2015 Fovell (see course notes, Chapter 9) 1.
Adjoint models: Theory ATM 569 Fovell Fall 2015 (See course notes, Chapter 15) 1.
LECTURE 22: BIG-OH COMPLEXITY CSC 212 – Data Structures.
S7-1 ADM730, Section 7, September 2005 Copyright  2005 MSC.Software Corporation SECTION 7 ADVANCED TOPICS.
Managed and Operated by National Security Technologies, LLC Nevada National Security Site SurVisTool “SurVisTool” Visualizing and Analyzing Multiple Time.
Numerical Solutions to the Diffusion Equation
Computer Programming.
Introduction to MATLAB
CHAPTER 8 Multimedia Authoring Tools
Introduction to Computer Programming
Chapter 10 Algorithms.
An Introduction to VEX IQ Programming with Modkit
Introduction to MATLAB
Presentation transcript:

Model Task 4: Time stepping and the leapfrog scheme ATM 562 Fall 2015 Fovell (see updated course notes, Chapter 12) 1

Outline The 2D model framework was established in MT3 MT4 accomplishes two things: – Implements a time stepping loop for a simple, 2D linear advection equation – Illustrates phase and dispersion errors inherent in the leapfrog (LF) scheme The MT3 initial conditions on  ’,  ’ are not used for this task – Those will be used in MT5 – A similar initial condition is implemented for a variable I’ll call “v”. This variable is defined at the scalar point (grid center) 2

Synopsis MT4 model domain will be square and doubly periodic Initial condition will be a cone-shaped object Cone will be advected at constant speed You do not need to touch your MT3 code, except to change the domain configuration ( nx, nz ) and grid spacing ( dx, dz ). 3

Equation and code Advection equation Code (Fortran) for 2 nd order LF Specifics: –nx = nz = 51 –cx = cz = 1 m/s –dx = dz = 100 m –dt = 50 sec –rd2x = 1./(2.*dx) and rd2z = 1./(2.*dz) –d2t = dt + dt (after 1 st time step) –timend = 4900 sec 4 vp(i,k)=vm(i,k)-cx*d2t*rd2x*(v(i+1, k )-v(i-1, k )) & -cz*d2t*rd2z*(v( i,k+1)-v( i,k-1))

Initial condition Initial condition: very similar to MT3 for  ’, but for v with radx = radz = 1000 m, delt = 10, and placed at the domain center For Fortran, imid = (nx+1)/2, kmid = (nz+1)/2. For 0-based index languages, imid = (nx-1)/2, kmid = (nz-1)/2 Don’t forget to set vm(i,k) = v(i,k) to start 5  is trigonometric pi

Boundary conditions Doubly periodic, with a frame of fake points, so for Fortran the real points are 2, nx-1 and 2, nz-1 6 do k=2,nz-1 v( 1,k)=v(nx-1,k) v(nx,k)=v( 2,k) enddo do i=1,nx v(i, 1)=v(i,nz-1) v(i,nz)=v(i, 2) enddo

Programming concept From MT3 and earlier, you have set up your 1D and 2D arrays, base state, and an initial condition for  ’ and  ’. Keep all this. For MT4, create additional initial condition for v, vm. Start with d2t = dt. (Note nx, nz, dx, dz change also.) Implement time stepping loop: – Predict vp using v, vm for all real points – Take care of boundary conditions – Calculate exact solution, if desired (see next) – Set for new time step, including d2t = dt + dt – Time to plot? – Time to end model run? If not, loop back. 7

Visualization using GrADS This visualization uses grads_routines_augmented.f code version of 10/31/15 – This version is already includes v and defines it at the scalar point – It also includes qv (water vapor), which I use to hold the exact solution – Note calls to subroutine dumpgrads are altered (expanded) in this version (passes qv and qb ) 8

9 t = 0 sec Contours: LF solution. Shading: true solution

10 t = 1500 sec Contours: LF solution. Shading: true solution Note short wavelength components are moving in the wrong direction!

11 t = 3000 sec Contours: LF solution. Shading: true solution

12 t = 4500 sec Contours: LF solution. Shading: true solution Little amplitude error Some phase error (lag) More dispersion error

13 Animation (frames every 100 sec)

Tracking the exact solution Saved in qv array in this example 14

Problem geometry 15 xi = a grid point in the domain xloc = distance to cone centroid xlocmirror = distance to cone’s mirror image Take minimum of xloc, xlocmirror

16 c c exact solution c xmid=dx*(nx+1)/2+cx*n*dt! Departure of cone centroid zmid=dz*(nz+1)/2+cz*n*dt! from initial position if(xmid.ge.nx*dx) xmid=xmid-(nx-2)*dx! Passing the periodic if(zmid.ge.nz*dz) zmid=zmid-(nz-2)*dz! boundary if(xmid.gt.dx*(nx+1)/2) then! The cone’s “mirror” location xmidmirror=xmid-(nx-2)*dx! on other side of periodic else! boundary xmidmirror=xmid+(nx-2)*dx endif if(zmid.gt.dz*(nz+1)/2) then zmidmirror=zmid-(nz-2)*dz else zmidmirror=zmid+(nz-2)*dz endif qv=0. ! start with a clean slate

17 c c exact solution (continued) c do i=2,nx-1 do k=2,nz-1 xi=float(i)*dx! Current location zk=float(k)*dz xloc=((xi-xmid)/radx)**2! Location relative to zloc=((zk-zmid)/radz)**2! domain midpoint xlocmirror=((xmidmirror-xi)/radx)**2! Mirror beyond the zlocmirror=((zmidmirror-zk)/radz)**2! periodic boundary xloc=amin1(xloc,xlocmirror)! Make sure location is zloc=amin1(zloc,zlocmirror)! in the domain rad=sqrt(xloc+zloc) if(rad.lt.1.) qv(i,k)=.5*delt*(cos(trigpi*rad)+1.) ! Exact soln. enddo

Example GrADS script for making animations 18

19 * example GrADS plot script for model task 4 * this version can save individual frames as gif images * ATM562 * * version of 10/31/2015 'set display color white' 'clear' 'run rgbset.gs' * display parameters 'set mproj off' 'set vpage ' 'set parea ' * save individual plots as gif images? say 'Create gif images? (1=yes ; 0=no)' pull ans * find final time in grads file frame = 1 'q file' rec=sublin(result,5) _endtime=subwrd(rec,12) say " endtime is " _endtime * looping flag runscript = 1 * start at time 1 dis_t = 1

20 * ======================================================================= * MOVIE LOOP * ======================================================================= while(runscript) 'set t ' dis_t 'clear' 'set grads off' 'set ccolor 15' 'set cint 2.0' 'set black 0 0' 'set cthick 7' 'set gxout shaded' 'set clevs ' 'set ccols ' 'd qv' 'run cbarn.gs' 'set clab off' 'set gxout contour' 'set ccolor 2' 'set clevs ' 'd qv' 'set clab on' 'set cthick 5' 'set ccolor 1' 'set cthick 6' 'set cint 2.0' 'd v’

21 * ======================================================================= * FINISH * ======================================================================= if(ans) if( frame < 10 ) 'printim movie00'frame'.gif gif ' else if ( frame < 100 ) 'printim movie0'frame'.gif gif ' else 'printim movie'frame'.gif gif ' endif frame=frame+1 endif * this next line makes you hit return key to advance pull dummy if ( dis_t=_endtime ) runscript=0 endif dis_t = dis_t + 1 endwhile Results in sequence of individual GIF files named movie*.gif, which can be combined into an animation

GIF animations Gifsicle – Command-line tool, multiple platforms Graphic Converter (Mac) – slideshow-browser-batch-conversion-metadata- and-more-on-your-mac/ slideshow-browser-batch-conversion-metadata- and-more-on-your-mac/ Many, many others 22

MT4 Summary Turn in your model code and a plot showing your LF solution at 4900 sec Chapter 5 will reveal that the stability condition for the 2D leapfrog is a lot more restrictive: c’=0.5. Our experiment is using c’ = 0.5 exactly. Prove you cannot use a larger ∆t than 50 sec. What wavelengths are blowing up fastest? What happens if you code the upstream or an RK3 scheme instead? 23