0
$\begingroup$
k1 = 1;
k2 = 5;
t0 = 0;
ts = 10000000;
t01 = ts - ts/3;
t02 = 7000;
tfnh = 500;
t0nh01 = tfnh/3;
tf = ts;
bv2 = 0;
bb2 = 0;

fh = 0.99;
b10 = 1.0
h10 = fh*b10*(k2/k1)

h20 = 0
Rm2 = 12000;

soln2dec = 
 NDSolve[{
   h1'[t] == (2/3)*h2[t]*b1[t] - (2/3) (k1/k2)^2*h1[t] - 2*h1[t] (k1/k2)^2/Rm2, 
   h2'[t] == -(2/3)*h2[t]*b1[t] + (2/3) (k1/k2)^2*h1[t] - 2*h2[t]/Rm2,
   b1'[t] == (2/3) h1[t]*h2[t] (k1/k2)^2 - (2/3)*
     b1[t] (k1/k2)^2 - (2/Rm2) b1[t] (k1/k2)^2, h1[0] == h10, 
   b1[0] == b10, h2[0] == h20}, {h1, h2, b1, h1', h2', b1'}, {t, t0, ts}, 
 MaxSteps -> 15000000]

Export["logb1k5Rm12000.dat", Evaluate[{b1[t]} /. soln2dec], "TSV"]

Export["logh2k5Rm12000.dat", Evaluate[{h2[t]} /. soln2dec], "TSV"]

Export["logh1k5Rm12000.dat", Evaluate[{h1[t]} /. soln2dec], "TSV"]

Export["logh1dk5Rm12000.dat", Evaluate[{h1'[t]} /. soln2dec], "TSV"]

Export["logh2dk5Rm12000.dat", Evaluate[{h2'[t]} /. soln2dec], "TSV"]

Export["logb1dk5Rm12000.dat", Evaluate[{b1'[t]} /. soln2dec], "TSV"]

The first three exports rightly retrieve the data. But the last three seem to retrieve the function itself and not the derivatives.

Is there a way out ?

$\endgroup$
1
  • $\begingroup$ Calling Export["logb1k5Rm12000.dat", Evaluate[{b1[t]} /. soln2dec], "TSV"] won't give you what you expect... did you checked it? $\endgroup$
    – mmal
    Aug 8, 2013 at 14:35

1 Answer 1

2
$\begingroup$

First, after running your code, I ran

Plot[Evaluate[{h1[t] /. soln2dec[[1, 1]], h1'[t] /. soln2dec[[1, 4]]}], {t, 0, 10^7}]

Output from Mathematica

They are clearly different functions. Your problem is not at the point where soln2dec was computed.

Second, I ran

Plot[Evaluate[{(h1'[t] /. soln2dec[[1, 1]]) - (h1'[t] /. soln2dec[[1, 4]])}], {t, 0, 10^7}]

The output was was a flat line at zero. This tests shows that computing h1'[t] from the interpolated h1[t] is equivalent to use the 4-th rule in soln2dec. In fact, I would modify the third parameter you passed to NDSolve from

{h1, h2, b1, h1', h2', b1'}

to

{h1, h2, b1}

Third, I ran a comparison tool on the seemingly same files and I got enter image description here

The first few lines are almost identical, but they are definitely different functions.

$\endgroup$

Your Answer

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

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