A Simple Example

<< Click to Display Table of Contents >>

Navigation:  Problem Descriptor Reference > Introduction >

A Simple Example

Previous pageReturn to chapter overviewNext page

As a preview example to give the flavor of a FlexPDE descriptor file, we will construct a model of heatflow on a square domain.

The heatflow equation is      

    div(K*grad(Temp)) + Source = 0

If K is constant and Source = 4*K, the heat equation will be satisfied by the function      

    Temp = Const - x^2 - y^2 .    

We define a square region of material of conductivity K = 1, with a uniform heat source of 4 heat units per unit area.

We further specify the boundary value

    Temp = 1 - x^2 - y^2    

Since we know the analytic solution, we can compare the accuracy of the FlexPDE solution.

 

The text of the descriptor is as follows:

{ *******************************************************************  

SIMPLE.PDE

This sample demonstrates the simplest application of FlexPDE to

heatflow problems.      

******************************************************************* }

   

TITLE "Simple Heatflow"

 

VARIABLES

temp                { Identify "Temp" as the system variable }

   

DEFINITIONS

k = 1                { declare and define the conductivity }

source = 4                { declare and define the source }

texact = 1-x^2-y^2        { exact solution for reference }

   

INITIAL VALUES

temp = 0        { unimportant in linear steady-state problems,

         but necessary for time-dependent or nonlinear

         systems }

 

EQUATIONS        { define the heatflow equation :}

div(k*grad(temp)) + source = 0      

 

                       

BOUNDARIES   { define the problem domain: }            

REGION 1                { ... only one region }

START(-1,-1)        { specify the starting point }

  { specify Dirichlet boundary at exact solution: }

  VALUE(temp)=texact

LINE TO (1,-1)        { walk the boundary }

TO (1,1)

TO (-1,1)

TO CLOSE        { bring boundary back to starting point }

   

MONITORS

CONTOUR(temp)        { show the Temperature during solution }

   

PLOTS          { write these plots to disk at completion: }

   

CONTOUR(temp)        { show the solution }

SURFACE(temp)        { show a surface plot as well }

                 { display the solution error :}

CONTOUR(temp-texact) AS "Error"

                       { show a vector flow plot: }

VECTOR(-dx(temp),-dy(temp)) AS "Heat Flow"

   

END                        { end of descriptor file }