Zonder jouw inzicht op de as limieten (de roots) hadden we via Newton-Rapson al veel minder Mikado oplossingen. Op dit moment ben ik nog geen Mikado oplossing gezien met berekende limieten dus niet door itteratie.
Zware massa lichtstraal op \(r_{zon}\): Zware massa kleine radius (zon als referentie): Limiet massa kleine radius (zon als referentie): Via mybinder:
https://mybinder.org/v2/gh/oooVincentoo ... ptic.ipynb
Python Console (hoop dat deze werkt bij jouw):
Code: Selecteer alles
#Version 17.0 Schwarzschild, Jacobi Elliptic
#https://sciencetalk.nl/forum/viewtopic.php?f=85&t=212427
#Open pyplot in separate interactive window
from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt5')
import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sps
from scipy import optimize
from matplotlib.widgets import Slider, CheckButtons
fig= plt.figure(figsize=(15, 6))
ax1 = plt.subplot2grid((3, 3), (0, 0),rowspan=2)
ax2 = plt.subplot2grid((3, 3), (0, 1),rowspan=2)
ax3 = plt.subplot2grid((3, 3), (0, 2),rowspan=2)
ax4 = plt.subplot2grid((3, 3), (2, 0),colspan=3)
ax4.axis('off')
plt.suptitle('Schwarzschild, Jacobi Elliptic', fontsize=22)
# Draw slider alpha
axcolor = 'lightgoldenrodyellow'
axalpha = plt.axes([0.25, 0.05,0.4, 0.04], facecolor=axcolor)
s_zoom = Slider(axalpha, 'zoom: ', 0, 1, valinit=1)
axsm = plt.axes([0.25, 0.1,0.4, 0.04], facecolor=axcolor)
s_sm = Slider(axsm, 'solar masses: ', 1,100000, valinit=1)
radius = plt.axes([0.25, 0.15,0.4, 0.04], facecolor=axcolor)
s_sr = Slider(radius, 'radius: ', 0.1, 5, valinit=1)
rax = plt.axes([0.75, 0.05, 0.15, 0.15])
check = CheckButtons(rax, ('xy equal', 'sun'), (False, False))
#Set constants note G is divided by c^2
global M
global G
global Ro
M=1.989e30
G=6.67408e-11/((3e8)**2)
Ro=696340000
def e1(sm,sr):
esqrt=np.sqrt((sr*Ro-sm*2*M*G)*(sr*Ro+sm*6*M*G))
e1=(sr*Ro-sm*2*M*G+esqrt)/(sm*4*M*G*sr*Ro)
return e1
def e2(sr):
e2=1/(sr*Ro)
return e2
def e3(sm,sr):
esqrt=np.sqrt((sr*Ro-sm*2*M*G)*(sr*Ro+sm*6*M*G))
e3=(sr*Ro-sm*2*M*G-esqrt)/(sm*4*M*G*sr*Ro)
return e3
def r(phi):
sm = s_sm.val
sr = s_sr.val
e1v=e1(sm,sr)
e2v=e2(sr)
e3v=e3(sm,sr)
tau=np.sqrt(sm*M*G*(e1v-e3v)/2)
h = (e2v-e3v)/(e1v-e3v)
sigma = -tau*np.pi/2 - sps.ellipk(h)
sn,_,_,_=sps.ellipj(tau*phi+sigma, h)
r=e3v+(e2v-e3v)*sn**2
return r
def alpha():
#Determine the root of solution
sm = s_sm.val
sr = s_sr.val
e1v=e1(sm,sr)
e2v=e2(sr)
e3v=e3(sm,sr)
h = (e2v-e3v)/(e1v-e3v)
phi=np.arcsin(np.sqrt(-e3v/(e2v-e3v)))
angle= sps.ellipkinc(phi, h)
tau=np.sqrt(sm*M*G*(e1v-e3v)/2)
sigma = -tau*np.pi/2 - sps.ellipk(h)
alphav = (angle-sigma) /tau-2*np.pi
return alphav
#The following function updateplot runs whenever slider changes value
def updateplot(val):
clearsetplot()
#Solar masses/radius and magnification alpha
zoom = s_zoom.val
sm = s_sm.val
sr = s_sr.val
#Find root angle for non-solutions
alphamax=alpha()
print('Direct:' + str(alphamax))
#Set angle range and calculate radius
phi= np.linspace(alphamax/2,np.pi-alphamax/2,500)
phi=phi[int(0.5*(1-zoom)*500):int(0.5*(1+zoom)*500)]
rv=1/r(phi)
x=rv*np.cos(phi)
y=rv*np.sin(phi)
#plot lightpath curve
ax1.plot(x,y)
ax1.grid()
#Angular Deflection
dx=np.diff(x)
dy=np.diff(y)
dydx=dy/dx
da=np.arctan(dydx)
dam=np.max(da)
ax2.plot(x[:-1],-da)
ax2.grid()
#Angular Distribution
ddy=np.diff(da)
ddydx=ddy/dx[:-1]
ax3.plot(x[:-2],-ddydx)
ax3.grid()
text=( str('{:10.6f}'.format(dam)) + ' $[rad]$\n' +
str('{:10.6f}'.format(np.degrees(dam))) + '$^{\circ}$\n' +
str('{:10.6f}'.format(np.degrees(dam)*3600)) + "$''$")
ax1.text(0.01, 0.75,text, transform=ax1.transAxes, fontsize=10)
#scaling method and draw sun
plotoptions(x,y,sr)
fig.canvas.draw_idle()
#This function set scaling axis and drawes sun
def plotoptions(x,y,sr):
i=0
for r in check.get_status():
if i==0:
#Set scaling auto or equal
if r==False:
ax1.axis('auto')
range=np.max(y)-np.min(y)
ax1.set_ylim([np.min(y)-range*2/100,np.max(y)+range*2/100])
range=np.max(x)-np.min(x)
ax1.set_xlim([np.min(x)-range*2/100,np.max(x)]+range*2/100)
ax2.set_xlim([np.min(x)-range*2/100,np.max(x)]+range*2/100)
ax3.set_xlim([np.min(x)-range*2/100,np.max(x)]+range*2/100)
else:
ax1.axis('equal')
range=np.max(x)-np.min(x)
ax1.set_xlim([np.min(x)-range*2/100,np.max(x)+range*2/100])
ax2.set_xlim([np.min(x)-range*2/100,np.max(x)+range*2/100])
ax3.set_xlim([np.min(x)-range*2/100,np.max(x)+range*2/100])
if i==1:
#Draw Sun yes/no
if r==True:
circle=plt.Circle((0,np.max(y)-sr*Ro),Ro, color='orange',label='Label')
ax1.add_patch(circle)
circle=plt.Circle((0,np.max(y)-sr*Ro),sr*Ro,fill=False, ls='--',ec='black')
ax1.add_patch(circle)
i=i+1
def clearsetplot():
ax1.clear()
ax1.set_title('Light path', fontsize=14)
ax1.set_xlabel('x [m]', fontsize=14)
ax1.set_ylabel('y [m]', fontsize=14)
ax1.ticklabel_format(axis='both', style='sci', scilimits=(0,0))
ax2.clear()
ax2.set_title('Angular Deflection', fontsize=14)
ax2.set_xlabel('x [m]', fontsize=14)
ax2.set_ylabel('deflection angle [rad]', fontsize=14)
ax2.ticklabel_format(axis='both', style='sci', scilimits=(0,0))
ax3.clear()
ax3.set_title('Angular Disribution', fontsize=14)
ax3.set_xlabel('x [m]', fontsize=14)
ax3.set_ylabel('angular Change [rad/m]', fontsize=14)
ax3.ticklabel_format(axis='both', style='sci', scilimits=(0,0))
#Display plot n startup.
updateplot(1)
#The following code checkes if slider changes. This line is looped automatic by pyplot
s_sm.on_changed(updateplot);
s_sr.on_changed(updateplot);
s_zoom.on_changed(updateplot);
check.on_clicked(updateplot);