Message Boards Message Boards

GROUPS:

What went wrong with this NDSolve command usage?

Posted 7 years ago
8255 Views
|
2 Replies
|
0 Total Likes
|

Dear All,

I got error message when trying to solve an equation by using NDSolve command. This is my equation:

  sol = NDSolve[{q'[t] == (a q[t]^b newefrainfunc[t] - q[t]) + (a q[t]^b sigmaer1[t]), q[1] == q0}, q, {t, 1, 456}]

where: a, b, and q0 are given constant values; newefrainfunc[t_] = newefrain, where newefrain=Table[rainfun[t]ff, {t, 1, 456}]; sigmaer1[t_]=newefrain - newefrain1, where newefrain1=Table[rainfun[t]ff1, {t, 1, 456}]

But when I run the script, I got an error message as follows:

NDSolve::ndfdmc: Computed derivatives do not have dimensionality consistent with the initial conditions. >>

NDSolve[{Derivative[1][q][t] == {0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 11.3171 q[t]^0.006286 - q[t], 
    3.77239 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 113.219 q[t]^0.006286 - q[t], 
    151.199 q[t]^0.006286 - q[t], 18.9052 q[t]^0.006286 - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 11.3451 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 343.199 q[t]^0.006286 - q[t], 
    84.137 q[t]^0.006286 - q[t], 0. - q[t], 
    3.82495 q[t]^0.006286 - q[t], 65.1857 q[t]^0.006286 - q[t], 
    0. - q[t], 7.67124 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 57.671 q[t]^0.006286 - q[t], 
    50.0905 q[t]^0.006286 - q[t], 116.225 q[t]^0.006286 - q[t], 
    58.2834 q[t]^0.006286 - q[t], 42.8373 q[t]^0.006286 - q[t], 
    42.9368 q[t]^0.006286 - q[t], 39.1184 q[t]^0.006286 - q[t], 
    138.025 q[t]^0.006286 - q[t], 47.4618 q[t]^0.006286 - q[t], 
    0. - q[t], 7.91423 q[t]^0.006286 - q[t], 0. - q[t], 
    23.7784 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 31.7692 q[t]^0.006286 - q[t], 
    75.8284 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    19.9816 q[t]^0.006286 - q[t], 108.711 q[t]^0.006286 - q[t], 
    646.845 q[t]^0.006286 - q[t], 873.149 q[t]^0.006286 - q[t], 
    819.296 q[t]^0.006286 - q[t], 408.903 q[t]^0.006286 - q[t], 
    148.225 q[t]^0.006286 - q[t], 61.6501 q[t]^0.006286 - q[t], 
    51.5953 q[t]^0.006286 - q[t], 10.3279 q[t]^0.006286 - q[t], 
    20.6911 q[t]^0.006286 - q[t], 10.3544 q[t]^0.006286 - q[t], 
    31.143 q[t]^0.006286 - q[t], 0. - q[t], 
    20.7976 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 5.20161 q[t]^0.006286 - q[t], 
    5.20383 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    26.0748 q[t]^0.006286 - q[t], 26.1305 q[t]^0.006286 - q[t], 
    10.4611 q[t]^0.006286 - q[t], 36.7236 q[t]^0.006286 - q[t], 
    36.8334 q[t]^0.006286 - q[t], 31.6523 q[t]^0.006286 - q[t], 
    5.27764 q[t]^0.006286 - q[t], 15.8532 q[t]^0.006286 - q[t], 
    10.5778 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 15.887 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 
    10.6003 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 10.6094 q[t]^0.006286 - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    15.9344 q[t]^0.006286 - q[t], 53.341 q[t]^0.006286 - q[t], 
    69.7271 q[t]^0.006286 - q[t], 32.2638 q[t]^0.006286 - q[t], 
    5.37957 q[t]^0.006286 - q[t], 0. - q[t], 
    21.5548 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 280.801 q[t]^0.006286 - q[t], 
    55.2904 q[t]^0.006286 - q[t], 0. - q[t], 
    270.758 q[t]^0.006286 - q[t], 412.347 q[t]^0.006286 - q[t], 
    34.9313 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 11.6532 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    11.6627 q[t]^0.006286 - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 5.83369 q[t]^0.006286 - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 11.6768 q[t]^0.006286 - q[t], 
    17.5365 q[t]^0.006286 - q[t], 153.584 q[t]^0.006286 - q[t], 
    59.3078 q[t]^0.006286 - q[t], 29.7132 q[t]^0.006286 - q[t], 
    0. - q[t], 5.94502 q[t]^0.006286 - q[t], 
    47.712 q[t]^0.006286 - q[t], 29.8794 q[t]^0.006286 - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 0. - q[t], 
    0. - q[t]}, q[1] == 1}, q, {t, 1, 456}]

So may I know what possibly went wrong with my equation? Thanks in advance for your help!

Best Regards, Intan

2 Replies

Hi,

The problem is that you trying to use lists as functions. Make functions from your list with Interpolation[]. Here is a simple example:

Plot[#, {s, 0, 10.}] &@ NDSolveValue[{q'[s] == Sin[s] q[s], q[0] == 1}, q[s], {s, 0, 10.}]
sin = Interpolation[Table[{s, Sin[s]}, {s, 0., 10., 0.1}]];
Plot[#, {s, 0, 10.}] &@  NDSolveValue[{q'[s] == sin[s] q[s], q[0] == 1}, q[s], {s, 0, 10.}]

I.M.

Dear Ivan,

Thanks for your response. I really appreciate it. Yes, you are right. It has something to do with the usage of lists. So I changed my equation into:

sol = NDSolve[{q'[t] == (a q[t]^b newefr[t] - q[t]) + (a q[t]^b (newefr[t] - newefr1[t])), q[1] == 0.001}, q, {t, 1, 456}]

where:

newefr = Interpolation[newefrain, InterpolationOrder -> 1]; where: newefrain = Table[rainfun[t]*ff, {t, 1, 456}]

similarly to newefr1:

newefr1 = Interpolation[newefrain1, InterpolationOrder -> 1]; where: newefrain1 = Table[rainfun[t]*ff1, {t, 1, 456}]

And it works! Thanks for your help!

Best Regards, Intan

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract