x=\delta Is the equation for my rope equation solver???

Hey guys,

Quick question- Could anyone recommend some useful libraries for implementing the wave equation solver in python? Especially for manipulating equations and animating graphs?

I can implement the solver in Mathematica, but I am still relatively new at python and would appreciate any pointers at where to start,

Thanks!

Holly

If you want to have some user-directed manipulation, you can look at the widgets functionality in jupyter/ipython:

https://ipywidgets.readthedocs.io/en/stable/

Is that the kind of tool you were looking for? If you just want to animate some figures you can use matplotlibâ€™s built-in animation functionality:

https://matplotlib.org/stable/gallery/animation/double_pendulum.html

Click around on that site for some other examples, too, theyâ€™ve got some nice ones! (@pablo you might like this: The Bayes update â€” Matplotlib 3.7.1 documentation , at some point weâ€™ll do something similar for BMEX)

Iâ€™ve had pretty good success in the past with matplotlibs animation and normal pyplot libraries before.

Here is a small plotting script I used to plot an N-Body simulation before in 3D. It can be a little finicky depending on your device in my experience (for some reason it only wanted to make gifs even when I tried to have something else). There are certainly more interactive ways to do it as mentioned with Jupyter lab widgets, but thereâ€™s just something wrong with my installation of Jupyter to where the IPython dependency just doesnâ€™t want to workâ€¦

```
#now do the 3D video plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
def updatePlot(frame):
#If you want to follow sets of particles and update the scales, comment out the set_lim lines
ax.clear()
ax.set_xlabel('x (km)')
ax.set_ylabel('y (km)')
ax.set_zlabel('z (km)')
ax.set_title(f'N-Body Simulation (N={len(mArr)})')
ax.set_xlim(-2e1,2e1)
ax.set_ylim(-2e1,2e1)
ax.set_zlim(-2e1,2e1)
# Plot the positions of each body at the current frame
for i in range(nBodies): #this shows the particles
ax.scatter(x[i, frame]/kmCon, y[i, frame]/kmCon, z[i, frame]/kmCon, marker='o')
for i in range(nBodies): #this plots the line
ax.plot(x[i, :frame+1]/kmCon, y[i, :frame+1]/kmCon, z[i, :frame+1]/kmCon)
return ax
ani = FuncAnimation(fig, updatePlot, frames=np.size(tVals)+1, interval=10)
ani.save('nbody20.gif') #writer='Pillow') here
```

Hey @hmatt!

You can take a look here:

http://rbm.ascsn.net/HO_Time/HO_Time_Dependent.html

It is not the best commented code, but in the function â€śMovie_Makerâ€ť I lay out how to make movies:

If you download the notebook, run it locally, and uncomment the command below you should be able to make an animation and the adapt to your own rope problem.

Hope this helps!

Pablo

Awesome! Iâ€™ll take a look, thanks!

Got it! Thanks for everyoneâ€™s help!

Very nice! Did you end up using the widgets?

AWESOME!!! Love this very nice rope . What happens if you include more terms in the expansion (more normal modes)?

Excellent work Holly!

Pablo

So I was rewriting my rope solver to be a little more general by just integrating by hand to find things like the aiâ€™s and normalization constant, and I seem to be a little confused. When we were originally deriving the rope equation, we had a B with a tilda in the expression. Is this supposed to be our normalization constant? When we do <\phi_i | \phi_i>=1 are we finding what value B would have to be to make that true? In that case are we then just multiplying each ai (in effect the entire \phi(x, t) expression) by that value? I ask mainly because it seems the strangest thing about my solution is that the scale is completely off in weird ways right now

Never mind, I think I figured it out, or at the very least I have something!

BRAVO GABE!!

Sorry for not answering before to your previous post, we are running with the final details for the summer school. We can chat tomorrow if something is still confusing about it, but it seems your rope is moving in a very healthy way, super congrats!!

Finally had some time to work on the problem and thankfully my python skills are still functioning properly. (I didnâ€™t normalize the function since the movement of the rope is the same either way.)