quantumworldX package

Submodules

quantumworldX.core module

qwX core functions

Here you can find all the main functions of quantumworldX, the suggested way to import this module is

import quantumworldX as qw

from there you are able to use all core functions, for example to utilize pib_eigenfunction you would use qw.pib_eigenfunction.

class quantumworldX.core.EnergyTuple(name=None, energy=1.0, quantumNumbers=[], efunc=None, **kwds)

Bases: object

colour(n1=2.0)
colour_string()
energyInWavenumbers()
populateEnergy()
wavelength()
quantumworldX.core.HO_wigner(x, p, w, m=1.0, hbar=1.0)

Harmonic Oscillator wigner representation.

Returns the Wigner representation of a gaussian in a harmonic oscillator potential.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of length n.
  • p (np.array) – 1-D array representing a momentum space grid of length m.
  • w (float) – Frequency of the Oscillator. Defaults to 1 (atomic units).
  • m (float) – Mass of the Oscillator. Defaults to 1 (atomic units).
  • h_bar (float) – Value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will a 1-D array of length (n).

quantumworldX.core.L(rho, alpha, n)

This method returns the generalized laguerre polynomial with subscript n # and superscript alpha for points rho This is a giant pain to get all the factors just right. Don’t do it.

rho: Array of points to return the value of the polynomial on alpha: Superscript parameter n: Subscript parameter

poly: Array with the discrete values of the specified Laguerre polynomial

quantumworldX.core.build_hamiltonian(x, v_x, m=1, h_bar=1)

Hamiltonian in matrix form

Will build the Hamiltonian H in matrix form. This is typically used along with sp.linalg.eigh to compute eigenvalues and eigenfunctions. v_x will be a potential evaluated on a spatial grid x.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of len n.
  • v_x (np.array) – 1-D array representing a potential function evaluated
  • a spatial grid, also of len n. (on) –
  • m (float) – Mass of the particle. Defaults to 1 (atomic units).
  • h_bar (float) – Value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will a 2-D array of shape (n,n).

quantumworldX.core.cnt_evolve(cn_0, t, En, hbar=1)

Coefficient time evolution

Based on the time evolution equation and the coefficient and energy of a wavefunction it will time-propagate this coefficient into a future time t. Returning the value of the coefficient at this time.

Parameters:
  • cn_0 (float) – Coefficient of a wavefunction at time zero.
  • t (float) – The time at which the coefficient will be evolved.
  • En (float) – Energy of the wavefunction.
  • h_bar (float) – value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will return a float representing the coefficient at time t.

quantumworldX.core.complex_quad(func, a, b, **kwargs)

Complex version of scipy’s quad

Will return integral of a complex function over a range (a,b). Uses same arguments as scipy.integrate.quad.

Parameters:
  • func (function) – Callable function to integrate.
  • a (float) – Start point of integration range.
  • b (float) – End point of integration range.
  • **kwargs – For additional arguments look up documentation on the scipy.integrate.quad function.
Returns:

Will a tuples of (real,imaginary) values.

quantumworldX.core.complex_simps(y, x)

Complex version of scipy’s simps

Will return integral of a complex function y over a numerical grid x.

Parameters:
  • y (np.array) – A 1-D complex-valued array of size n.
  • x (float) – A 1-D real-valued array of size n.
Returns:

A 1-D complex-valued array of size n.

quantumworldX.core.coulomb_double_well(x, r)

Double coulomb-like well potential

Will create a double well potential, with coulomb-like wells. Assumes the wells are each located at -r/2 and r/2, so the potential is centered at 0. The potential is constructed iteratively, using the columb function for each site after and before the center 0.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of len n.
  • a spatial grid. (on) –
  • r (float) – The distance between the centers of the two wells
Returns:

1-D array of length n.

quantumworldX.core.coulomb_well(x, x0=0.0)

Coulomb-like well potential

Will create a Coulomb well potential. Assumes the well is located as x0.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of len n.
  • a spatial grid. (on) –
  • x0 (float) – Centers of the well.
Returns:

1-D array of length n.

quantumworldX.core.dipole_moment_integrand(phi, theta, mu, l1, m1, l2, m2)

