InitializePDECoefficients

InitializePDECoefficients[vd,sd,rules]
initializes the coefficients specified by rules in accordance with variable data vd and solution data sd to generate a PDECoefficientData object.
Details and Options
- The coefficients are assumed to come from a second-order system of
PDEs in
space dimensions of the form:
- In InitializePDECoefficients[vd,sd,rules], the rules should be of the form name->coefficient. The possible coefficient names are:
-
"LoadCoefficients" {{f1},{f2},…} is a scalar
"LoadDerivativeCoefficients" {{γ1},{γ2},…} is a vector of length
"DiffusionCoefficients" {{-c11,-c12,…},{-c21,-c22,…},…} may be specified as scalars, diagonal vectors of length
, or
×
matrices
"ConservativeConvectionCoefficients" {{-α11,-α12,…},{-α21,-α22,…},…} is a vector of length
"ConvectionCoefficients" {{β11,β12,…},{β21,β22,…},…} is a vector of length
"ReactionCoefficients" {{a11,a12,…},{a21,a22,…},…} is a scalar
- If a rule is not specified for any of these coefficient names, the coefficients of that type are all assumed to be 0.
- DiscretizePDE will take the generated PDECoefficientData object and provide system matrices such that
- where
is the stiffness matrix and
a load vector.
- Transient systems of PDEs may be specified up through second, with
the first-order temporal derivative and
the second-order temporal derivative.
- The transient coefficient form is:
- DiscretizePDE will take the generated PDECoefficientData object and provide system matrices such that
- where
is the mass matrix,
the damping matrix,
the stiffness matrix and
a load vector.
- The possible damping coefficient names are:
-
"DampingDiffusionCoefficients" {{-dc11,-dc12,…},{-dc21,-dc22,…},…} may be specified as scalars, diagonal vectors of length
or
×
matrices
"DampingConservativeConvectionCoefficients" {{-dα11,-dα12,…},{-dα21,-dα22,…},…} is a vector of length
"DampingConvectionCoefficients" {{dβ11,dβ12,…},{dβ21,dβ22,…},…} is a vector of length
"DampingReactionCoefficients" {{dα11,dα12,…},{dα21,dα22,…},…} is a scalar
- The possible mass coefficient names are:
-
"MassDiffusionCoefficients" {{-mc11,-mc12,…},{-mc21,-mc22,…},…} may be specified as scalars, diagonal vectors of length
or
×
matrices
"MassConservativeConvectionCoefficients" {{-mα11,-mα12,…},{-mα21,-mα22,…},…} is a vector of length
"MassConvectionCoefficients" {{mβ11,mβ12,…},{mβ21,mβ22,…},…} is a vector of length
"MassReactionCoefficients" {{mα11,mα12,…},{mα21,mα22,…},…} is a scalar
- "Mass" coefficients contribute to the mass matrix
, "Damping" coefficients contribute to the damping matrix
, and the remaining coefficients contribute to the stiffness matrix
and the load vector
.
- NDSolve reduces transient systems so that they are first order in time.
- The coefficients can be functions of space, time, parameters, dependent variables and first-order derivatives of dependent variables.
- 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.
- InitializePDECoefficients verifies and optimizes the coefficients in accordance with variable data vd and solution data sd.
- The "Space" component of vd and sd should be set to the spatial variables and the spatial mesh represented as a NumericalRegion object, respectively.
- The "DependentVariables" component of vd should be a list of dependent variable name symbols without arguments.
- For time-dependent problems, the "Time" component of vd and sd should be set to the temporal variable and the initial time, respectively.
- For nonlinear problems, the "DependentVariables" component of sd should be set to the initial seedings for the dependent variables.
- For parametric problems, the "Parameters" component of vd and sd should be set to the parametric variables and the initial parametric values, respectively.
- InitializePDECoefficients has the following options:
-
"VerificationData" Automatic specify PDE coefficient verification data - Options given to InitializePDECoefficients can be given to NDSolve by specifying "InitializePDECoefficientsOptions". »
- Setting the option from NDSolve and related functions is explained in NDSolve Finite Element Options.




Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Load the finite element package:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-8h62vh
Set up a NumericalRegion:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-nx6wf8

Set up variable and solution data:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-b1fv3m
Convert a Laplace equation into coefficients:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-b5959b

Convert a Poisson equation into coefficients:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-8qm7wn

Scope (6)Survey of the scope of standard use cases
Coefficients can be functions:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-sm54k1

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-s01j07

Coefficients can be interpolation functions:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-nxwc8j


https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-pfs6vg

Coefficients can be nonlinear:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-pn0344

If the input for "DiffusionCoefficient" is a vector, it is interpreted as the diagonal of the requested input matrix:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-6u3xc9

If the input for "DiffusionCoefficient" is a scalar, the scalar is put in all places of the diagonal of the requested matrix:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-uqdhg2


https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-vcu24u

Options (1)Common values & functionality for each option
"VerificationData" (1)
The PDE coefficients that are given to InitializePDECoefficients are verified so that they evaluate to numeric input:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-j59okn

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-2umezb

