Message Boards Message Boards

0
|
2760 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

NDSolve`Iterate in a table

Posted 10 years ago

This should be a fairly simple problem, but something isn't working. I'm solving a differential equation several hundred times, with different initial conditions each time.

First step, I process the equations. It's 3 coupled equations

 state = First@
   NDSolve`ProcessEquations[{(1.05*10^-34) kx'[
        t] == -(1.6*10^-19) Cross[
         velocity /. kx -> kx[t] /. ky -> ky[t] /. kz -> kz[t], B][[
        1]], (1.05*10^-34) ky'[
        t] == -(1.6*10^-19) Cross[
         velocity /. kx -> kx[t] /. ky -> ky[t] /. kz -> kz[t], B][[
        2]], (1.05*10^-34) kz'[
        t] == -(1.6*10^-19) Cross[
         velocity /. kx -> kx[t] /. ky -> ky[t] /. kz -> kz[t], B][[
        3]], kx[0] ==  startt[[gridIndex, 1]], 
     ky[0] ==  startt[[gridIndex, 2]], 
     kz[0] ==  startt[[gridIndex, 3]]}, {kx, ky, kz}, t]

This step works fine. Then i build a table of states with the different initial conditions:

state2 = Table[
    First@NDSolve`Reinitialize[
      state, {kx[0] ==  startt[[gridIndex, 1]], 
       ky[0] ==  startt[[gridIndex, 2]], 
       kz[0] ==  startt[[gridIndex, 3]]}], {gridIndex, 1, 
     Length[startt]}];

This also works fine. Then I try to iterate them for the required time span

NDSolve`Iterate[#, -1.6*10^-12] & /@ state2

This gives the error

The first argument NDSolve`StateData[{5,256,{NDSolve`Reinitialize,None}},{TimeIntegration:>Automatic,BoundaryValues:>Automatic,DiscontinuityProcessing:>Automatic,EquationSimplification:>Automatic,IndexReduction:>None,DAEInitialization:>Automatic,PDEDiscretization:>Automatic,ParametricCaching:>Automatic,ParametricSensitivity:>Automatic},<<6>>,{},{}] to NDSolve`Iterate should be a symbol assigned to a value that is a valid NDSolve`StateData object.

Same thing if i try to iterate with a For loop, or a table. Same thing if i try to evaluate a single state from the list:

NDSolve`Iterate[state2[[1]], -1.6*10^-12] 

gives the same error. However, if i assign a state to a new variable, then it works:

st = state2[[1]]
NDSolve`Iterate[st, -1.6*10^-12] 

Any ideas?

POSTED BY: brad ramshaw
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