0
$\begingroup$

I wish to incorporate ODE solution with Bondary condition sets:

smax=Pi; (*Full superset not displayed on slider *) superset={{.2,3},{.3,4},{.5,6}}; Manipulate[Module[{SI,PH,R,TH,Z,MER,si,ph,r,th,z,mer,b,smax},{b,smax}=subset; {si[t_],ph[t_],r[t_],th[t_],z[t_],mer[t_]}={SI[t],PH[t],R[t],TH[t],Z[t],MER[t]}/.First@NDSolve[{SI'[s]==1/b+Sin[PH[s]] Sin[SI[s]]/R[s],SI[0]==0,PH'[s] ==R[s]Sin[SI[s]],PH[0]==0.,R'[s]==Sin[PH[s]]Cos[SI[s]],Z'[s]==Cos[PH[s]]Cos[SI[s]],TH'[s]==Sin[SI[s]]/R[s],R[0]==1,Z[0]==0.,TH[0]==0,MER'[s]==Cos[SI[s]],MER[0]==0.},{SI,PH,R,TH,Z,MER},{s,0,smax}]; Plot[z[s],{s,0,smax},GridLines->Automatic,PlotStyle->{Thick,Red}]],{subset,superset}] 

Something is missing in Syntax. Superset / individual subset values are not seen on slider. Please help.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

You can either specify the control type as Setter:

smax = Pi; superset = {{.2, 3}, {.3, 4}, {.5, 6}}; Manipulate[Module[{SI, PH, R, TH, Z, MER, si, ph, r, th, z, mer, b, smax}, {b, smax} = subset; {si[t_], ph[t_], r[t_], th[t_], z[t_], mer[t_]} = {SI[t], PH[t], R[t], TH[t], Z[t], MER[t]} /. Quiet@First@ NDSolve[{SI'[s] == 1/b + Sin[PH[s]] Sin[SI[s]]/R[s], SI[0] == 0, PH'[s] == R[s] Sin[SI[s]], PH[0] == 0., R'[s] == Sin[PH[s]] Cos[SI[s]], Z'[s] == Cos[PH[s]] Cos[SI[s]], TH'[s] == Sin[SI[s]]/R[s], R[0] == 1, Z[0] == 0., TH[0] == 0, MER'[s] == Cos[SI[s]], MER[0] == 0.}, {SI, PH, R, TH, Z, MER}, {s, 0, smax}]; Plot[z[s], {s, 0, smax}, GridLines -> Automatic, PlotStyle -> {Thick, Red}]], {subset, superset, Setter}] 

enter image description here

or use the part index for superset as the control:

Manipulate[Module[{SI, PH, R, TH, Z, MER, si, ph, r, th, z, mer, b, smax}, {b, smax} = superset[[k]]; {si[t_], ph[t_], r[t_], th[t_], z[t_], mer[t_]} = {SI[t], PH[t], R[t], TH[t], Z[t], MER[t]} /. Quiet@First@NDSolve[{SI'[s] == 1/b + Sin[PH[s]] Sin[SI[s]]/R[s], SI[0] == 0, PH'[s] == R[s] Sin[SI[s]], PH[0] == 0., R'[s] == Sin[PH[s]] Cos[SI[s]], Z'[s] == Cos[PH[s]] Cos[SI[s]], TH'[s] == Sin[SI[s]]/R[s], R[0] == 1, Z[0] == 0., TH[0] == 0, MER'[s] == Cos[SI[s]], MER[0] == 0.}, {SI, PH, R, TH, Z, MER}, {s, 0, smax}]; Plot[z[s], {s, 0, smax}, GridLines -> Automatic, PlotStyle -> {Thick, Red}]], {k, 1, Length@superset, 1}] 

enter image description here

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.