A site devoted mostly to everything related to Information Technology under the sun - among other things.

Tuesday, April 9, 2024

Plotting Quantum Potential with Python - ChatGPT 3.5

To simulate the interference pattern produced by a double-slit experiment with a double Gaussian wave function and compute the quantum potential, we can follow these steps:

  • Define the double Gaussian wave function.
  • Simulate the double-slit experiment by allowing the wave function to pass through two slits.
  • Compute the interference pattern resulting from the superposition of the waves passing through the two slits.
  • Compute the quantum potential based on the resulting wave function.
  • Plot the interference pattern and the quantum potential.
The results are:




    """

    This code defines a double Gaussian wave function, computes its quantum potential, 

    and then plots both the wave function and the quantum potential. Adjust the parameters 

    as needed to observe different behaviors.

    """

import numpy as np

import matplotlib.pyplot as plt


def compute_quantum_potential(psi, h_bar=1, m=1):

    """

    Computes the quantum potential for a given wave function.


    Arguments:

    psi : array_like

        1-D array representing the wave function.

    h_bar : float, optional

        Value of the reduced Planck constant (default is 1).

    m : float, optional

        Mass of the particle (default is 1).


    Returns:

    quantum_potential : array_like

        1-D array representing the quantum potential.

    """

    # Compute the magnitude of the wave function

    psi_magnitude = np.abs(psi)


    # Compute the second derivative of the wave function

    second_derivative = np.gradient(np.gradient(psi_magnitude))


    # Compute the quantum potential

    quantum_potential = - (h_bar**2 / (2 * m)) * (second_derivative / psi_magnitude)


    return quantum_potential


def double_gaussian_wavefunction(x, x0, sigma, A):

    """

    Computes the double Gaussian wave function.


    Arguments:

    x : array_like

        1-D array representing the position.

    x0 : float

        Position of the center of the Gaussians.

    sigma : float

        Width of the Gaussians.

    A : float

        Amplitude of the Gaussians.


    Returns:

    psi : array_like

        1-D array representing the wave function.

    """

    psi = A * (np.exp(-((x - x0 - 1) / sigma)**2) + np.exp(-((x - x0 + 1) / sigma)**2))

    return psi

# Example usage

if __name__ == "__main__":

    # Define parameters

    x = np.linspace(-5, 5, 1000)  # Position range

    x0 = 0  # Center of the Gaussians

    sigma = 0.5  # Width of the Gaussians

    A = 1  # Amplitude of the Gaussians


    # Compute the double Gaussian wave function

    psi = double_gaussian_wavefunction(x, x0, sigma, A)


    # Compute the quantum potential

    Q = compute_quantum_potential(psi)


    # Plot the wave function and the quantum potential

    plt.figure(figsize=(12, 6))


    plt.subplot(1, 2, 1)

    plt.plot(x, psi, label='Wave function')

    plt.title('Double Gaussian Wave Function')

    plt.xlabel('Position')

    plt.ylabel('Amplitude')

    plt.legend()


    plt.subplot(1, 2, 2)

    plt.plot(x, Q, label='Quantum Potential', color='red')

    plt.title('Quantum Potential')

    plt.xlabel('Position')

    plt.ylabel('Value')

    plt.legend()


    plt.tight_layout()

    plt.show()

No comments:

About Me

My photo
I am a senior software developer working for General Motors Corporation.. I am interested in intelligent computing and scientific computing. I am passionate about computers as enablers for human imagination. The contents of this site are not in any way, shape, or form endorsed, approved, or otherwise authorized by HP, its subsidiaries, or its officers and shareholders.

Blog Archive