INPUTS: phi: real value in [0,2pi] theta: real value in [0,pi] mu: dipole moment of the molecule l1, m1: quantum numbers for the first spherical harmonic l2, m2: quantum numbers for the second spherical harmonic OUTPUT: Integrand evaluated at (phi,theta)

quantumworldX.core.dipole_moment_integrand_superposition(phi, theta, mu, c1, c2, l1, m1, l2, m2)

INPUTS: phi: real value in [0,2pi] theta: real value in [0,pi] mu: dipole moment of the molecule c1, c2: normalized coefficients for the superposition l1, m1: quantum numbers for the first spherical harmonic l2, m2: quantum numbers for the second spherical harmonic OUTPUT: Integrand evaluated at (phi,theta) for the superposition Y=c_1 Y^l1_m1 + c_2 Y^l2_m2

quantumworldX.core.eval_expectation(x, psi_x, operator_x)

Evaluate expectation value

Compute the expectation of a wavefunction psi_x defined on a grid x with respect to the quantum operator operator_x. First build the integrand and uses scipy.integrate.simps to integrate and return the expectation value.

Parameters:
  • psi_x (np.array) – 1-D array representing a wavefunction on a
  • grid. (spatial) –
  • dx (float) – Spacing for the spatial grid.
  • h_bar (float) – Value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will a complex number.

quantumworldX.core.excited_overlap(t, omega_f, omega_0=1, lam=1, E_0=0.1, m=1, hbar=1)
quantumworldX.core.finite_diff(y, dx)

Finite difference via central differences.

For a given function (y) evaluated on a uniform spatial grid with spacing dx, it will return the finite differences approximation to the derivative of

Parameters:
  • cn_0 (float) – Coefficient of a wavefunction at time zero.
  • t (float) – The time at which the coefficient will be evolved.
  • En (float) – Energy of the wavefunction.
  • h_bar (float) – value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will return a float representing the coefficient at time t.

quantumworldX.core.harmonic_oscillator_2D(xx, yy, l, m, mass=1.0, omega=1.0, hbar=1.0)

2D Harmonic Oscillator

Given 2-D coordinate arrays xx and yy, it will evaluate the harmonic oscillator on these grids and return another 2-D coordinate array.

Parameters:
  • xx (np.ndarray) – 2-D coordinate array representing a spatial grid on the x axis of shape (n,n).
  • yy (np.ndarray) – 2-D coordinate array representing a spatial grid on the y axis of shape (n,n).
  • l (int) – Quantum number l.
  • m (int) – Quantum number m.
  • mass (float) – Mass of the Oscillator. Defaults to 1 (atomic units).
  • omega (float) – Frequency of the Oscillator. Defaults to 1 (atomic units).
  • h_bar (float) – Value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will a 2-D ndarray of shape (n,n).

quantumworldX.core.harmonic_oscillator_wfn(x, n, m=1.0, omega=1.0, hbar=1.0)

1D Harmonic Oscillator wavefunction.

Will return the harmonic oscillator wavefunction evaluted on the spatial grid x acoording to the parameters.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of length n.
  • n (int) – Quantum number n.
  • m (float) – Mass of the Oscillator. Defaults to 1 (atomic units).
  • omega (float) – Frequency of the Oscillator. Defaults to 1 (atomic units).
  • h_bar (float) – Value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will a 1-D array of length (n).

quantumworldX.core.harmonic_time_dependent(t, c, n, l)

1D time-dependent component of the wave solution for a standing wave.

Will return the time-dependent solution to the wave equation for a wave on a string, evaluted on the spatial grid x acoording to the parameters.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of length xn.
  • c (int) – String constant for the standing wave.
  • n (int) – Harmonic n.
  • l (float) – Length of the box for the HO.
Returns:

Will a 1-D array of length (xn). Can also return a float.

quantumworldX.core.harmonic_time_independent(x, n, l)

1D time-dependent component of the wave solution for a standing wave.

Will return the time-independent solution to the wave equation for a wave on a string, evaluted on the spatial grid x acoording to the parameters.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of length xn.
  • n (int) – Harmonic n.
  • l (float) – Length of the box for the HO.
