---
title: "PDESolve"
language: "en"
type: "Symbol"
summary: "PDESolve[cdata, bcdata, vd, sd, mdata] solves a PDE based on coefficient data cdata, boundary condition data bcdata, variable data vd, solution data sd and method data mdata to return new solution data."
keywords: 
- PDE
- partial differential equation
- non-linear
- nonlinear
- non-liner differential equation
- nonlinear differential equation
- root
- find root
- FindRoot
- newton
- solve
- PDESolveOptions
- "PDESolveOptions"
- PDE solve options
canonical_url: "https://reference.wolfram.com/language/FEMDocumentation/ref/PDESolve.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Finite Element Method"
    link: "https://reference.wolfram.com/language/FEMDocumentation/guide/FiniteElementMethodGuide.en.md"
related_tutorials: 
  - 
    title: "Finite Element Programming"
    link: "https://reference.wolfram.com/language/FEMDocumentation/tutorial/FiniteElementProgramming.en.md"
  - 
    title: "NDSolve Finite Element Options"
    link: "https://reference.wolfram.com/language/FEMDocumentation/tutorial/FiniteElementOptions.en.md"
  - 
    title: "Affine Covariant Newton's Method"
    link: "https://reference.wolfram.com/language/tutorial/UnconstrainedOptimizationMethodsForSolvingNonlinearEquations.en.md#45025331"
---
## NDSolve\`FEM\`

# PDESolve

PDESolve[cdata, bcdata, vd, sd, mdata] solves a PDE based on coefficient data cdata, boundary condition data bcdata, variable data vd, solution data sd and method data mdata to return new solution data.

## Details and Options

* ``PDESolve`` solves linear and nonlinear stationary partial differential equations.

* ``PDESolve`` returns a list that is the ``solution data``.

* The coefficient data ``cdata`` is a ``PDECoefficientData`` object generated by ``InitializePDECoefficients``.

* The boundary condition data ``bcdata`` is a ``BoundaryConditionData`` object generated by ``InitializeBoundaryConditions``.

* Variable data ``vd`` and solution data ``sd`` are corresponding lists of variables and values. Templates for ``vd`` and ``sd`` may be generated using ``NDSolve\`VariableData`` and ``NDSolve\`SolutionData``, and components may be set using ``NDSolve\`SetSolutionDataComponent``.

* The method data ``mdata`` is a PDE method data object, such as ``FEMMethodData``, generated through ``InitializePDEMethodData``.

* ``PDESolve`` takes the following options:

|                    |           |                                            |
| ------------------ | --------- | ------------------------------------------ |
| "FindRootOptions"  | Automatic | specify options for FindRoot               |
| "LinearSolver"     | Automatic | specify a linear solver and options for it |

* Options given to ``PDESolve`` can be given to ``NDSolve`` by specifying ``"PDESolveOptions"``. »

* Setting the option from ``NDSolve`` and related functions is explained in [NDSolve Finite Element Options](https://reference.wolfram.com/language/FEMDocumentation/tutorial/FiniteElementOptions.en.md).

---

## Examples (12)

### Basic Examples (3)

Load the finite element package:

```wl
In[1]:= Needs["NDSolve`FEM`"]
```

Set up a ``NumericalRegion`` :

```wl
In[2]:= nRegion = ToNumericalRegion[Rectangle[{0, 0}, {1, 1 / 2}]]

Out[2]= NumericalRegion[FullRegion[2], {{0, 1}, {0, (1/2)}}]
```

Set up variable and solution data:

```wl
In[3]:=
vd = NDSolve`VariableData[{"DependentVariables", "Space"} -> {{u}, {x, y}}];
sd = NDSolve`SolutionData[{"Space"} -> {nRegion}];
```

Initialize the partial differential equation data:

```wl
In[4]:= methodData = InitializePDEMethodData[vd, sd]

Out[4]= FEMMethodData[<1394,{2},4>]
```

---

Set up the solution of the linear PDE $\nabla \cdot (-\nabla \text{\textit{$u$}}\text{\textit{$)$}}=0$. Initialize the linear coefficients:

```wl
In[1]:= pdeData = InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-IdentityMatrix[2]}}]

Out[1]= PDECoefficientData[<1,2>]
```

Initialize the linear boundary condition data:

```wl
In[2]:= bcData = InitializeBoundaryConditions[vd, sd, {{DirichletCondition[u[x, y] == 0., x == 0]}}]

Out[2]= BoundaryConditionData[<1,2>]
```

Solve the PDE:

```wl
In[3]:= sdNew = PDESolve[pdeData, bcData, vd, sd, methodData];
```

Post-process the PDE:

```wl
In[4]:= ProcessPDESolutions[methodData, sdNew]

