Parametric Sensitivity of the Wave Equation
Parametric Sensitivity of the Wave Equation
pfun = ParametricNDSolveValue[{D[u[t, x], t, t] == c ^ 2 D[u[t, x], x, x], u[0, x] == Exp[-(a x) ^ 2], Derivative[1, 0][u][0, x] == 0, u[t, -10] == u[t, 10]}, u, {t, 0, 5}, {x, -10, 10}, {a, c}];
ifun = pfun[1, 1];
ifda = D[pfun[a, 1], a] /. {a -> 1};
ifdc = D[pfun[1, c], c] /. {c -> 1};Grid[Join[{{"", "a", "c"}}, Table[{StringJoin["t = ", ToString[τ]], Plot[Evaluate[(pfun[a, c][τ, x] + .5{0, 1, -1}D[pfun[a, c][τ, x], a]) /. {a -> 1, c -> 1}], {x, -10, 10}, Filling -> {2 -> {3}}, PlotRange -> All], Plot[Evaluate[(pfun[a, c][τ, x] + .5{0, 1, -1}D[pfun[a, c][τ, x], c]) /. {a -> 1, c -> 1}], {x, -10, 10}, Filling -> {2 -> {3}}, PlotRange -> All]}, {τ, {1, 3, 5}}]]]ColorSensitivityPlot3D[f_, fsense_, opts___] :=
Block[{fs = fsense}, Plot3D[f, {t, 0, 5}, {x, -10, 10}, Mesh -> None, ColorFunction -> Function[{t, x}, ColorData["LakeColors"][fs]], PlotPoints -> 60, ColorFunctionScaling -> False, opts]];
{ColorSensitivityPlot3D[pfun[1, 1][t, x], Abs[ifda[t, x]], PlotLabel -> a, PlotRange -> All], ColorSensitivityPlot3D[pfun[1, 1][t, x], .25Abs[ifdc[t, x]], PlotLabel -> c, PlotRange -> All]}