Created
June 30, 2024 11:57
-
-
Save santiago-salas-v/499b762454ef643f543e6a327bafa13e to your computer and use it in GitHub Desktop.
15 pendula solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import linspace,array,outer,sqrt,cos,pi | |
from matplotlib import pyplot as plt | |
from seaborn import color_palette | |
n=15 | |
L=array([0.625+0.05/2*j for j in range(n)]) # m | |
omega=sqrt(9.81/L) # 1/s | |
n_range=[10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160] | |
fig,ax_list=plt.subplots(len(n_range),1,figsize=(15,10),constrained_layout=True) | |
nmin=0 | |
for i,nmax in enumerate(n_range): | |
t=linspace(nmin*2*pi/(max(omega)),nmax*2*pi/(max(omega)),5000) | |
theta_0=1/4*pi | |
accelerate=8 | |
theta=theta_0*cos(accelerate*outer(omega,t).T) | |
for j in range(n): | |
ax_list[i].plot(t,theta[:,j],label='L={:g} m'.format(L[j]),color=color_palette('viridis',n)[j]) | |
nmin=nmax | |
ax_list[i].set_ylabel(r'$\theta$') | |
ax_list[-1].set_xlabel(r'$t$ / s') | |
ax_list[-1].legend(ncols=5,loc='upper center',bbox_to_anchor=[0.5,-0.05]) | |
plt.show(block=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment