LinearCombinationOfHAWPs

About the LinearCombinationOfHAWPs 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 LinearCombinationOfHAWPs

Class documentation

class WaveBlocksND.LinearCombinationOfHAWPs(dimension, number_components, eps, number_packets=0)[source]

This class represents linear combinations of compatible Hagedorn wavepackets.

__init__(dimension, number_components, eps, number_packets=0)[source]

Initialize a new linear combination of Hagedorn wavepackets. This object represents \Upsilon := \sum_{j=0}^{J-1} c_j \Psi_j. All J wavepackets \Psi_j have the same number N components and are defined in the D dimensional space.

Parameters:
  • dimension – The space dimension D the packets have.
  • ncomponents – The number N of components the packets have.
Returns:

An instance of LinearCombinationOfHAWPs.

__str__()[source]
Returns:A string describing the linear combination of Hagedorn wavepackets \Upsilon = \sum_{j=0}^J c_j \Psi_j.
add_wavepacket(packet, coefficient=1.0)[source]

Add a new wavepacket to the linear combination.

Parameters:
  • packet (A HagedornWavepacket instance.) – The new Hagedorn wavepacket \Psi_j to add.
  • coefficient – The corresponding coefficient c_j, default is 1.0.
add_wavepackets(packetlist, coefficients=None)[source]

Add a list of new wavepackets to the linear combination.

Parameters:
  • packetlist (A list of HagedornWavepacket instances.) – A list of new Hagedorn wavepackets \{\Psi_j\}.
  • coefficients – The corresponding coefficient vector c, default is a vector of all 1.0.
clone()
Raise:NotImplementedError Abstract interface.
evaluate_at(grid, packetindex=None, prefactor=False)[source]

Evaluate the linear copmbination \Upsilon = \sum_{j=0}^J c_j \Psi_j of Hagedorn wavepackets \Psi_j at the given nodes \gamma.

Parameters:
  • grid (A class having a get_nodes(...) method.) – The grid \Gamma containing the nodes \gamma.
  • packetindex – The index j of a single packet \Psi_j to evaluate. (Defaults to None for evaluating all wavepackets.)
  • prefactor (Boolean, default is False.) – Whether to include a factor of \frac{1}{\sqrt{\det(Q_j)}}.
Returns:

A list of arrays or a single array containing the values of the \Psi_j at the nodes \gamma.

evaluate_basis_at(grid, prefactor=False)[source]

Evaluate all the individual Hagedorn wavepackets \Psi_j of \Upsilon = \sum_{j=0}^J c_j \Psi_j at the given nodes \gamma.

Parameters:
  • grid (A class having a get_nodes(...) method.) – The grid \Gamma containing the nodes \gamma.
  • prefactor (Boolean, default is False.) – Whether to include a factor of \frac{1}{\sqrt{\det(Q_j)}}.
Returns:

A two-dimensional ndarray H of shape (|\Gamma|, J) where the entry H[i, j] is the value of \Psi_j(\gamma_i).

get_basis_shapes(packetindex=None)[source]

Retrieve the basis shapes \mathfrak{K}_j for each packet \Psi_j.

