Problem

You've formulated the finite difference equations for an elliptic boundary value problem and now you need to solve the resulting system of equations.

Solution

Use Excel's matrix functions to solve the system of finite difference equations.

Discussion

The finite difference method is a well-known and well-established numerical method suitable for solving partial differential equations. Virtually every book I've ever read dealing with partial differential equations covers the finite difference method to some degree. DuChateau and Zachmann give a pretty good introduction, with examples, on the application of the finite difference method to partial differential equations in their book Applied Partial Differential Equations.[*]

[*] Paul DuChateau and David Zachmann, Applied Partial Differential Equations (Mineola, N.Y.: Dover Publications, 2002; originally published 1989 by Harper & Row).

The basic idea of the finite difference method is to divide the problem domain into a finite number of cells, forming a grid. The intersections of grid lines then represent computational nodes where the value of the function sought will be approximated. The governing differential equation is then written in terms of finite differences (see Recipe 10.6). These finite differences could be forward differences, backward differences, or central differences, and they are used to approximate the derivatives appearing in the governing partial differential equations at each node in the computational grid.

Consider the Laplace equation :

If we discretize the problem domain as describe a moment ago, then at each node illustrated in Figure 12-1, we can approximate the second partial derivative of u with respect to x using the following finite difference approximation:

Figure 12-1. Finite difference nodes

Similarly, the finite difference approximation for uyy is:

Here, I'm assuming the node spacing is uniform and the same in both the x and y directions. Substitution of these finite difference approximations into the Laplace equation yields the following finite difference equation:

This equation must be satisfied at every node. Nodes adjacent to boundary nodes with Dirichlet boundary conditions will include the specified value at the boundary node. Typically, a ghost particle technique is used in the case of Neumann boundary conditions. In any case, writing this finite difference approximation at each node in the computation grid results in a system of equations that must be solved to find the u-values at each node. It's this resulting system of equations that can be solved in Excel.

For example, a rectangular domain divided into nine equal-sized cells would contain four interior nodes where values of u are sought. Applying the above finite difference equation at each node would result in a system of four equations and four unknowns. In this case, with such a small number of equations, you can use matrix formulas discussed in Recipe 9.4 to solve for the unknown u-values.

Finer computational grids, or meshes, result in a larger number of nodes and thus a larger system of equations. In these cases, it's usually more efficient and easier to use iterative methods to solve the system. Recipe 12.2 explains such an approach.

See Also

The body of literature covering finite difference methods is vast. Consult your favorite numerical methods book for more information. I found the Applied Partial Differential Equations book cited earlier in this recipe very readable and comprehensive in its coverage of the finite difference method to elliptic, parabolic, and hyperbolic problems.

Using Excel

- Introduction
- Navigating the Interface
- Entering Data
- Setting Cell Data Types
- Selecting More Than a Single Cell
- Entering Formulas
- Exploring the R1C1 Cell Reference Style
- Referring to More Than a Single Cell
- Understanding Operator Precedence
- Using Exponents in Formulas
- Exploring Functions
- Formatting Your Spreadsheets
- Defining Custom Format Styles
- Leveraging Copy, Cut, Paste, and Paste Special
- Using Cell Names (Like Programming Variables)
- Validating Data
- Taking Advantage of Macros
- Adding Comments and Equation Notes
- Getting Help

Getting Acquainted with Visual Basic for Applications

- Introduction
- Navigating the VBA Editor
- Writing Functions and Subroutines
- Working with Data Types
- Defining Variables
- Defining Constants
- Using Arrays
- Commenting Code
- Spanning Long Statements over Multiple Lines
- Using Conditional Statements
- Using Loops
- Debugging VBA Code
- Exploring VBAs Built-in Functions
- Exploring Excel Objects
- Creating Your Own Objects in VBA
- VBA Help

Collecting and Cleaning Up Data

- Introduction
- Importing Data from Text Files
- Importing Data from Delimited Text Files
- Importing Data Using Drag-and-Drop
- Importing Data from Access Databases
- Importing Data from Web Pages
- Parsing Data
- Removing Weird Characters from Imported Text
- Converting Units
- Sorting Data
- Filtering Data
- Looking Up Values in Tables
- Retrieving Data from XML Files

Charting

