I have the problem of trying to get 2D plot from a 3D plot (which used NDSolve to solve the PDE), and I need the 3D plot's x-axis and y-axis to be the axes for my 2D plot while the z-axis of it to be the time for my 2D plot. I wrote the following code:
(*Step1. Define and plot the field*)
lhs = 24
rhs = 40
beta = 0
field = 1/(1 + Exp[-x + rhs]) - 1/(1 + Exp[-x + lhs]) + 1 + beta (*our field value v.s. spatial dimension*)
Plot[field, {x, 0, 64}, PlotRange -> {{0, 64}, {-1, 2}}]
(*Step.2 Define the field potential derivative dv/dphi*)
b = 0.1
dv = (y[t, x]^2 - 1)*(y[t, x] + b) (*dv actually denotes dv/dphi*)
(*Step3. Define PDE from our E.O.M *)
pde = D[y[t, x], {t, 2}] - D[y[t, x], {x, 2}]+ dv == 0
(*Step4. Use NDSolve to solve PDE with the help of known initial condition - field value v.s. spatial coordinate at t0 *)
nsol = NDSolve[{pde, y[0, x] == field}, y[t, x], {t, 0, 10}, {x, 0, 64}]
(*Step5. plot the field in spatial dimension at different times*)
nsol2 = nsol[[1, 1, 2]]
Plot3D[nsol2, {t, 0.000, 0.001}, {x, 0, 64},
PlotRange -> {-1.5, 1.5}]
Plot3D[nsol2, {t, 0.200, 0.201}, {x, 0, 64},
PlotRange -> {-1.5, 1.5}]
Plot3D[nsol2, {t, 0.400, 0.401}, {x, 0, 64},
PlotRange -> {-1.5, 1.5}]
Plot3D[nsol2, {t, 0.600, 0.601}, {x, 0, 64},
PlotRange -> {-1.5, 1.5}]
where the horizontal axis(x-axis) denotes spatial coordinates, vertical axis(y-axis) denotes field value, inward axis(z-axis) denotes time.
What I need is to get an animation of 2D plot of y-axis versus x-axis over time, and I wrote the code to be 'Animate[Plot[nsol2, {x, 0, 64}, PlotRange -> {-1.5, 1.5}], {t, 0, 10}]' but it does not show any plot. Please let me know what could be the correct way to do this. Thank you for reading my post!
FindRoot::dfmin: The minimal damping factor of 1/10000 has been reached.
andNDSolveValue::fempsf: PDESolve could not find a solution.
What's your Mathematica version? $\endgroup$