0
|
2760 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
# NDSolveIterate in a table
 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@ NDSolveProcessEquations[{(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@NDSolveReinitialize[ 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 NDSolveIterate[#, -1.6*10^-12] & /@ state2  This gives the error The first argument NDSolveStateData[{5,256,{NDSolveReinitialize,None}},{TimeIntegration:>Automatic,BoundaryValues:>Automatic,DiscontinuityProcessing:>Automatic,EquationSimplification:>Automatic,IndexReduction:>None,DAEInitialization:>Automatic,PDEDiscretization:>Automatic,ParametricCaching:>Automatic,ParametricSensitivity:>Automatic},<<6>>,{},{}] to NDSolveIterate should be a symbol assigned to a value that is a valid NDSolveStateData 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: NDSolveIterate[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]] NDSolveIterate[st, -1.6*10^-12]  Any ideas?