Main Content

Solve Problems Using PDEModel Objects

  1. Put your problem in the correct form for Partial Differential Equation Toolbox™ solvers. For details, seeEquations You Can Solve Using PDE Toolbox. If you need to convert your problem to divergence form, seePut Equations in Divergence Form.

  2. 创建一个PDEModelmodel container. For scalar PDEs, usecreatepdewith no arguments.

    model = createpde();

    IfNis the number of equations in your system, usecreatepdewith input argumentN.

    model = createpde(N);
  3. Import or create the geometry. For details, seeGeometry and Mesh.

    importGeometry(model,'geometry.stl');% importGeometry for 3-DgeometryFromEdges(model,g);% geometryFromEdges for 2-D
  4. View the geometry so that you know the labels of the boundaries.

    pdegplot(model,'FaceLabels','on')% 'FaceLabels' for 3-Dpdegplot(model,'EdgeLabels','on')% 'EdgeLabels' for 2-D

    To see labels of a 3-D model, you might need to rotate the model, or make it transparent, or zoom in on it. SeeSTL File Import.

  5. Create the boundary conditions. For details, seeSpecify Boundary Conditions.

    % 'face' for 3-DapplyBoundaryCondition(model,'dirichlet','face',[2,3,5],'u',[0,0]);% 'edge' for 2-DapplyBoundaryCondition(model,'neumann',“边缘”,[1,4],'g',1,'q',eye(2));
  6. Create the PDE coefficients.

    f = [1;2]; a = 0; c = [1;3;5]; specifyCoefficients(model,'m',0,'d',0,'c',c,'a',a,'f',f);
  7. For time-dependent equations, or optionally for nonlinear stationary equations, create an initial condition. SeeSet Initial Conditions.

  8. Create the mesh.

    generateMesh(model);
  9. Call the appropriate solver. For all problems except for eigenvalue problems, callsolvepde.

    result = solvepde(model);% for stationary problemsresult = solvepde(model,tlist);% for time-dependent problems

    For eigenvalue problems, usesolvepdeeig:

    result = solvepdeeig(model);
  10. Examine the solution. SeeSolution and Gradient Plots with pdeplot and pdeplot3D,2-D Solution and Gradient Plots with MATLAB Functions, and3-D Solution and Gradient Plots with MATLAB Functions.

See Also

|||||||