Finite Difference Methods Or Computational Calculus.

Slides:



Advertisements
Similar presentations
Partial Differential Equations
Advertisements

Single Variable and a Lot of Variables The declaration int k; float f; reserve one single integer variable called k and one single floating point variable.
Finite Volume II Philip Mocz. Goals Construct a robust, 2nd order FV method for the Euler equation (Navier-Stokes without the viscous term, compressible)
Numerical modeling example A simple s teel reheat furnace model – pg Reheat furnace Hot steel slabRolling mill Final product.
Chapter 30 Sources of the magnetic field
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Recursion.
15 PARTIAL DERIVATIVES.
Transport Equations and Flux Laws Basic concepts and ideas 1.A concept model of Diffusion 2.The transient Diffusion Equation 3.Examples of Diffusion Fluxes.
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
II–2 DC Circuits I Theory & Examples.
CHE/ME 109 Heat Transfer in Electronics LECTURE 11 – ONE DIMENSIONAL NUMERICAL MODELS.
Physics 218, Lecture XVII1 Physics 218 Lecture 17 Dr. David Toback.
Numerical Methods for Partial Differential Equations CAAM 452 Spring 2005 Lecture 9 Instructor: Tim Warburton.
Solving Systems with Matrices Can’t figure out how to solve systems using Elimination Method? Substitution Method? Graphing? Why not try…
Laws of Thermodynamics: Too Hot, Too Cold, Just Right
Digital “ABC” Book By: Scott Bowers.
Here are some examples:
Scientific Computing Partial Differential Equations Introduction and
CHAPTER 2 ONE-DIMENSIONAL STEADY STATE CONDUCTION
Chapter 9 Numerical Integration Flow Charts, Loop Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
17.4 State Variables State variables describe the state of a system
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
Partial Differential Equations Finite Difference Approximation.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
Basics of molecular dynamics. Equations of motion for MD simulations The classical MD simulations boil down to numerically integrating Newton’s equations.
Lecture Objectives: Analyze the unsteady-state heat transfer Conduction Introduce numerical calculation methods Explicit – Implicit methods.
Linear Systems Iterative Solutions CSE 541 Roger Crawfis.
1 CHAPTER 6 HEAT TRANSFER IN CHANNEL FLOW 6.1 Introduction (1) Laminar vs. turbulent flow transition Reynolds number is where  D tube diameter  u mean.
Model Task 0A: Programming the 1D upstream scheme ATM 562 Fall 2015 Fovell 1.
Fractions  Fractions are a way of showing a portion of material compared with the whole thing.  E.g. ½ Pizza, half time, 1/3 off.
SECTION 13.8 STOKES ’ THEOREM. P2P213.8 STOKES ’ VS. GREEN ’ S THEOREM  Stokes ’ Theorem can be regarded as a higher- dimensional version of Green ’
Topics for our first Seminar The readings are Chapters 1 and 2 of your textbook. Chapter 1 contains a lot of terminology with which you should be familiar.
HW2 Due date Next Tuesday (October 14). Lecture Objectives: Unsteady-state heat transfer - conduction Solve unsteady state heat transfer equation for.
The Configuration Factors between Ring Shape Finite Areas in Cylinders and Cones Cosmin DAN, Gilbert DE MEY.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
The Generalized Interpolation Material Point Method.
Model Task 5: Implementing the 2D model ATM 562 Fall 2015 Fovell (see updated course notes, Chapter 13) 1.
Discretization Methods Chapter 2. Training Manual May 15, 2001 Inventory # Discretization Methods Topics Equations and The Goal Brief overview.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Recursion.
Copyright © 2000, Department of Systems and Computer Engineering, Carleton University 1 Introduction An array is a collection of identical boxes.
MECH4450 Introduction to Finite Element Methods
CHP-3 STACKS.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
1 Rocket Science using Charm++ at CSAR Orion Sky Lawlor 2003/10/21.
1 Foundations of circulation modeling systems EBS566: Estuary and Ocean Systems II – Lecture 3, Winter 2010 Instructors: T. Peterson, M. Haygood, A. Baptista.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Water Computational Fluid Dynamics Volumes Lagrangian vs. Eulerian modelling Navier-Stokes equations.
3/21/20161 ELECTRICITY AND MAGNETISM Phy 220 Chapter2: Gauss’s Law.
Recursion Chapter 7 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Loop Design What goes into coding a loop. Considerations for Loop Design ● There are basically two kinds of loops: ● Those that form some accumulated.
Chapter 30.
Laws of Thermodynamics: Too Hot, Too Cold, Just Right
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Estuarine models: what is under the hood?
HW2 Example MatLab Code is posted on the course website
Points, Lines, and Their Graphs
Arrays & Functions Lesson xx
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Numerical Approximation
Announcement MATHCAD for solving system of equation for HW1b
Topic 3 Discretization of PDE
Lecture Objectives: Analysis of unsteady state heat transfer HW3.
Finite Volume Method Philip Mocz.
topic4: Implicit method, Stability, ADI method
Topic 3 Discretization of PDE
Pointers and dynamic objects
Chapter 2 Section 1 Tools and Measurement.
Example 5A: Solving Simple Rational Equations
Topic 3 Discretization of PDE
Presentation transcript:

