WaveFunction

About the WaveFunction class

The WaveBlocks Project

@author: R. Bourquin @copyright: Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016 R. Bourquin @license: Modified BSD License

Inheritance diagram

Inheritance diagram of WaveFunction

Class documentation

class WaveBlocksND.WaveFunction(parameters)[source]

This class represents a vector valued wavefunction \Psi as used in the vector valued time-dependent Schroedinger equation. The state \Psi consists of the components \psi_0 to \psi_{N-1}.

get_grid()[source]

Return the Grid instance representing the grid \Gamma. The wavefunction \Psi is evaluated on the grid nodes to get \Psi(\Gamma).

get_number_components()[source]

The number of components \psi_i the vector \Psi consists of.

get_values(components=None, flat=None)[source]

Get the wavefunction values \psi(\Gamma) for each component \psi_i of \Psi.

Parameters:
  • components (A single integer or a list of integers. If set to None (default) we return the data for all components.) – The components i for which we want to get the wavefunction values \psi_i.
  • flat (Boolean or None , default is None.) – Whether to return the wavefunction with a hypercubic (N, N_1, ..., N_D) shape or a flat (N, \prod_i^D N_i) shape.
Returns:

A list of the values \psi_i for all components i.

kinetic_energy(kinetic, summed=False)[source]

Calculate the kinetic energy E_{\text{kin}} := \langle\Psi|T|\Psi\rangle of the different components \psi_i.

Parameters:
  • kinetic (A KineticOperator instance.) – The kinetic energy operator T(\omega).
  • summed – Whether to sum up the kinetic energies E_i of the individual components \psi_i. Default is False.
Returns:

A list with the kinetic energies of the individual components or the overall kinetic energy of the wavefunction. (Depending on the optional arguments.)

norm(values=None, summed=False, components=None)[source]

Calculate the L^2 norm of the whole vector values wavefunction \Psi or some individual components \psi_i. The calculation is done in momentum space.

Parameters:
  • values – Allows to use this function for external data, similar to a static function.
  • summed (Boolean, default is False.) – Whether to sum up the norms of the individual components.
  • components (A single integer or a list of integers. If set to None (default) we compute the norm for all components.) – The components \psi_i of which the norms are calculated.
Returns:

The L^2 norm of \Psi or a list of L^2 norms of the specified components \psi_i.

potential_energy(potential, summed=False)[source]

Calculate the potential energy E_{\text{pot}} := \langle\Psi|V|\Psi\rangle of the different components \psi_i.

Parameters:
  • potential – The potential energy operator V(x).
  • summed – Whether to sum up the potential energies E_i of the individual components \psi_i. Default is False.
Returns:

A list with the potential energies of the individual components or the overall potential energy of the wavefunction. (Depending on the optional arguments.)

set_grid(grid)[source]

Assign a new grid \Gamma to this WaveFunction instance.

Note: The user of this class has to make sure that the grid \Gamma and the wavefunction values \Psi(\Gamma) are consistent with each other!

Parameters:grid – A new Grid instance.
set_values(values, components=None, flat=None)[source]

Assign new wavefunction values \psi_i(\Gamma) for each component i of \Psi to the current WaveFunction instance.

Parameters:
  • values (Each entry of the list has to be an ndarray.) – A list with the new values of all components we want to change.
  • components (A single integer or a list of integers. If set to None (default) we set the data for all components.) – The components i for which we want to set the new wavefunction values \psi_i.
  • flat (Boolean or None , default is None.) – Whether the wavefunction is given in hypercubic (N, N_1, ..., N_D) shape or a flat (N, \prod_i^D N_i) shape. Note that this has no effect yet.

Note: This method does NOT copy the input data arrays.

Raise:ValueError If the list of values has the wrong length.