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()









share|improve this question




























    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()









    share|improve this question


























      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()









      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 at 19:45

























      asked Nov 21 at 17:24









      user169808

      5910




      5910





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          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






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Contact image not getting when fetch all contact list from iPhone by CNContact

          count number of partitions of a set with n elements into k subsets

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks