xxzchain.core package

See also

Before reference guide, our calculation is based on NumPy. So, if you need a detail of computation, please visit website of NumPy. Indeed, every np which appears below documentation indicates Numpy module.

Classes

xxzchain.core.System

class xxzchain.core.System(size, name=None, dtype=<class 'numpy.float64'>, **kwarg)[source]

A environment object of whole calculation.

Parameters:
  • size (integer) – Size of the new system.
  • name (string) – Description of parameter name.
  • dtype (np.dtype) – Description of parameter dtype.

Please make sure your system’s size that you want to use. Support 1 ~ 32 lattice size. You can see the summery of your system through ‘System.tree’.

Note

In many calculation, we represent spin configuration as binary. Generally, 4bytes-integer(int) is consist of 32 bits. It’s the reason why this package support system size below 32.

range

Equivalent to range(size).

Type:range (built-in)
Odtype

Data type of operator’s elements.

Type:np.complex128
Hamiltonian

Hamiltonian operator of this system. Only operator which is defined on this system can be Hamiltonian.

Type:xxzchian.core.Operator

Note

xxzchain.core.Basis.energy and xxzchain.core.State.time_evolving() or xxzchain.core.State.time_evolving_states() will be affected by this property.

data_list()[source]

List of name of data which is stored.

Returns:List of name of data.
Return type:list
delete(name, force=False)[source]

Delete saved data.

Parameters:
  • name (str) – name of data which you want to delete.
  • force (boolean) – If Ture, method will delete data without asking.
Raises:

KeyError – If the data which is given name doesn’t exist.

function_list()[source]

List of name of function stored.

Returns:List of name of function.
Return type:list
get_basis(*arg, **kwarg)[source]

Get basis of given simultaneous eigenvalue sector.

Parameters:
  • *arg (Integer) – Simultaneous eigenvalues of basis which you want to get in order (N[, K[, P[, X]]]).
  • **kwarg (‘key( Operator ) = value( eigenvalue )’) –

    Specific kind of eigenvalues.

    i.e.)
    get_basis(N = 1), get_basis(n = 1, k = 0), get_basis(k = 0, p = 1)
Returns:

Basis object to manage specific Hilbert space sector.

Return type:

xxzchain.core.Basis

Note

This method automatically search basis within data. if given sector is not found, then system will calculate.

positional argument : eigenvalues in order of (N, K, P, X)

keywork argument : N = n, K = k, P = p, X = x (small and capital letter can be used for identifying each eigenvale.)

get_data(key)[source]

Getting data with its key.

Parameters:key (str) – Data’s name when you save it.
Returns:Data which is named as key.
Return type:np.ndarray
Raises:KeyError – If there is no data that has name as key.
get_full_sector()[source]

Access to full sector of this system..

Returns:Basis object of full Hilbert space.
Return type:xxzchain.core.Basis
get_function(key)[source]

Getting python function with its key.

Parameters:key (str or Integer) – Function’s name when you save it. Or, order of saving.
Returns:Python function object will be returned.
Return type:function
Raises:KeyError – If there is no function that has name as key. Or, out of index.
get_function_script(key)[source]

Getting python function script with its key.

Parameters:key (str or Integer) – Function’s name when you save it. Or, order of saving.
Returns:Function’s source script.
Return type:str
Raises:KeyError – If there is no function that has name as key. Or, out of index.
get_operator(op_name)[source]

Getting operator with its name.

Parameters:op_name (str) – Operator’s name that you’ve set. You can find list of operator with xxzchain.core.System.operator_list().
Returns:The operator which is named as st_name.
Return type:xxzchain.core.Operator
Raises:KeyError – If there is no operator that has name as op_name.

Warning

To access to operator with operators name. before that, the operator name must be set on system.

get_state(st_name)[source]

Getting operator with its name.

Parameters:st_name (str) – Name of state that you’ve set. You can find list of state with xxzchain.core.System.state_list().
Returns:The state which is named as st_name.
Return type:xxzchain.core.State
Raises:KeyError – If there is no operator that has name as st_name.

Warning