Returns:

Will a 1-D array of length (xn). Can also return a float.

quantumworldX.core.hydrogen_radial_wfn(r, n, l, a0=1.0, z=1.0)

This method will return the radial part of the wave function. I’ve gone ahead and defined the normalization factor but you will need to implement the rest.

INPUT r: Array of points to return the value of the wavefunction on n: principle quantum number l: angular quantum number

OUTPUT wf: Array of points to return the wavefunction

quantumworldX.core.kinetic_operator(x, m=1, h_bar=1)

Kinetic operator in matrix form

Will build the Kinectc operator T in matrix form. This is typically used for building a Hamiltonian. Uses finite differences to compute the double derivative.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of len n.
  • m (float) – mass of the particle. Defaults to 1 (atomic units).
  • h_bar (float) – value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will a 2-D array of shape (n,n).

quantumworldX.core.momentum_operator(psi_x, dx, hbar=1)

Momentum operator on wavefunction

Compute the momentum operator for a given wavefunction psi_x. Will use finite differences to compute the derivative.

Parameters:
  • psi_x (np.array) – 1-D array representing a wavefunction on a
  • grid. (spatial) –
  • dx (float) – Spacing for the spatial grid.
  • h_bar (float) – Value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will return a 1-D np.array.

quantumworldX.core.normalize_wfn(x, psi_x)

Normalize a wavefunction

Will return the wavefunction psi_x normalized, first it calculates the probability density function then the norm of the wavefunction and finally divides by the square root of the norm.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid.
  • psi_x (np.array) – 1-D array representing a wavefunction evaluated on the spatial grid, show be same length as x.
Returns:

Will return a 1-D real np.array representing the normalized wavefunction of psi_x.

quantumworldX.core.pib_eigenfunction(x, l, n)

Particle in the box eigenfunction.

Give a spatial array x, the length of box L and a harmonic number n, it will return the eigenfunction of the 1-D Particle in a box evaluated on the x grid.

Parameters:
  • x (np.array) – 1-D array representing a wavefunction evaluated on a spatial grid.
  • L (float) – length of the box.
  • n (int) – number of the harmonic of the pib.
Returns:

Will return a 1-D np.array.

quantumworldX.core.pib_energy(n, L, m=1, h_bar=1)

Energy of particle in a box n-th eigenstate.

Returns energy of the nth eigenstate of the 1D particle in a box.

Parameters:
  • n (int) – The quantum number specifying the eigenstate of the pib.
  • L (float) – length of the box.
  • m (float) – mass of the particle. Defaults to 1 (atomic units).
  • h_bar (float) – value of plank’s constant. Defaults to 1 (atomic units).
Returns:

Will a float representing the energy

quantumworldX.core.pib_superposition(x, t, l, n1=1, n2=2)

Particle in a box superposition

Create a time-evolved superposition of two particle in a Box eigenstates, assumes equal contribution in coefficients between each eigenstate. Will return a 2-D np.array with each row being a snapshot of the time-evolved wavefunction.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of len n.
  • t (np.array) – 1-D array representing a temporal grid of len m.
  • l (float) – The length of the box of the pib.
  • n1 (int) – Quantum number for the first eigenstate.
  • n2 (int) – Quantum number for the second eigenstate.
Returns:

Will a 2-D array of shape (n,m).

quantumworldX.core.plane_wave(x, energy, m=1, hbar=1)
quantumworldX.core.prob_density(psi_x)

Probability density of a wavefunction.

Given a wavefuntion represented as a 1-D array, it will compute the
probability density, which is the square of the wavefuntion.
Parameters:psi_x (np.array) – 1-D array representing a wavefunction evaluated on a spatial grid.
Returns:Will return a 1-D real np.array.
quantumworldX.core.r_expectation(r, n, l, a0=1.0, z=1.0)
quantumworldX.core.square_barrier(x, l=1, h=9, x0=4)
quantumworldX.core.time_dependent_psi(x, t, omega_f, omega_0=1, lam=1, E_0=1, m=1, hbar=1)
quantumworldX.core.transmission_probability(pdf, n_cutoff=300)
quantumworldX.core.tunnel_findiff_propagate(x, psi_x, v_x, E)
quantumworldX.core.wave_solution(x, t, c, n, l)

