3
$\begingroup$

I am solving a 2D PDE in space and time b(r,t) and would like to find the maximum value of b in space as a function of time t.

Using the solution for maximising a 1D interpolating function from here, I tried the following minimal working example, but it doesn't work:

largerad = 10;
tmax = 80;
b0 = 0.1;

pde = {D[b[r, t], t] == D[b[r, t], r, r] - b[r, t]};
ic = {b[r, 0] == b0};
bc = {Derivative[1, 0][b][largerad, t] == 0, 
   Derivative[1, 0][b][0, t] == 0}; 

zsolv = NDSolve[{pde, ic, bc}, {b}, {r, 0, largerad}, {t, 0, tmax}, 
   MaxStepSize -> 0.01];

Nbins = 200;

mytableb = 
  Table[NMaximize[{ b[r, t] /. zsolv, 0 <= r <= rad}, r, 
    Method -> "SimulatedAnnealing"], {t, 0, tmax, tmax/Nbins}];

Does anyone have a suggestion for an alternative implementation that would give b_max(t) as a list of values?

Edit: I'm looking for a general solution, also for PDE's that are not exactly solvable using DSolve. I just gave this as a simple example.

$\endgroup$
3
  • $\begingroup$ DSolve [{pde, ic, bc}, b , {r, 0, largerad}, {t, 0, tmax} ] evaluates the exact solution {b -> Function[{r, t}, 0.1 2.71828^(-1. t)]}} which doesn't depend on r! $\endgroup$ Mar 29, 2022 at 16:54
  • $\begingroup$ Thanks! However, I'm looking for a general solution, also for PDE's that are not exactly solvable using DSolve. I just gave this as a simple example. I clarified that in an edit. $\endgroup$ Mar 31, 2022 at 13:27
  • $\begingroup$ In my comment I tried to emphasize that your example has no unique solution, that's why a numerical solution can't be found $\endgroup$ Mar 31, 2022 at 14:30

1 Answer 1

3
$\begingroup$

An easy approximation is to pick out the max values from the interpolation grid.

bval = b@"ValuesOnGrid" /. First@zsolv // Transpose;

bmax = Interpolation[
   Transpose@{Last[b@"Coordinates" /. First@zsolv], Max /@ bval}];
ListLogPlot[bmax, Joined -> True]
$\endgroup$
1
  • $\begingroup$ Thank you, this solves my problem! $\endgroup$ Apr 5, 2022 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.