using solve_bvp to solve Schrödinger equation
up vote
0
down vote
favorite
Hi I'm trying to sove the Schrödinger equation for a infinite square well with a barrior using solve_bvp but I don't understand how to do two things with solve_bvp. one is setting the range, the x axis I am trying to give it goes from -b to b but it is solving for 0 to b, I had previously tried solving with solve_ivp but I was running into the same problem. the other problem I have is how to set the boundary condition, I need to take into account the first and second derivative, but I'm a bit lost because I cannot understand the documentation very well. I was following an example found here, but it wasn't giving me the correct results so I'm trying to rewrite it. I'm also discussing the problem on another site but that one is a bit more general than what I'm trying to solve here.
this is the code that I'm trying to get to work
from scipy.integrate import solve_bvp
from pylab import *
import numpy as np
## dimentions _
## | : | | Vmax
## | ___:___ | | _
## |___| |___| _| Vmin _|- Vb
##-B -A 0 A B*Alpha
## ______/|______/
## Po Pf
Vmax = 55
Vmin = 0
Vb = 50
A = 1
B = 4
alpha = 1
Po = -A-B
Pf = A+B*alpha
psi_b = array([0,1]) # Wave function boundry [first dir, secound dir]
N = 1000 #steps
psi = np.zeros([N,2])
x = linspace(Po, Pf, N) # x-axis
def V(z):
'''
#Potential function in the finite square well.
'''
val=
for i in z:
if -A <=i <= A:
val.append( Vb)
elif i<=Po:
val.append( Vmax)
elif i>=Pf:
val.append(Vmax)
else:
val.append(Vmin)
return val
def boundary_conditions(psi_Po, psi_pf):
return (psi_b)
def SE(z, p, E):
state0 = p[1]
state1 = 1.0*(V(z) - E)*p[0]
return np.array([state0, state1])
def Wave_function(energy,psi):
y_ = np.zeros((2, x.size))
psi = solve_bvp(SE(x, psi, y_), boundary_conditions, x, y_)
print(len(psi.y))
return psi.y
def pltPotentail():
plot(x,V(x))
def main():
en = linspace(0, Vb, 10) # vector of energies where we look for the stable states
figure(1)
pltPotentail()
Wave_function(0,psi)
show()
if __name__ == "__main__":
main()
python scilab
add a comment |
up vote
0
down vote
favorite
Hi I'm trying to sove the Schrödinger equation for a infinite square well with a barrior using solve_bvp but I don't understand how to do two things with solve_bvp. one is setting the range, the x axis I am trying to give it goes from -b to b but it is solving for 0 to b, I had previously tried solving with solve_ivp but I was running into the same problem. the other problem I have is how to set the boundary condition, I need to take into account the first and second derivative, but I'm a bit lost because I cannot understand the documentation very well. I was following an example found here, but it wasn't giving me the correct results so I'm trying to rewrite it. I'm also discussing the problem on another site but that one is a bit more general than what I'm trying to solve here.
this is the code that I'm trying to get to work
from scipy.integrate import solve_bvp
from pylab import *
import numpy as np
## dimentions _
## | : | | Vmax
## | ___:___ | | _
## |___| |___| _| Vmin _|- Vb
##-B -A 0 A B*Alpha
## ______/|______/
## Po Pf
Vmax = 55
Vmin = 0
Vb = 50
A = 1
B = 4
alpha = 1
Po = -A-B
Pf = A+B*alpha
psi_b = array([0,1]) # Wave function boundry [first dir, secound dir]
N = 1000 #steps
psi = np.zeros([N,2])
x = linspace(Po, Pf, N) # x-axis
def V(z):
'''
#Potential function in the finite square well.
'''
val=
for i in z:
if -A <=i <= A:
val.append( Vb)
elif i<=Po:
val.append( Vmax)
elif i>=Pf:
val.append(Vmax)
else:
val.append(Vmin)
return val
def boundary_conditions(psi_Po, psi_pf):
return (psi_b)
def SE(z, p, E):
state0 = p[1]
state1 = 1.0*(V(z) - E)*p[0]
return np.array([state0, state1])
def Wave_function(energy,psi):
y_ = np.zeros((2, x.size))
psi = solve_bvp(SE(x, psi, y_), boundary_conditions, x, y_)
print(len(psi.y))
return psi.y
def pltPotentail():
plot(x,V(x))
def main():
en = linspace(0, Vb, 10) # vector of energies where we look for the stable states
figure(1)
pltPotentail()
Wave_function(0,psi)
show()
if __name__ == "__main__":
main()
python scilab
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Hi I'm trying to sove the Schrödinger equation for a infinite square well with a barrior using solve_bvp but I don't understand how to do two things with solve_bvp. one is setting the range, the x axis I am trying to give it goes from -b to b but it is solving for 0 to b, I had previously tried solving with solve_ivp but I was running into the same problem. the other problem I have is how to set the boundary condition, I need to take into account the first and second derivative, but I'm a bit lost because I cannot understand the documentation very well. I was following an example found here, but it wasn't giving me the correct results so I'm trying to rewrite it. I'm also discussing the problem on another site but that one is a bit more general than what I'm trying to solve here.
this is the code that I'm trying to get to work
from scipy.integrate import solve_bvp
from pylab import *
import numpy as np
## dimentions _
## | : | | Vmax
## | ___:___ | | _
## |___| |___| _| Vmin _|- Vb
##-B -A 0 A B*Alpha
## ______/|______/
## Po Pf
Vmax = 55
Vmin = 0
Vb = 50
A = 1
B = 4
alpha = 1
Po = -A-B
Pf = A+B*alpha
psi_b = array([0,1]) # Wave function boundry [first dir, secound dir]
N = 1000 #steps
psi = np.zeros([N,2])
x = linspace(Po, Pf, N) # x-axis
def V(z):
'''
#Potential function in the finite square well.
'''
val=
for i in z:
if -A <=i <= A:
val.append( Vb)
elif i<=Po:
val.append( Vmax)
elif i>=Pf:
val.append(Vmax)
else:
val.append(Vmin)
return val
def boundary_conditions(psi_Po, psi_pf):
return (psi_b)
def SE(z, p, E):
state0 = p[1]
state1 = 1.0*(V(z) - E)*p[0]
return np.array([state0, state1])
def Wave_function(energy,psi):
y_ = np.zeros((2, x.size))
psi = solve_bvp(SE(x, psi, y_), boundary_conditions, x, y_)
print(len(psi.y))
return psi.y
def pltPotentail():
plot(x,V(x))
def main():
en = linspace(0, Vb, 10) # vector of energies where we look for the stable states
figure(1)
pltPotentail()
Wave_function(0,psi)
show()
if __name__ == "__main__":
main()
python scilab
Hi I'm trying to sove the Schrödinger equation for a infinite square well with a barrior using solve_bvp but I don't understand how to do two things with solve_bvp. one is setting the range, the x axis I am trying to give it goes from -b to b but it is solving for 0 to b, I had previously tried solving with solve_ivp but I was running into the same problem. the other problem I have is how to set the boundary condition, I need to take into account the first and second derivative, but I'm a bit lost because I cannot understand the documentation very well. I was following an example found here, but it wasn't giving me the correct results so I'm trying to rewrite it. I'm also discussing the problem on another site but that one is a bit more general than what I'm trying to solve here.
this is the code that I'm trying to get to work
from scipy.integrate import solve_bvp
from pylab import *
import numpy as np
## dimentions _
## | : | | Vmax
## | ___:___ | | _
## |___| |___| _| Vmin _|- Vb
##-B -A 0 A B*Alpha
## ______/|______/
## Po Pf
Vmax = 55
Vmin = 0
Vb = 50
A = 1
B = 4
alpha = 1
Po = -A-B
Pf = A+B*alpha
psi_b = array([0,1]) # Wave function boundry [first dir, secound dir]
N = 1000 #steps
psi = np.zeros([N,2])
x = linspace(Po, Pf, N) # x-axis
def V(z):
'''
#Potential function in the finite square well.
'''
val=
for i in z:
if -A <=i <= A:
val.append( Vb)
elif i<=Po:
val.append( Vmax)
elif i>=Pf:
val.append(Vmax)
else:
val.append(Vmin)
return val
def boundary_conditions(psi_Po, psi_pf):
return (psi_b)
def SE(z, p, E):
state0 = p[1]
state1 = 1.0*(V(z) - E)*p[0]
return np.array([state0, state1])
def Wave_function(energy,psi):
y_ = np.zeros((2, x.size))
psi = solve_bvp(SE(x, psi, y_), boundary_conditions, x, y_)
print(len(psi.y))
return psi.y
def pltPotentail():
plot(x,V(x))
def main():
en = linspace(0, Vb, 10) # vector of energies where we look for the stable states
figure(1)
pltPotentail()
Wave_function(0,psi)
show()
if __name__ == "__main__":
main()
python scilab
python scilab
edited Nov 21 at 19:45
asked Nov 21 at 17:24
user169808
5910
5910
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417544%2fusing-solve-bvp-to-solve-schr%25c3%25b6dinger-equation%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown