Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have some code that solves an ugly PDE by using the results of another, and outputs the value of the solution between a range $mic \leq r \leq r_{o}$. It looks something like this

(*Constants for these PDEs*)
a = 7.5*10^-7; omega = 3.0138*10^7; Do2 = 2*10^-9; po = 100;
ro = 300*10^-6; k = 1; eo = 100; qm = 10^-4; mic = 1*10^-6; De = 5.5*10^-11;

(*First solver*)
s = Quiet[
   NDSolve[{D[Ox[r, t], t] - 
       Do2*(D[Ox[r, t], r, r] + (2/r)*(D[Ox[r, t], r])) + (a*
      omega)*((Ox[r, t])/(Ox[r, t] + k)) == 0, Ox[r, 0] == 0, 
 Ox[micron, t] == 0, Ox[ro, t] == po}, 
Ox, {r, mic, ro}, {t, 0, 14400}]];

p = Ox /. First[s];

(*More constants (These are ones we want to parameter sweep)*)
kme = 0.1; kmn = 0; j = 0.02;

(*Output PDE solution set*)
G = Table[
    Eb1[r, 14400] /. 
     NDSolve[{D[Eb1[r, t], t] - 
         qm*((kme)/(kme + 
                p[r, t])*((p[r, t])/(p[r, t] + 
                 kmn)) + (1 - (p[r, t])/(p[r, t] + kmn))*j)*
            Ef1[r, t] /. 
         NDSolve[{D[Ef1[r, t], t] - 
             De*(D[Ef1[r, t], r, r] + (2/r)*(D[Ef1[r, t], r])) + 
             qm*((kme)/(kme + 
                p[r, t])*((p[r, t])/(p[r, t] + 
                kmn)) + (1 - (p[r, t])/(p[r, t] + kmn))*j)*
              Ef1[r, t] == 0, Ef1[r, 0] == 0, Ef1[mic, t] == 0,
            Ef1[ro, t] == eo}, 
          Ef1, {r, mic, ro}, {t, 0, 14400}]]] == 0, 
   Eb1[r, 0] == 0}, Eb1, {r, mic, ro}, {t, 0, 14400}]], {r, 
mic, ro, mic}];
Export["testplot.xls", G];

This works well for individual solution sets, but what I really want are the solution sets as $kme$, $kmn$ and $j$ vary; specifically, I want these parameters to vary between the limits of

{kme,0.1,15,0.1} , {kmn,0,15,0.1}, {j,0,1,0.01}

I've tried not declaring $kme,kmn,j$ and then adding the above terms to the table output, but this yields an errors with NDSolve. I tried combatting this using ParametricNDSolve and got errors about too many parameters. I was wondering if there's a more elegant solution, or should I use loops to output to individual files, and how would I go about this? This question has stumped me for two days, and there's simply too many values (150 x 151 x 101 = 2287650 solution sets!)to increment this manually.

If anyone has a good solution to this, I'd be very, very grateful if they would outline it. The exported format does not have to be excel; it simply has to be in a file format which I can easily import into MATLAB. Thanks in advance. Apologies if there's an obvious solution I'm missing - I'm self-taught and tend to miss the more elegant approaches!

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.