To access to state with its name, the state must have name on system.

initialize(path=None, force=False)[source]

Specific initializing method of this object.

Parameters:
  • path (str) – The path that current system will be saved on.
  • force (bool) – If force == True, system will ignore FileExistsError.

Our system use I/O system with HDF5 File Format to save calculation enviroment. every progress will be saved on path (i.e. Basis, Operator, State).

Note

If force argument is False and there is hdf5 file made by system earlier, this method will ask whether load that file or not. If you answer ‘yes’, this method will be equivalent to xxzchain.lib.load_system().

load(path, print_tree=True)[source]

Load system object from .hdf5 (experimental).

Parameters:
  • path (string) – The File to read. Unfortunately, file-like object is not supported.
  • print_tree (bool, optional) – Skipping show tree when the system loaded. If you try to load multiple system, tree will make bunch of text.
Raises:

IOError – If the input file path does not valid, or cannot be read.

This method is not convenient to load system. We recommend using xxzchain.lib.load_system()

load_operators_to_var(op_name_list=None, obj=None)[source]

Stack given operators to namespace(variables).

Parameters:
  • op_name_list (list of str) – The name list of operator which you want to load.
  • obj (dict) – The namespace or dictionary-like object to define operators. Default value is globals()
operator_list()[source]

List of name of operator which is stored.

Returns:List of name of operator.
Return type:list
plot(data_path, *arg, **kwarg)[source]

Plotting method for saved data. (experimental)

Parameters:
  • data_path (str) – Name of data which you want to plot.
  • arg, ** kwarg (*) – Same arg and kwarg with matplotlib.pyplot.plot.

See also

This method is using matplotlib.pyplot.plot. If you need more detail for plotting, See reference.

print_spin(value)[source]

Print spin-configuration to binary representation.

Parameters:value (Integer) – Representation of spin-configuration.

This method will print spinstate with 0(null site, down-spin),1(particle site, up-spin) of give integer format state onto console. If you put vanishing state as argument, method will print ‘Vanishing’

save(name=None, data_array=None)[source]

Save system or specific data into file.

Parameters:
  • name (str) – Name of data which will be saved. After save data, you can access data with this name.
  • data_array (array-like object) – Data which will be saved.
state_list()[source]

List of name of state which is stored.

Returns:List of name of state.
Return type:list
tree

Short summary of current system.

Note

If you run xxzchain.core.System.initialize(), you will see output of this property.


xxzchain.core.Basis

class xxzchain.core.Basis(system, N=None, K=None, P=None, X=None, symmetry=None)[source]

Class ‘basis’ for Hilbert space sector of system.

address

return address dict of this basis

energy

The energy property.

load(N, K, P, X)[source]

load from hdf5 based on given symmetry factor.

trace(operator, eigen=True)[source]

return Tr{ O } on this sector(s). basically, calculate eigenvalues and sum over.


xxzchain.core.Operator

class xxzchain.core.Operator(system, name=None, prefix=None, group=None, use_gpu=False)[source]
acton(x)[source]

x is array of bitwise state(int type). return is another state(int type). default is Identity you can also implement of your own operator with keeping return format

expectation(state)[source]

a funciton of getting expectation value of this operator based on given state.

Parameters:state (xxzchain.core.State) – state which will be calculated with.
Returns:array of \(\langle \psi | \hat O | \psi \rangle\)
Return type:np.float64 or (array)
get_eigenstates(basis, save=True)[source]

return State made up with eigenvectors of matrix of this Operator on given basis.

get_eigenvalue(basis, save=True)[source]

return eigenvalues of matrix of this Operator on given basis.

get_eigenvectors(basis, save=True)[source]

return eigenvectors of matrix of this Operator on given basis.

get_matrix(basis, eigen=False, keep=False, use_gpu=False)[source]

return matrix form of Operator as given basis

latex

The latex property.

trace(basis_set, func=<function Operator.<lambda>>, eigen=True)[source]

return Tr{ f( O ) } on given sector(s).


xxzchain.core.State

class xxzchain.core.State(basis, coef, eigen=False, name=None)[source]