Parameters:component (int) – The component i whose basis shape we request. (Default is None which means to return the basis shapes for all components.
Returns:The basis shape for an individual component or a list with all shapes.
get_basis_shapes_hashes(packetindex=None)[source]

Retrieve the hashes of all basis shapes \mathfrak{K}_j for each packet \Psi_j.

Parameters:component (int) – The component i whose basis shape we request. (Default is None which means to return the basis shapes for all components.
Returns:The basis shape for an individual component or a list with all shapes.
get_basis_sizes(packetindex=None)[source]

Retrieve the basis sizes |\mathfrak{K}_j| for each packet \Psi_j.

Parameters:component (int) – The component i whose basis shape we request. (Default is None which means to return the basis shapes for all components.
Returns:The basis shape for an individual component or a list with all shapes.
get_coefficient(packetindex)[source]

Get the coefficient c_j of the wavepacket \Psi_j.

Parameters:packetindex – The index 0 \leq j < J of the coefficient to retrieve.
Returns:The coefficient c_j.
get_coefficients()[source]

Get the vector with all coefficients c_j of all wavepackets \Psi_j.

Returns:The vector c of all coefficients c_j. The vector is of shape (J, 1).
Type:An ndarray
get_description()[source]

Return a description of this linear combination object. A description is a dict containing all key-value pairs necessary to reconstruct the current instance. A description never contains any data.

get_dimension()
Returns:The space dimension D of all the wavepackets \Psi_j.
get_eps()[source]

Retrieve the semi-classical scaling parameter \varepsilon of the wavepacket.

Returns:The value of \varepsilon.
get_number_components()
Returns:The number N of components all the wavepackets \Psi_j have.
get_number_packets()
Returns:The number J of wavepackets in the linear combination \Upsilon := \sum_{j=0}^{J-1} c_j \Psi_j.
get_wavepacket(packetindex)[source]

Get the wavepacket \Psi_j from the linear combination.

Parameters:index – The index 0 \leq j < J of the packet to retrieve.
Returns:The wavepacket \Psi_j.
Type:A HagedornWavepacket instance.
get_wavepacket_coefficient(packetindex, index)[source]

Retrieve a single coefficient c^i_k of the specified component \Phi_i of \Psi.

Parameters:
  • component – The index i of the component \Phi_i we want to update.
  • index (A tuple of D integers.) – The multi-index k of the coefficient c^i_k we want to update.
Returns:

A single complex number.

Raise:

ValueError For invalid indices i or k.

get_wavepacket_coefficients(packetindex=None)[source]

Retrieve a single coefficient c^i_k of the specified component \Phi_i of \Psi.

Parameters:
  • component – The index i of the component \Phi_i we want to update.
  • index (A tuple of D integers.) – The multi-index k of the coefficient c^i_k we want to update.
Returns:

A single complex number.

Raise:

ValueError For invalid indices i or k.

get_wavepacket_parameters(packetindex=None, key=('q', 'p', 'Q', 'P', 'S'))[source]

Get the Hagedorn parameter set \Pi of the wavepacket \Psi_j.

Parameters:packetindex – The index 0 \leq j < J of the packet whose parameter set Pi we want.
Returns:The Hagedorn parameter set \Pi = (q, p, Q, P, S) in this order.
get_wavepackets()[source]

Get all the wavepackets \Psi_j from the linear combination \Upsilon.

Warning

This method potentially generates a large number of wavepacket instances.

Returns:A list of HagedornWavepacket instances.
remove_wavepacket(packetindex)[source]

Remove a wavepacket \Psi_j from the linear combination.

Parameters:packetindex – The index 0 \leq j < J of the packet to remove.
set_coefficient(packetindex, coefficient)[source]

Set the coefficient c_j of the wavepacket \Psi_j.

Parameters:
  • packetindex – The index 0 \leq j < J of the coefficient to retrieve.
  • coefficient – The coefficient c_j.
set_coefficients(coefficients)[source]

Update all the coefficients c of \Upsilon.

Parameters:coefficients (An ndarray) – The vector c.
set_wavepacket_coefficient(packetindex, index, value)[source]

Set a single coefficient c^i_k of the specified component \Phi_i of \Psi.

Parameters:
  • component – The index i of the component \Phi_i we want to update.
  • index (A tuple of D integers.) – The multi-index k of the coefficient c^i_k we want to update.
  • value – The new value of the coefficient c^i_k.
Raise:

ValueError For invalid indices i or k.

set_wavepacket_coefficients(coefficients, basisshapes=None, packetindex=None)[source]

Retrieve a single coefficient c^i_k of the specified component \Phi_i of \Psi.

Warning: make sure the coefficients and basis shapes stay in sync!

Parameters:
  • component – The index i of the component \Phi_i we want to update.
  • index (A tuple of D integers.) – The multi-index k of the coefficient c^i_k we want to update.
Returns:

A single complex number.

Raise:

ValueError For invalid indices i or k.

set_wavepacket_parameters(Pilist, packetindex=None, key=('q', 'p', 'Q', 'P', 'S'))[source]

Set the Hagedorn parameters \Pi of the wavepacket \Psi_j.

Parameters:Pilist – The Hagedorn parameter set \Pi = (q, p, Q, P, S) in this order.
set_wavepackets(packetlist)
Raise:NotImplementedError Abstract interface.
slim_recursion(grid, packetindex, prefactor=False)[source]

Evaluate the Hagedorn wavepacket \Psi at the given nodes \gamma. This routine is a slim version compared to the full basis evaluation. At every moment we store only the data we really need to compute the next step until we hit the highest order basis functions.

Parameters:
  • grid (A class having a get_nodes(...) method.) – The grid \Gamma containing the nodes \gamma.
  • component – The index i of a single component \Phi_i to evaluate.
  • prefactor (Boolean, default is False.) – Whether to include a factor of \frac{1}{\sqrt{\det(Q)}}.
Returns:

A list of arrays or a single array containing the values of the \Phi_i at the nodes \gamma.

Note that this function does not include the global phase \exp(\frac{i S}{\varepsilon^2}).