1D wave solution for a standing wave.

Will return the time-depdant solution to the wave equation for a wave on a string, evaluted on the spatial grid x and temporal grid t acoording to the parameters.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid of length xn.
  • t (np.array) – 1-D array representing a spatial grid of length tn.
  • c (int) – String constant for the standing wave.
  • n (int) – Harmonic n.
  • l (float) – Length of the box for the HO.
Returns:

Will a 2-D array of shape (xn,tn).

quantumworldX.core.wfn_norm(x, psi_x)

Calculate norm of a wavefuntion.

Returns the norm of a wavefunction psi_x by getting the pdf and then integrating over a spatial grid x.

Parameters:
  • x (np.array) – 1-D array representing a spatial grid.
  • psi_x (np.array) – 1-D array representing a wavefunction evaluated on the spatial grid, show be same length as x.
Returns:

Will a float representing the norm of the wavefunction.

quantumworldX.helium module

quantumworldX.helium.H0()
quantumworldX.helium.H1(lam)
quantumworldX.helium.H11_pm()
quantumworldX.helium.H11_vpm(t, u, s, zeta=1.6875, Z=2)
quantumworldX.helium.H12_pm()
quantumworldX.helium.H22_pm()
quantumworldX.helium.H_lambda(lam)
quantumworldX.helium.J22_pm()
quantumworldX.helium.K22_pm()
quantumworldX.helium.S11_vpm(t, u, s, zeta=1.6875, Z=2)
quantumworldX.helium.ci_hamiltonian()
quantumworldX.helium.expected_phi1(zeta)
quantumworldX.helium.phi1(s, t, u, zeta, Z=2)
quantumworldX.helium.phi10(s, t, u, zeta, Z=2)
quantumworldX.helium.phi10_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi10_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi10_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi1_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi1_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi1_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi2(s, t, u, zeta, Z=2)
quantumworldX.helium.phi2_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi2_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi2_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi3(s, t, u, zeta, Z=2)
quantumworldX.helium.phi3_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi3_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi3_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi4(s, t, u, zeta, Z=2)
quantumworldX.helium.phi4_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi4_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi4_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi5(s, t, u, zeta, Z=2)
quantumworldX.helium.phi5_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi5_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi5_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi6(s, t, u, zeta, Z=2)
quantumworldX.helium.phi6_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi6_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi6_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi7(s, t, u, zeta, Z=2)
quantumworldX.helium.phi7_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi7_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi7_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi8(s, t, u, zeta, Z=2)
quantumworldX.helium.phi8_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi8_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi8_du(s, t, u, zeta, Z=2)
quantumworldX.helium.phi9(s, t, u, zeta, Z=2)
quantumworldX.helium.phi9_ds(s, t, u, zeta, Z=2)
quantumworldX.helium.phi9_dt(s, t, u, zeta, Z=2)
quantumworldX.helium.phi9_du(s, t, u, zeta, Z=2)

quantumworldX.hydrogen module

quantumworldX.hydrogen.E_excited(R)
quantumworldX.hydrogen.E_ground(R)
quantumworldX.hydrogen.H11(R)
quantumworldX.hydrogen.H12(R)
quantumworldX.hydrogen.J11(R)
quantumworldX.hydrogen.J12(R)
quantumworldX.hydrogen.J22(R)
quantumworldX.hydrogen.K12(R)
quantumworldX.hydrogen.S12(R)
quantumworldX.hydrogen.T11(R)
quantumworldX.hydrogen.T12(R)
quantumworldX.hydrogen.V(R)
quantumworldX.hydrogen.V11A(R)
quantumworldX.hydrogen.V11B(R)
quantumworldX.hydrogen.V12A(R)
quantumworldX.hydrogen.V12B(R)
quantumworldX.hydrogen.int_1111(R)
quantumworldX.hydrogen.int_1112(R)
quantumworldX.hydrogen.int_1122(R)
quantumworldX.hydrogen.int_1212(R)