Out[4]=
{InterpolatingFunction[{{0., 1.}, {0., 0.5}}, {5, 4225, 0, {1394, 0}, {3, 0}, 0, 0, 0, 0, Automatic, 
  {}, {}, False}, {NDSolve`FEM`ElementMesh[CompressedData["«5848»"], 
   {NDSolve`FEM`QuadElement[CompressedData["«6524»"]]}, {NDSolve`FEM`LineElem ...  3, 1, 3, 1, 3, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
      4, 4, 4, 4, 4, 3}]}, {NDSolve`FEM`PointElement[CompressedData["«458»"]]}]}, CompressedData[
  "\n1:eJztwTENACAQBLBjQMhbQgIJMwn+hxfB2rb2XWckeTMAAAAAAAAAAAAAwIcG\nAkoCIg==\n    "], {Automatic}]}
```

---

Set up the solution of the nonlinear PDE $\nabla \cdot \left(-\sqrt{\text{\textit{$u$}}}\nabla \text{\textit{$u$}}\text{\textit{$)$}}\right.=0$. Initialize the nonlinear coefficients:

```wl
In[1]:= npdeData = InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-Sqrt[u[x, y]] * IdentityMatrix[2]}}]

Out[1]= PDECoefficientData[<1,2>]
```

Initialize nonlinear boundary condition data:

```wl
In[2]:= nbcData = InitializeBoundaryConditions[vd, sd, {{DirichletCondition[u[x, y] == 0., x == 0], NeumannValue[u[x, y] ^ 2, x == 1]}}]

Out[2]= BoundaryConditionData[<1,2>]
```

Specify an initial guess:

```wl
In[3]:= NDSolve`SetSolutionDataComponent[sd, "Dependent", {1}]

Out[3]= {1}
```

Solve the nonlinear PDE:

```wl
In[4]:= sdnew = PDESolve[npdeData, nbcData, vd, sd, methodData];
```

Post-process the PDE:

```wl
In[5]:= ProcessPDESolutions[methodData, sdNew]

Out[5]=
{InterpolatingFunction[{{0., 1.}, {0., 0.5}}, {5, 4225, 0, {1394, 0}, {3, 0}, 0, 0, 0, 0, Automatic, 
  {}, {}, False}, {NDSolve`FEM`ElementMesh[CompressedData["«5848»"], 
   {NDSolve`FEM`QuadElement[CompressedData["«6524»"]]}, {NDSolve`FEM`LineElem ...  3, 1, 3, 1, 3, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 
      4, 4, 4, 4, 4, 3}]}, {NDSolve`FEM`PointElement[CompressedData["«458»"]]}]}, CompressedData[
  "\n1:eJztwTENACAQBLBjQMhbQgIJMwn+hxfB2rb2XWckeTMAAAAAAAAAAAAAwIcG\nAkoCIg==\n    "], {Automatic}]}
```

---

### Options (8)

#### "FindRootOptions" (5)