The verification is done by finding a test coordinate that lies within the NumericalRegion. It may, however, happen that the automatically chosen test coordinate or test ElementMarker are at a singularity:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-hfjmfn

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-8aplpl


Overwriting the automatic finding of the verification data can be done with the "VerificationData" option:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-mrb0ly

Additionally, the automatic ElementMarker can be changed:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-ki07ir

For nonlinear problems, the verification data for the dependents and the derivative of the dependents can be modified with "DependentVariables" and "DependentVariablesDerivative", respectively:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-l0c2wl


Change the test value for the dependent variable to be 1 and not 0 from the initial condition:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-iqjq3y

Change the test value of the derivative of the dependent variable to the vector {1,1}. The components of the vector are the values of the derivative in each space direction. Currently, a default 0.1 is used:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-f87lx1

Applications (6)Sample problems that can be solved with this function
Specify a Laplace equation over a disk with Dirichlet and Neumann conditions
for
and
for
:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-xqi7ef
Inspect the diffusion coefficients:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-g927gy

Discretize, solve, interpolate and visualize the solution:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-uuyati


The "LoadCoefficients" coefficient is used by NIntegrate to integrate over a region:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-83gexl

Use NIntegrate to verify the result:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-omot2s

A "ReactionCoefficients" of can be used to evaluate a function, for example,
over a region:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-z7fab6

Visualize the evaluated function:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-zc2jio

A "ReactionCoefficients" of in combination with a "LoadCoefficients" can be used to scale a function, for example,
over a region by a factor of
:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-fxi2vc

Visualize the scaled evaluated function:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-wzovri

A "ReactionCoefficients" in combination with a "LoadDerivativeCoefficients" can be used to interpolate the derivative of a function over a region:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-x48blj

Visualize the difference between the numerical approximation and the exact derivative:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-gpknbt

Specify an equation with mixed spatial and temporal derivatives in the domain
:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-c9wnfg

Specify Dirichlet conditions ,
and initial conditions
:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-gj2u7m

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-8xqcxf
Set up the variable and solution data:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-5je4l7

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-c0dos2

Initialize the boundary conditions:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-3jwuaj


https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-b0ba08

Discretize the PDE coefficients. In this case, all PDE coefficients are time independent:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-su51q3

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-jh0gh3


https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-dn20ki

Discretize the boundary conditions:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-n6hv6b

Write a function to compute the residual of the PDE:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-c6q587
Evaluate the initial conditions:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-idz4e3
Set up a function for the sparsity patterns of the system matrices:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-pavdg9
Compute the sparsity patterns:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-sbrj3k


https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-lus18j

Create a unified interpolating function:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-jwtoqv

For comparison, compute a solution with the tensor product grid method:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-rcdb8l

Plot the difference between the TPG and FEM methods:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-yb62od

Properties & Relations (2)Properties of the function, and connections to other functions
Options given to InitializePDECoefficients can be given to NDSolve by specifying "InitializePDECoefficientOptions":

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-9gdph9


Specify "VerificationData" to pass a coordinate that is not at a singularity:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-lcfue1

Convert a Poisson equation into coefficients:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-gkzn0c

Use GetInactivePDE to create an inactive version of the input:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-b1mpgj

Possible Issues (1)Common pitfalls and unexpected behavior
Typically, NDSolve will detect if coefficients do not evaluate to numeric quantities with the correct dimensions and warn about that:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-fr9zuf


To verify that the coefficients given are adequate for each operator, the coefficients undergo a test evaluation using the initial point in time and a coordinate from the region. If the combination of the coefficient and the used values cancel out, NDSolve cannot detect if a coefficient has not been specified. NDSolve will then give a message that it was not able to compute the elements contributed by a specific operator:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-vr0yxl





In the preceding case, evaluating the load operator at t=0 and x=-π will let the load operator vanish, and NDSolve cannot detect that k has not been specified:

https://wolfram.com/xid/0cdrkk1d8duramw5ruzxu22z52rqc82-et0bjp

Wolfram Research (2014), InitializePDECoefficients, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html (updated 2024).
Text
Wolfram Research (2014), InitializePDECoefficients, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html (updated 2024).
Wolfram Research (2014), InitializePDECoefficients, Wolfram Language function, https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html (updated 2024).
CMS
Wolfram Language. 2014. "InitializePDECoefficients." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html.
Wolfram Language. 2014. "InitializePDECoefficients." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html.
APA
Wolfram Language. (2014). InitializePDECoefficients. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html
Wolfram Language. (2014). InitializePDECoefficients. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html
BibTeX
@misc{reference.wolfram_2025_initializepdecoefficients, author="Wolfram Research", title="{InitializePDECoefficients}", year="2024", howpublished="\url{https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html}", note=[Accessed: 25-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_initializepdecoefficients, organization={Wolfram Research}, title={InitializePDECoefficients}, year={2024}, url={https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html}, note=[Accessed: 25-April-2025
]}