quantumworldX.plot module

qwX plotting functions

Anything plotting related goes here, these functions are imported with import quantumworldX as qw from there you are able to use all plot functions, for example to utilize time_plot you would use qw.time_plot.

quantumworldX.plot.plot_3d_surface(xx, yy, zz)

Plot a 3D surface.

Based on three numpy.ndarray objects xx,yy and zz of the same shape, it will plot the surface represented by z on the axis x and y. Typically xx and yy are constructed via np.meshgrid and then zz by a function evaluation on these grids.

Parameters:
  • xx (np.ndarray) – 2-D coordinate array representing a spatial grid on the x axis.
  • yy (np.ndarray) – 2-D coordinate array representing a spatial grid on the y axis.
  • zz (np.ndarray) – 2-D coordinate array representing a spatial grid on the z axis.
Returns:

Does not return anything, will have a plot already loaded to be use along with matplotlib.pyplot (plt.show).

quantumworldX.plot.plot_contours(xx, yy, zz, vmin=None, vmax=None)

Plot a heatmap and level set contours of a 3d surface.

Based on three numpy.ndarray objects xx,yy and zz of the same shape, it will plot a heatmap, a 2D colored image representing values of z across x and y, along with several contour level sets, curves where z is constant. Both visualizations provide an alternative way of looking at 3-D surfaces in a 2-D projection.

Parameters:
  • xx (np.ndarray) – 2-D coordinate array representing a spatial grid on the x axis.
  • yy (np.ndarray) – 2-D coordinate array representing a spatial grid on the y axis.
  • zz (np.ndarray) – 2-D coordinate array representing a spatial grid on the z axis.
  • vmin (float) – Mainimum value of z, used to anchor the colormap. Defaults to None, which means it will calculate it dynamically.
  • vmax (float) – Maximum value of z, used to anchor the colormap. Defaults to None, which means it will calculate it dynamically.
Returns:

Does not return anything, will have a plot already loaded to be use along with matplotlib.pyplot (plt.show).

quantumworldX.plot.plot_energy_diagram(energy_list)

Plot a typical energy diagram based

Will plot the representation of several energy levels and their associated quantum numbers in a energy diagram. It uses as input a list of Energy tuples.

Parameters:energy_list (list) – A list of energy tuples.
Returns:Does not return anything, will have a plot already loaded to be use along with matplotlib.pyplot (plt.show).
quantumworldX.plot.plot_settings()
quantumworldX.plot.time_plot(x, y, t, t_step=1)

Plot several plots overlaid across time

Utility plotting function that will setup plots of several snapshots in time (t) of a function (y) over a spatial grid (x). You can control the frequency of these plots with t_step, with a higher value indicating less frequent plots across time. At some moment after use, plt.show should be utilized to display the figure.

Parameters:
  • x (np.array) – 1-D array of shape (n) representing a spatial grid
  • y (np.array) – 2-D array of shape (n,m) representing several snapshots across time of a function on a spatial grid
  • t (np.array) – 1-D array of shape (m) representing a time grid
  • t_step (int) – integer indicating how many frames to skip for plotting, for example, t_step=10, means it will plot every 10 frame of t, while t_step=1, will plot every frame possible.
Returns:

Does not return anything, will have a plot already loaded to be use along with matplotlib.pyplot (plt.show).

quantumworldX.plot.time_plot1D(x, t, t_step=1)

Plot several plots overlaid across time for a 1-D particle.

Utility plotting function that will setup plots of several snapshots in time (t) of a the position of a 1-D particle(x). You can control the frequency of these plots with t_step, with a higher value indicating less frequent plots across time. At some moment after use, plt.show should be utilized to display the figure.

Parameters:
  • x (np.array) – 1-D array of shape (n) representing a spatial grid.
  • t (np.array) – 1-D array of shape (m) representing a time grid.
  • t_step (int) – integer indicating how many frames to skip for plotting, for example, t_step=10, means it will plot every 10 frame of t, while t_step=1, will plot every frame possible.
Returns:

Does not return anything, will have a plot already loaded to be use along with matplotlib.pyplot (plt.show).

Module contents