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.
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.
更多信息和选项
- 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"DampingCoefficients" {{d11,d12,…},{d21,d22,…},…}
is a scalar"MassCoefficients" {{m11,m12,…},{m21,m22,…},…}
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.
- Transient system of PDEs may be specified up through second order based on the form:
- 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.
范例
打开所有单元 关闭所有单元基本范例 (2)
Load the finite element package:
Needs["NDSolve`FEM`"]Set up a NumericalRegion:
nr = ToNumericalRegion[Disk[]]Set up variable and solution data:
vd = NDSolve`VariableData[{"DependentVariables", "Space"} -> {{u}, {x, y}}];
sd = NDSolve`SolutionData["Space" -> nr];Convert a Laplace equation
into coefficients:
InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-IdentityMatrix[2]}}]Convert a Poisson equation
into coefficients:
InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-IdentityMatrix[2]}}, "LoadCoefficients" -> {{1}}]Scope (6)
Coefficients can be functions:
f[x_, y_] := {{x ^ 2, 0}, {x + y, y ^ 2}}InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-f[x, y]}}]Coefficients can be interpolation functions:
if = Interpolation[Flatten[Table[Evaluate[{{x, y}, Sin[x y]}], {x, 0, 1, 0.2}, {y, 0, 1 / 2, 0.1}], 1]]InitializePDECoefficients[vd, sd, "LoadCoefficients" -> {{-if[x, y]}}]Coefficients can be nonlinear:
sdnonlinear = sd;
NDSolve`SetSolutionDataComponent[sdnonlinear, "DependentVariables", {0.}];
InitializePDECoefficients[vd, sdnonlinear, "DiffusionCoefficients" -> {{{{-u[x, y], 0}, {0, -Derivative[1, 0][u][x, y]}}}}]If the input for "DiffusionCoefficient" is a vector, it is interpreted as the diagonal of the requested input matrix:
InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-{1, 1}}}] === InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-IdentityMatrix[2]}}]If the input for "DiffusionCoefficient" is a scalar, the scalar is put in all places of the diagonal of the requested matrix:
InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-1}}] === InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-IdentityMatrix[2]}}]vd2 = vd;
NDSolve`SetSolutionDataComponent[vd2, "DependentVariables", {u, v}];
InitializePDECoefficients[vd2, sd, "DiffusionCoefficients" -> -{{{{(100000/91), 0}, {0, (5000/13)}}, {{0, (30000/91)}, {(5000/13), 0}}}, {{{0, (5000/13)}, {(30000/91), 0}}, {{(5000/13), 0}, {0, (100000/91)}}}}]Options (1)
"VerificationData" (1)
The PDE coefficients that are given to InitializePDECoefficients are verified so that they evaluate to numeric input:
f[x_ ? NumericQ, y_ ? NumericQ] := (Print["Test Coordinate: ", {x, y}];1)InitializePDECoefficients[vd, sd, "ReactionCoefficients" -> {{-f[x, y]}}]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:
f[x_ ? NumericQ, y_ ? NumericQ] := (Print["Test Coordinate: ", {x, y}];1 / (x + 0.5 + y + 0.5))InitializePDECoefficients[vd, sd, "ReactionCoefficients" -> {{-f[x, y]}}]Overwriting the automatic finding of the verification data can be done with the "VerificationData" option:
InitializePDECoefficients[vd, sd, "ReactionCoefficients" -> {{-f[x, y]}}, "VerificationData" -> {"Coordinate" -> {0, 0}}]Additionally, the automatic ElementMarker can be changed:
InitializePDECoefficients[vd, sd, "ReactionCoefficients" -> {{-f[x, y]}}, "VerificationData" -> {"Coordinate" -> {0, 0}, "ElementMarker" -> 1}]For nonlinear problems, the verification data for the dependents and the derivative of the dependents can be modified with "DependentVariables" and "DependentVariablesDerivative", respectively:
sdnonlinear = sd;
NDSolve`SetSolutionDataComponent[sdnonlinear, "DependentVariables", {0.}];
InitializePDECoefficients[vd, sdnonlinear, "ReactionCoefficients" -> {{-1 / u[x, y]}}]
Change the test value for the dependent variable to be 1 and not 0 from the initial condition:
InitializePDECoefficients[vd, sdnonlinear, "ReactionCoefficients" -> {{-1 / u[x, y]}}, "VerificationData" -> {"DependentVariables" -> {1}}]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:
InitializePDECoefficients[vd, sdnonlinear, "ReactionCoefficients" -> {{-1 / (0.1 - Derivative[1, 0][u][x, y])}}, "VerificationData" -> {"DependentVariablesDerivatives" -> {{1, 1}}}]Applications (5)
Specify a Laplace equation
over a disk with Dirichlet and Neumann conditions
for
and
for
:
pded = InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-IdentityMatrix[2]}}];
bcd = InitializeBoundaryConditions[vd, sd, {{DirichletCondition[u[x, y] == 0, x ≤ -0.3], NeumannValue[1., x ≥ 0.35]}}];
md = InitializePDEMethodData[vd, sd];Inspect the diffusion coefficients:
pded["DiffusionCoefficients"]Discretize, solve, interpolate and visualize the solution:
dpde = DiscretizePDE[pded, md, sd];
dbc = DiscretizeBoundaryConditions[bcd, md, sd];
{l, s, d, m} = dpde["SystemMatrices"];
DeployBoundaryConditions[{l, s, d, m}, dbc]
res = LinearSolve[s, l];
efun = ElementMeshInterpolation[{nr["ElementMesh"]}, res];
Plot3D[efun[x, y], {x, y}∈nr["ElementMesh"]]The "LoadCoefficients" coefficient is used by NIntegrate to integrate over a region:
vd = NDSolve`VariableData[{"DependentVariables", "Space"} -> {{u}, {x, y}}];
sd = NDSolve`SolutionData["Space" -> ToNumericalRegion[Disk[]]];
ipde = InitializePDECoefficients[vd, sd, "LoadCoefficients" -> {{1}}];
md = InitializePDEMethodData[vd, sd];
dpde = DiscretizePDE[ipde, md, sd];
Total[dpde["LoadVector"], 2]Use NIntegrate to verify the result:
NIntegrate[1, {x, y}∈Disk[]]A "ReactionCoefficients" of
can be used to evaluate a function, for example,
over a region:
vd = NDSolve`VariableData[{"DependentVariables", "Space"} -> {{u}, {x, y}}];
sd = NDSolve`SolutionData["Space" -> ToNumericalRegion[Disk[]]];
ipde = InitializePDECoefficients[vd, sd, "ReactionCoefficients" -> {{1}}, "LoadCoefficients" -> {{x ^ 2 + y ^ 2}}];
md = InitializePDEMethodData[vd, sd];
dpde = DiscretizePDE[ipde, md, sd];
sol = LinearSolve[dpde["StiffnessMatrix"], dpde["LoadVector"]];
if = ElementMeshInterpolation[{md["ElementMesh"]}, sol]Visualize the evaluated function:
Plot3D[if[x, y], {x, y}∈Disk[]]A "ReactionCoefficients" of
in combination with a "LoadCoefficients" can be used to scale a function, for example,
over a region by a factor of
:
vd = NDSolve`VariableData[{"DependentVariables", "Space"} -> {{u}, {x, y}}];
sd = NDSolve`SolutionData["Space" -> ToNumericalRegion[Disk[]]];
ipde = InitializePDECoefficients[vd, sd, "ReactionCoefficients" -> {{10}}, "LoadCoefficients" -> {{x ^ 2 + y ^ 2}}];
md = InitializePDEMethodData[vd, sd];
dpde = DiscretizePDE[ipde, md, sd];
sol = LinearSolve[dpde["StiffnessMatrix"], dpde["LoadVector"]];
if = ElementMeshInterpolation[{md["ElementMesh"]}, sol]Visualize the scaled evaluated function:
Plot3D[if[x, y], {x, y}∈Disk[], PlotRange -> All]A "ReactionCoefficients" in combination with a "LoadDerivativeCoefficients" can be used to interpolate the derivative of a function over a region:
uExact[x_] := Cos[x] + 1
vd = NDSolve`VariableData[{"DependentVariables", "Space"} -> {{u}, {x}}];
sd = NDSolve`SolutionData["Space" -> ToNumericalRegion[Line[{{0}, {π}}]]];
ipde = InitializePDECoefficients[vd, sd, "ReactionCoefficients" -> {{-1}},
"LoadDerivativeCoefficients" -> {{{uExact[x]}}}];
ibcd = InitializeBoundaryConditions[vd, sd, {{DirichletCondition[u[x] == (D[uExact[x], x] /. x -> 0), x == 0], DirichletCondition[u[x] == (D[uExact[x], x] /. x -> π), x == π]}}];
md = InitializePDEMethodData[vd, sd];
dpde = DiscretizePDE[ipde, md, sd];
dbcd = DiscretizeBoundaryConditions[ibcd, md, sd, "Stationary"];
{s, l} = {dpde["StiffnessMatrix"], dpde["LoadVector"]};
DeployBoundaryConditions[{l, s}, dbcd];
sol = LinearSolve[s, l];
if = ElementMeshInterpolation[{md["ElementMesh"]}, sol]Visualize the difference between the numerical approximation and the exact derivative:
Plot[Evaluate[{if[x] - Div[{uExact[x]}, {x}]}], {x, 0, π}, PlotRange -> All]Properties & Relations (2)
Options given to InitializePDECoefficients can be given to NDSolve by specifying "InitializePDECoefficientOptions":
NDSolve[{Laplacian[u[x, y], {x, y}] == 1 / (x + 1 / 2 + y + 1 / 2), DirichletCondition[u[x, y] == 0, True]}, u, {x, y}∈Disk[]]Specify "VerificationData" to pass a coordinate that is not at a singularity:
NDSolve[{Laplacian[u[x, y], {x, y}] == 1 / (x + 1 / 2 + y + 1 / 2), DirichletCondition[u[x, y] == 0, True]}, u, {x, y}∈Disk[], Method -> {"FiniteElement", "InitializePDECoefficientsOptions" -> {"VerificationData" -> {"Coordinate" -> {0, 0}}}}]Convert a Poisson equation
into coefficients:
pdec = InitializePDECoefficients[vd, sd, "DiffusionCoefficients" -> {{-IdentityMatrix[2]}}, "LoadCoefficients" -> {{1}}]Use GetInactivePDE to create an inactive version of the input:
GetInactivePDE[pdec, vd]Possible Issues (1)
Typically, NDSolve will detect if coefficients do not evaluate to numeric quantities with the correct dimensions and warn about that:
NDSolveValue[{D[u[t, x], {t, 1}] - D[u[t, x], {x, 2}] == k Sin[x], u[0, x] == 0, DirichletCondition[u[t, x] == 0, True]}, u, {t, 0, π}, {x, -π, π}, Method -> {"PDEDiscretization" -> {"MethodOfLines"}}]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:
NDSolveValue[{D[u[t, x], {t, 1}] - D[u[t, x], {x, 2}] == Cos[t] Sin[x] + k Sin[t] Sin[x], u[0, x] == 0, DirichletCondition[u[t, x] == 0, True]}, u, {t, 0, π}, {x, -π, π}, Method -> {"PDEDiscretization" -> {"MethodOfLines"}}]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:
(Cos[t] * Sin[x] + k * Sin[t] * Sin[x]) /. {t -> 0., x -> -π}相关指南
文本
Wolfram Research (2014),InitializePDECoefficients,Wolfram 语言函数,https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html (更新于 2020 年).
CMS
Wolfram 语言. 2014. "InitializePDECoefficients." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2020. https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html.
APA
Wolfram 语言. (2014). InitializePDECoefficients. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html 年
BibTeX
@misc{reference.wolfram_2026_initializepdecoefficients, author="Wolfram Research", title="{InitializePDECoefficients}", year="2020", howpublished="\url{https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html}", note=[Accessed: 09-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_initializepdecoefficients, organization={Wolfram Research}, title={InitializePDECoefficients}, year={2020}, url={https://reference.wolfram.com/language/FEMDocumentation/ref/InitializePDECoefficients.html}, note=[Accessed: 09-August-2026]}