tkwant.manybody.WaveFunction¶

class
tkwant.manybody.
WaveFunction
(psi_init, tasks, comm=None)[source]¶ Evolve a manyparticle wavefunction in time.
Initialize the manybody state.
 Parameters
psi_init (dict of
tkwant.onebody.WaveFunction
) – Dictionary with all initial onebody states. For load balancing the dictionary should be distributed over all MPI ranks.tasks (dict of
tkwant.onebody.Task
) –Dictionary containing the weighting factor for each onebody state. Each item must have at least the following attribute:
weight :
ndarray
, weighting factor
tasks
must include all onebody states stored in psi_init and must be the same on all MPI ranks.comm (
Intracomm
, optional) – The MPI communicator over which to parallelize the computation. By default, use the tkwant global MPI communicator.
Methods

add_distributed_onebody_states
(states, tasks)[source]¶ Add several onebody wavefunctions to the manybody state.
 Parameters
state (dict of
tkwant.onebody.WaveFunction
) – Dictionary of onebody wavefunctions to be addedtask (dict of
tkwant.onebody.Task
) –Task info of the states. Each
tasks
item must contain at least the weight factors of the onebody states in the manybody average as attribute:weight :
ndarray
, weighting factor
Notes
The states present in the states dictionary can be distributed over all MPI ranks. Each single onebody state must be unique and not dublicated on any other MPI rank.

add_onebody_state
(state, task, key=None, rank=None)[source]¶ Add a onebody wavefunction to the manybody state.
 Parameters
state (
tkwant.onebody.WaveFunction
) – onebody wavefunctiontask (
tkwant.onebody.Task
) –Task info of the state.
task
must contain at least the weight factors of the onebody states in the manybody average as attribute:weight :
ndarray
, weighting factor
key (dict key, optional) – Idendentifier of the state. A free key is attributed if not present.
rank (int, optional) – MPI rank where the state should be added.
 Returns
key – Idendentifier of the added onebody state.
 Return type
dict key
Notes
The state must be present on all MPI ranks.

delete_onebody_state
(key)[source]¶ Delete a onebody wavefunction corresponding to its key.
 Parameters
key (dict key) – Idendentifier of the onebody state that should be deleted.

evaluate
(observable, root=0)[source]¶ Evaluate the expectation value of an operator at the current time.
 Parameters
observable (callable or
kwant.operator
) – An operator to evaluate the expectation value. Must have the calling signature ofkwant.operator
.root (int or None, optional) – MPI return rank on which to return the result. If
root
is an integer, it must be in the range of valid MPI ranks0 <= root < self.comm.size
. In that case, the calculated result is returned only on that specific MPI rank whererank == root
, whereas the result is None on all other MPI ranks withrank != root
. Alternatively, ifroot
is None, the calculated result is returned on all MPI ranks. By default, the result is returned on MPI rank zero only.
 Returns
result – The expectation value of
observable
, integrated over all occupied bands. The result might not be returned on all MPI ranks; note the explanation above for input parameterroot
. Return type
Notes
Returning the result on all MPI ranks (by setting
root=None
), might be slower, as an additional broadcast step is needed.

get_free_key
()[source]¶ Get a new free key.
 Returns
key – New unused key. All numbers larger then the returned key are also valid empty keys.
 Return type

get_keys
()[source]¶ Get the keys of all onebody wavefunctions forming the manybody state.
 Returns
keys – List of all state identifier keys present in the solver.
 Return type

get_onebody_state
(key, root=0)[source]¶ Get the onebody wavefunction corresponding to its key.
 Parameters
key (dict key) – Idendentifier key of the state.
root (int or None, optional) – MPI return rank on which to return the state. If
root
is an integer, it must be in the range of valid MPI ranks0 <= root < self.comm.size
. In that case, the state is returned only on that specific MPI rank whererank == root
, whereas the result is None on all other MPI ranks withrank != root
. Alternatively, ifroot
is None, the calculated state is returned on all MPI ranks. By default, the state is returned on MPI rank zero only.
 Returns
state – onebody wavefunction
 Return type