[Python] Plotting Harmonic Oscillator States using Hermite Functions

Discussão em 'Python' iniciado por Stack, Maio 27, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to figure out how to plot a displaced harmonic oscillator in position space. The solution of the wavefunction in coordinate basis is

    $$\psi_n(x) = \frac{1}{\sqrt{2^n n!}} e^{-x^2} H_n(x), n=0, 1, 2, .. $$

    And what I'm trying to do is calculate the coefficient in front of the Hermite function, which should be dependant on $x$. What I've been trying to do is:

    1. Put the Hamiltonian in the position basis (I'm not sure if I'm doing this correctly?)
    2. Get the eigenstates of $\ket{\psi_n}$
    3. evaluate $\braket{x}{\psi_n}$ for each position, which should give the coefficients
    4. Multiply $\braket{x}{\psi_n}$ by $H_n(x)$ function at the corresponding $x$ value

    I should also be able to sum all the $\psi_n(x)$ values to get a displaced Gaussian. Code below:

    disp = qt.displace(N, alpha)
    x_op = (a_dag + a)
    x_val, x_st = x_op.eigenstates()

    h = (a1_dag * a1 + 1/2)
    h_val, h_st = h.eigenstates()
    h_st = [disp * i for i in h_st]

    hx = (h_st[n].transform(x_st))
    wv_coeff = [i.dag() * hx for i in x_st]


    wf_coeff should be the coefficients for $\psi_n$, which can then be multiplied by the hermite polynomial $H_n(x)$, with $x$ coming from x_val.

    Continue reading...

Compartilhe esta Página