Finite Difference Methods Or Computational Calculus

 Consider the problem of heating your lunch in a microwave oven ◦ Given a known heating rate, calculate the time and temperature of your lunch Is this answer helpful? Does it represent the real world? Take a bite – why is the center cold (frozen) and edges burning hot? Treating the problem as uniform temperature does not work. This problem needs the tools of calculus.

 Break up space into small pieces (cells or zones)  Solve simple equations on each cell  As the cell size goes to zero, the solution approaches the correct values We will use the Introduction to Finite Difference Methods for Numerical Fluid Dynamics by Scannapieco and Harlow to see how to write a computational heat transfer code.

 We will read through Chapter II, pages 6-17 and construct the numerical model given there  Page 6 ◦ Note breaking up rod into zones or elements. Each zone will be an element in an array that we declare ◦ Note definition of finite difference *Discretization is just a fancy way of saying break into small zones (literally make discrete)

 Page 7 ◦ Definition of flux and conservation  Flux is the motion of something from one cell to another  Conservation is keeping the same total amount of things like mass and energy. This keeps simulations from being non-physical.  Page 8 ◦ Note the equation for an individual cell (zone) ◦ Fick’s Law is what you should see in high school physics and should be intuitive

 Bottom page 8 and top page 9 ◦ The full model is shown with jbar cells ◦ Temperatures are defined at cell centers (j) ◦ Fluxes occur at interfaces between cells (j-½,j+½) ◦ Boundary cells are added at each end for simplicity in implementing boundary conditions (array size will be 0 to j+1  Bottom page 9, top 10 ◦ Note the equations – simple, but lets check them ◦ These define energy for this problem – we will want to conserve this energy

 Page 10 – middle top ◦ In this section, the time domain is broken up into small pieces for the computation. This is similar to what was done with the space dimension and also uses calculus concepts of breaking things into pieces. ◦ Note the superscript represents time, not a power ◦ The time step, dt, must be small enough that all of the heat does not flux out of any cell (a little more complicated than this, but it gets the basic concept).

 Bottom page 10 to top page 11 ◦ Refer back to the diagram for a single cell or a single cell and its two neighbors ◦ We do a “black box” solution where we don’t worry about what is going on inside a cell and just calculate what is crossing the boundaries ◦ Write the equations for these fluxes and insert into Fick’s law. ◦ Rearrange so that T n+1 is on the left (actually dT or the change in temperature for the cell)

 Section C ◦ We will skip this section and leave it for you to read through. It uses calculus to come up with the same equation ◦ But we will take a quick look at equations II-18 and II-19 and replace ∂T with T n+1 -T n, ∂x with dx and ∂t with dt. Move dt over to the right and it becomes the same as II-12. II-19 is Fick’s Law as written in calculus

 Declare an array size j+1  Set initial temperature value  Set boundary conditions on ghost zones (0 and j+1)  Compute new temperatures as shown on pg 16. Note use of T and Tnew and discussion.  Loop back up to setting boundary condition and repeat until we reach time of interest  Print out temperature array

 Class will write a code in Python or C and see if they can get the results shown on pgs Note scales are 0-50 for x axis and for y axis.  Advanced ◦ Data can be imported into Excel or other plotting programs for a better graph ◦ Real-time visualization routines can be used to view the simulation during the calculation

#include int main(int argc, char *argv[]){ int j, jbar=50; // Problem settings double dx=1.0, dt=0.1, sig=1.0, endtime=10.0, time=0.0, TL=400.0, TR=0.0; double T[jbar+1], Tnew[jbar+1]; // Declare arrays for (j = 1; j <=jbar; j++){ T[j] = 0.0;} // Initialize to zero temperature while (time < endtime){ // Loop until time of interest T[0] = 2.0*TL – T[1]; T[jbar+1] = 2.0*TR-T[jbar]; // Set boundary conditions for (j=1; j<= jbar; j++) { Tnew[j] = T[j] + sig*dt*(T[j+1]+T[j-1]-2.0*T[j])/dx/dx; // Fick’s Law } for (j=1; j<= jbar; j++) { T[j]=Tnew[j]; } // Move data back to original array time += dt; // Advance time } for (j=1; j<=jbar; j++) {printf(“x %lf T %lf\n”,((double)j+0.5)*dx,T[j]); } // print results }

#include using namespace std; int main(int argc, char *argv[]){ int jbar=50; // Problem settings double dx=1.0, dt=0.1, sig=1.0, endtime=10.0, time=0.0, TL=400.0, TR=0.0; vector T[jbar+1], Tnew[jbar+1]; // Declare arrays for ( int j = 1; j <=jbar; j++){ T[j] = 0.0;} // Initialize to zero temperature while (time < endtime){ // Loop until time of interest T[0] = 2.0*TL – T[1]; T[jbar+1] = 2.0*TR-T[jbar]; // Set boundary conditions for (int j=1; j<= jbar; j++) { Tnew[j] = T[j] + sig*dt*(T[j+1]+T[j-1]-2.0*T[j])/dx/dx; // Fick’s Law } for (int j=1; j<= jbar; j++) { T[j]=Tnew[j]; } // Move data back to original array time += dt; // Advance time } for (j=1; j<=jbar; j++) {cout << "x " << ((double)j+0.5)*dx << " T " << T[j] << "\n"; } }

program heat integer :: j, jbar=50 ! Problem settings double precision :: dx=1.0, dt=0.1, sig=1.0, endtime=10.0, time=0.0 double precision :: TL = 400.0, TR = 0.0 double precision :: T(0:jbar+1), Tnew(0:jbar+1) ! Declare arrays T(:) = 0.0 ! Initialize to zero do if (time >= endtime) exit T(0) = 2.0*TL - T(1) ! Boundary conditions T(jbar+1) = 2.0*TR - T(jbar) do j=1,jbar Tnew(j) = T(j) + sig*dt*(T(j+1)+T(j-1)-2.0*T(j))/dx/dx ! Fick’s Law enddo T(1:jbar) = Tnew(1:jbar) ! Move data back to original array time = time+dt ! Advance time enddo do j=1,jbar print *,"x ",(dble(j)+0.5)*dx," T ", T(j) ! Print results enddo end program

x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T x T

 Time step stability is discussed starting on pg. 20. You can try this with the class model  Fluid dynamic models of various types are discussed in later chapters.  Simple turbulence models are studied. And now we can study the microwave problem – does it help to put more heat at the surface (Increase TL)? What is the fastest way to heat the food? the most energy efficient? the most even heating?