Inspect the number of function calls, steps and Jacobian evaluations needed:

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"FindRootOptions" -> {
	Jacobian -> {Automatic, EvaluationMonitor :> j++}
	, EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[7]:= "Function Evaluations = "40"\nSteps = "37"\nJacobian Evaluations = "3
```

---

Specify that ``PDESolve`` is to use the default ``FindRoot`` root-finding algorithm:

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"FindRootOptions" -> {
	Method -> {"Newton"}
	, Jacobian -> {Automatic, EvaluationMonitor :> j++}
	, EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[1]:= "Function Evaluations = "9"\nSteps = "8"\nJacobian Evaluations = "8
```

---

Specify that ``PDESolve`` is to use the default affine covariant Newton method:

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"FindRootOptions" -> {
	Method -> {"AffineCovariantNewton"}
	, Jacobian -> {Automatic, EvaluationMonitor :> j++}
	, EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[1]:= "Function Evaluations = "40"\nSteps = "37"\nJacobian Evaluations = "3
```

---

Set up ``PDESolve`` to not use Broyden updates:

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"FindRootOptions" -> {
	Method -> {"AffineCovariantNewton", "BroydenUpdates" -> False}
	, Jacobian -> {Automatic, EvaluationMonitor :> j++}
	, EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[1]:= "Function Evaluations = "8"\nSteps = "7"\nJacobian Evaluations = "6
```

---

Set a ``PrecisionGoal`` for the default ``PDESolve`` ``FindRoot`` method:

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"FindRootOptions" -> {PrecisionGoal -> 4, 
	Jacobian -> {Automatic, EvaluationMonitor :> j++}, 
	EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[1]:= "Function Evaluations = "13"\nSteps = "12"\nJacobian Evaluations = "1
```

#### "LinearSolver" (3)

Specify ``PDESolve`` to use a direct method for ``LinearSolve`` :

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"LinearSolver" -> {LinearSolve, "Method" -> "Direct"}, 
	"FindRootOptions" -> {Jacobian -> {Automatic, EvaluationMonitor :> j++}, 
	EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[11]:= "Function Evaluations = "40"\nSteps = "37"\nJacobian Evaluations = "3
```

---

Specify ``PDESolve`` to use a Krylov method for ``LinearSolve`` :

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"LinearSolver" -> {Automatic, "Method" -> "Krylov"}, 
	"FindRootOptions" -> {
	Jacobian -> {Automatic, EvaluationMonitor :> j++}
	, EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[12]:= "Function Evaluations = "40"\nSteps = "37"\nJacobian Evaluations = "3
```

---

Specify ``PDESolve`` to use a customer function for ``LinearSolve`` :

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	PDESolve[npdeData, nbcData, vd, sd, methodData, 
	"LinearSolver" -> {(Print["LinearSolverCall"];LinearSolve[#])&}, 
	"FindRootOptions" -> {
	Jacobian -> {Automatic, EvaluationMonitor :> j++}, 
	EvaluationMonitor :> e++, StepMonitor :> s++}
	];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[15]:= "LinearSolverCall"

During evaluation of In[15]:= "LinearSolverCall"

During evaluation of In[15]:= "LinearSolverCall"

During evaluation of In[15]:= "Function Evaluations = "40"\nSteps = "37"\nJacobian Evaluations = "3
```

---

### Properties & Relations (1)

Options given to ``PDESolve`` can be given to ``NDSolve`` by specifying ``"PDESolveOptions"`` :

```wl
In[1]:=
Block[{e = 0, s = 0, j = 0}, 
	NDSolve[{-Inactive[Div][(1/Sqrt[1 + Grad[u[x, y], {x, y}] . Grad[u[x, y], {x, y}]])*
  Inactive[Grad][u[x, y], {x, y}], {x, y}] == 0, DirichletCondition[u[x, y] == Sin[2π * (x + y)], True]}, u, {x, y}∈Disk[], Method -> {"FiniteElement", "PDESolveOptions" -> "FindRootOptions" -> {
	Jacobian -> {Automatic, EvaluationMonitor :> j++}
	, EvaluationMonitor :> e++, StepMonitor :> s++}}];
	Print["Function Evaluations = ", e, "
Steps = ", s, "
Jacobian Evaluations = ", j];
	]

During evaluation of In[11]:= "Function Evaluations = "22"\nSteps = "20"\nJacobian Evaluations = "6
```

## See Also

* [InitializePDECoefficients](https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.en.md)
* [PDECoefficientData](https://reference.wolfram.com/language/FEMDocumentation/ref/PDECoefficientData.en.md)
* [InitializeBoundaryConditions](https://reference.wolfram.com/language/FEMDocumentation/ref/InitializeBoundaryConditions.en.md)
* [BoundaryConditionData](https://reference.wolfram.com/language/FEMDocumentation/ref/BoundaryConditionData.en.md)
* [InitializePDEMethodData](https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDEMethodData.en.md)
* [FEMMethodData](https://reference.wolfram.com/language/FEMDocumentation/ref/FEMMethodData.en.md)
* [DeployBoundaryConditions](https://reference.wolfram.com/language/FEMDocumentation/ref/DeployBoundaryConditions.en.md)
* [ProcessPDESolutions](https://reference.wolfram.com/language/FEMDocumentation/ref/ProcessPDESolutions.en.md)
* [`LinearSolve`](https://reference.wolfram.com/language/ref/LinearSolve.en.md)
* [`FindRoot`](https://reference.wolfram.com/language/ref/FindRoot.en.md)
* [`NDSolve`](https://reference.wolfram.com/language/ref/NDSolve.en.md)

## Tech Notes

* [Finite Element Programming](https://reference.wolfram.com/language/FEMDocumentation/tutorial/FiniteElementProgramming.en.md)
* [NDSolve Finite Element Options](https://reference.wolfram.com/language/FEMDocumentation/tutorial/FiniteElementOptions.en.md)
* [Affine Covariant Newton's Method](https://reference.wolfram.com/language/tutorial/UnconstrainedOptimizationMethodsForSolvingNonlinearEquations.en.md#45025331)

## Related Guides

* [Finite Element Method](https://reference.wolfram.com/language/FEMDocumentation/guide/FiniteElementMethodGuide.en.md)