|
NonLinODE |
Top Previous Next |
|
{ NONLINODE.PDE }
{ *************************************************************
This example shows the application of FlexPDE to the solution of a non-linear first-order differential equation.
A liquid flows into the top of a reactor vessel through an unrestricted pipe and exits from the bottom through a choke value. This problem is discussed in detail in Silebi and Schiesser.
This is a problem in viscous flow:
dH/dt = a - b*sqrt(H)
The analytic solution satisfies the relation
sqrt(H0) + (a/b)ln[a-b*sqrt(H0)] - sqrt(H) - (a/b)ln[a-b*sqrt(H)] = (b/2)*t
which can be used as an accuracy check.
************************************************************* }
title "NONLINEAR FIRST ORDER ORDINARY DIFFERENTIAL EQUATION"
select ngrid=1 { Since there is no spatial information required, use the minimum grid size }
variables Height(threshold=1) { declare Height to be the system variable }
definitions a = 2 { define the equation parameters } b = 0.1 H0 = 100 { define the accuracy check } T0 = sqrt(H0) + (a/b)*ln(a-b*sqrt(H0)) Tcheck = sqrt(Height) + (a/b)*ln(a-b*sqrt(Height))
initial values Height = H0
equations dt(Height) = a - b*sqrt(Height) { The ODE }
boundaries region 1 { define a fictitious spatial domain } start (0,0) line to (1,0) to (1,1) to (0,1) to close
time 0 to 1000 { define the time range }
histories { Plot the solution: } history(Height) at (0.5,0.5) { Plot the accuracy check: } history([T0 - Tcheck - (b/2)*t]/[(b/2)*t]) at (0.5,0.5) as "Relative Error"
end |