- Introduction
- Creating Simple Charts
- Exploring Chart Styles
- Formatting Charts
- Customizing Chart Axes
- Setting Log or Semilog Scales
- Using Multiple Axes
- Changing the Type of an Existing Chart
- Combining Chart Types
- Building 3D Surface Plots
- Preparing Contour Plots
- Annotating Charts
- Saving Custom Chart Types
- Copying Charts to Word
- Recipe 4-14. Displaying Error Bars

Statistical Analysis

- Introduction
- Computing Summary Statistics
- Plotting Frequency Distributions
- Calculating Confidence Intervals
- Correlating Data
- Ranking and Percentiles
- Performing Statistical Tests
- Conducting ANOVA
- Generating Random Numbers
- Sampling Data

Time Series Analysis

- Introduction
- Plotting Time Series Data
- Adding Trendlines
- Computing Moving Averages
- Smoothing Data Using Weighted Averages
- Centering Data
- Detrending a Time Series
- Estimating Seasonal Indices
- Deseasonalization of a Time Series
- Forecasting
- Applying Discrete Fourier Transforms

Mathematical Functions

- Introduction
- Using Summation Functions
- Delving into Division
- Mastering Multiplication
- Exploring Exponential and Logarithmic Functions
- Using Trigonometry Functions
- Seeing Signs
- Getting to the Root of Things
- Rounding and Truncating Numbers
- Converting Between Number Systems
- Manipulating Matrices
- Building Support for Vectors
- Using Spreadsheet Functions in VBA Code
- Dealing with Complex Numbers

Curve Fitting and Regression

- Introduction
- Performing Linear Curve Fitting Using Excel Charts
- Constructing Your Own Linear Fit Using Spreadsheet Functions
- Using a Single Spreadsheet Function for Linear Curve Fitting
- Performing Multiple Linear Regression
- Generating Nonlinear Curve Fits Using Excel Charts
- Fitting Nonlinear Curves Using Solver
- Assessing Goodness of Fit
- Computing Confidence Intervals

Solving Equations

- Introduction
- Finding Roots Graphically
- Solving Nonlinear Equations Iteratively
- Automating Tedious Problems with VBA
- Solving Linear Systems
- Tackling Nonlinear Systems of Equations
- Using Classical Methods for Solving Equations

Numerical Integration and Differentiation

- Introduction
- Integrating a Definite Integral
- Implementing the Trapezoidal Rule in VBA
- Computing the Center of an Area Using Numerical Integration
- Calculating the Second Moment of an Area
- Dealing with Double Integrals
- Numerical Differentiation

Solving Ordinary Differential Equations

- Introduction
- Solving First-Order Initial Value Problems
- Applying the Runge-Kutta Method to Second-Order Initial Value Problems
- Tackling Coupled Equations
- Shooting Boundary Value Problems

Solving Partial Differential Equations

- Introduction
- Leveraging Excel to Directly Solve Finite Difference Equations
- Recruiting Solver to Iteratively Solve Finite Difference Equations
- Solving Initial Value Problems
- Using Excel to Help Solve Problems Formulated Using the Finite Element Method

Performing Optimization Analyses in Excel

- Introduction
- Using Excel for Traditional Linear Programming
- Exploring Resource Allocation Optimization Problems
- Getting More Realistic Results with Integer Constraints
- Tackling Troublesome Problems
- Optimizing Engineering Design Problems
- Understanding Solver Reports
- Programming a Genetic Algorithm for Optimization

Introduction to Financial Calculations

- Introduction
- Computing Present Value
- Calculating Future Value
- Figuring Out Required Rate of Return
- Doubling Your Money
- Determining Monthly Payments
- Considering Cash Flow Alternatives
- Achieving a Certain Future Value
- Assessing Net Present Worth
- Estimating Rate of Return
- Solving Inverse Problems
- Figuring a Break-Even Point

Index

Excel Scientific and Engineering Cookbook (Cookbooks (OReilly))

ISBN: 0596008791

EAN: 2147483647

EAN: 2147483647

Year: N/A

Pages: 206

Pages: 206

Authors: David M Bourg

Similar book on Amazon

Flylib.com © 2008-2017.

If you may any questions please contact us: flylib@qtcs.net

If you may any questions please contact us: flylib@qtcs.net