MATLAB PARTIAL DIFFERENTIAL EQUATION TOOLBOX 1 Manuel d'utilisateur Page 8

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 18
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 7
8
Solving PDEs Programatically
Although the PDE Toolbox GUI is a useful way to solve PDEs, the flexibility of using
command-line functions is sometimes useful for automating calculations, such as for
convergence studies. The easiest way to do this is to still use the PDE Toolbox GUI to define the
geometry and boundary conditions and export the decomposed geometry and boundary condition
matrices to the MATLAB environment as described above. Then, from the MATLAB
environment (or a script file) use the following functions
fid = wgeom(g, 'file_g'); % create geometry file from matrix g
fid = wbound(b, 'file_b'); % create boundary condition file from matrix b
Next, to create, refine, and jiggle a mesh use the following functions
[p, e, t] = initmesh('file_g', 'Hmax', Hm);
[p, e, t] = refinemesh('file_g', p, e, t);
p = jigglemesh(p, e, t);
One option for the initmesh function is shown that sets the minimum size, Hm, for the edge
spacing for the mesh. Use the online help to see additional options for each of these functions.
To solve an elliptic PDE defined as
−∇ c u
( )
+ a u = f
(6)
where the values of the coefficients c, a, and f must be set as string variables, use the following
function for a linear equation
u = assempde('file_b', p, e, t, c, a, f);
Alternatively, use the following function to solve a nonlinear elliptic PDE equation
[u, res] = pdenonlin('file_b', p, e, t, c, a, f, 'Jacobian', 'full', 'U0', 100);
where the options to use the full Jacobian and to specify an initial guess are set. To solve the
parabolic PDE defined as
d
u
t
∇⋅ c u
( )
+ a u = f
(7)
where the values of the coefficients d, c, a, and f must again be set as string variables and the
initial condition and number of time steps must also be set using
u0 = T0*ones(size(p, 2), 1); % initial condition, T0 is the initial temperature
Vue de la page 7
1 2 3 4 5 6 7 8 9 10 11 12 13 ... 17 18

Commentaires sur ces manuels

Pas de commentaire