I am using Mathematica 8.

I have two ODEs (in time) and a diffusion PDE (in radius and time) which are all coupled to each other. I solve them using NDSolve by adding a degenerate space dimension to the ODE functions. Let the space dimension be $[a, b]$. As boundary conditions for the diffusion PDE I take a value determined by one of the ODEs at $a$ and a constant 1 at $b$. Initially, I assume a constant 1 besides at $a$, where the value is given by the ODE-function's initial value.

Mathematica can solve the equations, but for some parameter sets, the concentration becomes negative - which should not happen. I want to try to increase the numerical precision of the calculation by

  • StartingStepSize -> small
  • MaxSteps -> high
  • MaxStepSize -> small
  • AccuracyGoal -> high

eventually also by increasing WorkingPrecision if necessary. The problem is that this would drastically increase calculation time and when I tried it, Mathematica crashed. At the same time, all this precision is needed for only about 20% of the spatial interval (which I want to keep large in order to minimise side effects from the box).

Therefore, my question is:

Is it possible in NDSolve to specify different values for above-mentioned options for different parts of the solution interval?


As was pointed out to me in the comments, not all the options I mentioned are relevant for the spatial acccuracy. I therefore want to reformulate my question.

I see numerical errors over the first ~20% of the spatial interval and would like to increase precision there. Which of the above-mentioned options actually do apply to the spatial discretisation and how can I selectively increase them for the critical interval?


closed as unclear what you're asking by MarcoB, user9660, Jens, Öskå, PlatoManiac Jun 6 '16 at 20:04

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ StartingStepSize , MaxSteps and MaxStepSize are options to change the temporal steps. But you write that you need precision for only 20% of the spatial interval, that is to say you want to control the spatial "steps" (= "points"). Which one do you want to control ? Both ? $\endgroup$ – andre314 May 30 '16 at 21:42
  • $\begingroup$ Thank you for the answer. I naively assumed that those options would, in the case of PDEs, also apply to the spatial direction. I would not mind increasing the temporal precision just in case, but my feeling is that the problem lies in too rough a spatial discretisation. I will edit my post. $\endgroup$ – Sanya May 31 '16 at 9:20
  • 1
    $\begingroup$ According to Albert Retey comment here, if you want to couple a ODE and a PDE you have to discretize the space and to rewrite the PDE as a set of ODEs "manually" (more precisaly with the tools described in tutorial/NDSolvePDE in the documentation). Have you already done this ? $\endgroup$ – andre314 May 31 '16 at 15:25
  • $\begingroup$ This is a good and interesting idea, which would at least help me in choosing the space discretisation steps myself. I will try that out as soon as my present calculation (which has been running for the last ~20h) finishes. What I have done is to follow the idea outlined in the answer of this thread: really just turned the functions from the ODE into functions also depending on space. $\endgroup$ – Sanya May 31 '16 at 15:57