|
A Simple Example |
Top Previous Next |
|
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
This equation is satisfied by the function
Temp = Const - x^2 - y^2
as long as K is constant and Source = 4*K.
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 }
{ define the heatflow equation :} EQUATIONS div(k*grad(temp)) + source = 0
{ define the problem domain: } BOUNDARIES REGION 1 { ... only one region } { specify Dirichlet boundary at exact solution: } VALUE(temp)=texact START(-1,-1) { specify the starting point } 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 }
|