Glowscript / vpython:如果轨道倾斜,如何使对象遵循圆形轨道。即轨道=环(...轴=矢量<-1,1,0>

时间:2018-07-31 23:33:58

标签: math 3d vpython parametric-equations glowscript

我能够创建电子(球体)围绕L2(环)和L3(环)的轨道(环)运动,因为它们是轴为<0,0,1>和<0,0的环,1>。但是,对于我的轴<-1,1,0>的倾斜轨道,不可能使电子跟随该环。似乎它们在x和y方向上偏离了。我尝试使用3D参数方程式,但它不起作用。请帮忙!

Electrons on L1 won't follow circular ring, instead form ellipse. The blue and green trails are the electrons I am talking about

下面是我的代码 我将在重要功能周围放置空格:

GlowScript 2.7 VPython
## Scene 
scene = display(title='The Photoelectric Process', width=800, height=600,center=vector(0,0,0), background = color.white)
## Nucleus
Nucleus = sphere(pos = vector(0,-0.5,0), radius=1.5, color = color.red, opacity=0.7)
## Incident Electron
e_i = sphere(pos = vector(-10,20,0), radius = 0.25, color = color.green, make_Trail = True)
## 1s Electrons (2e, K)
e_0 = sphere(pos = vector(2*cos((3*pi)/4),2*sin((3*pi)/4),0), radius = 0.25, color = color.green, make_trail = True) #secondary electron
e_1 = sphere(pos = vector(-2*cos((3*pi)/4),-2*sin((3*pi)/4),0), radius = 0.25, color = color.green)




## 2s Electrons (2e, L1)
e_2 = sphere(pos = vector(4*cos(pi/4),4*sin(pi/4),0), radius = 0.25, color = color.blue, make_trail = True)
e_3 = sphere(pos = vector(-4*cos(pi/4),-4*sin(pi/4),0), radius = 0.25, color = color.green, make_trail = True)



## 2p Electrons (2e, L2) 
e_4 = sphere(pos = vector(6*cos(0),6*sin(0),0), radius = 0.25, color = color.green)
e_5 = sphere(pos = vector(-6*cos(0),-6*sin(0),0), radius = 0.25, color = color.green)
## 3s Electrons (4e, L3)
# r * cos (theta) ; r * sin (theta)
e_6 = sphere(pos = vector(8*sin(pi),0,8*cos(pi)), radius =  0.25, color = color.green)
e_7 = sphere(pos = vector(-8*sin(pi),0,-8*cos(pi)), radius =  0.25, color = color.green)
e_8 = sphere(pos = vector(8*cos(0),0,8*sin(0)), radius =  0.25, color = color.green) #KLL Auger Electron
e_9 = sphere(pos = vector(-8*cos(0),0,-8*sin(0)), radius =  0.25, color = color.green) #Emitted Auger Electron
## K Shell 
s_1 = ring(pos= vector(0,0,0), axis= vector(1,1,0), radius=2, thickness=0.075, opacity=0.3)
K = text(text='K',align='center', depth=-0.3, color=color.black)
K.pos = vector (-2,1.75,0)
## L1 Shell
s_2 = ring(pos= vector(0,0,0), axis= vector(-1,1,0), radius=4, thickness=0.075, opacity=0.3)
L1 = text(text='L1',align='center', depth=-0.3, color=color.black)
L1.pos = vector (3.75,2.75,0)
## L2 Shell
p_2 = ring(pos= vector(0,0,0), axis= vector(0,0,1), radius=6, thickness=0.075, opacity=0.3)
L2 = text(text='L2',align='center', depth=-0.3, color=color.black)
L2.pos = vector (0,6.25,0)
## L3 Shell
s_3 = ring(pos= vector(0,0,0), axis= vector(0,1,0), radius=8, thickness=0.075, opacity=0.3)
L3 = text(text='L3',align='center', depth=-0.3, color=color.black)
L3.pos = vector (9.5,-0.5,0)
## Valence Band
VB = sphere(pos = vector(0,-0.5,0), radius=9, color = color.red, opacity=0.1)
V = text(text='Valence Band',align='center', depth=-0.3, color=color.orange)
V.pos = vector (0,-8,0)
## Conduction Band
CB = sphere(pos = vector(0,-0.5,0), radius=14.5, color = color.yellow, opacity=0.1)
C = text(text='Conduction Band',align='center', depth=-0.3, color=color.yellow)
C.pos = vector (0,-13.5,0)
## Animation
t = 0
dt = 0.01
while True:
    rate(10)
    t = t + dt



## L1 electron movement in orbital
# e_2 is blue
# e_3 is green
# both have trails and are in L1, I am trying to get them to move in circular motion 
# but end up with an ellipse, what is my problem?
    e_2.pos.x = e_2.pos.x + 4*sin(-t) * dt
    e_2.pos.y = e_2.pos.y + 4*sin(-t) * dt
    e_2.pos.z = e_2.pos.z + 4*cos(-t) * dt

    e_3.pos.x = e_3.pos.x + -4*sin(-t) * dt
    e_3.pos.y = e_3.pos.y + -4*sin(-t) * dt
    e_3.pos.z = e_3.pos.z + -4*cos(-t) * dt

    #### Below did not work, used parametric eq:
        #### x(t) = C_x + r * cos(t) * U_x + r * sin(t) * V_x
            #### C is center of circle, U and V are unit vectors

    #e_2.pos.x = e_2.pos.x + 2*sqrt(2)*cos(t) * dt
    #e_2.pos.y = e_2.pos.y + 2*sqrt(2)*cos(t) * dt
    #e_2.pos.z = e_2.pos.z + 32*sin(t) * dt





## L2 electron movement in orbital    
    e_4.pos.x = e_4.pos.x + 6*sin(-t) * dt
    e_4.pos.y = e_4.pos.y + 6*cos(-t) * dt    
    e_5.pos.x = e_5.pos.x + -6*sin(-t) * dt
    e_5.pos.y = e_5.pos.y + -6*cos(-t) * dt
## L3 electron movement in orbital
    e_6.pos.x = e_6.pos.x + 8*cos(t) * dt
    e_6.pos.z = e_6.pos.z + 8*sin(t) * dt    
    e_7.pos.x = e_7.pos.x + -8*cos(t) * dt
    e_7.pos.z = e_7.pos.z + -8*sin(t) * dt    
    e_8.pos.x = e_8.pos.x + 8*sin(-t) * dt
    e_8.pos.z = e_8.pos.z + 8*cos(-t) * dt   
    e_9.pos.x = e_9.pos.x + -8*sin(-t) * dt
    e_9.pos.z = e_9.pos.z + -8*cos(-t) * dt

0 个答案:

没有答案