No project description provided
Project description
struqture-qutip-interface
An interface that can transform struqture spin objects to qutip objects for simulation purposes.
This project is in the alpha stage, documentation is minimal at the moment and breaking changes may occur.
Example
from struqture_qutip_interface import SpinQutipInterface, SpinOpenSystemQutipInterface
import qutip as qt
import numpy as np
from struqture_py.spins import (
SpinLindbladOpenSystem,
SpinLindbladNoiseSystem,
SpinHamiltonianSystem,
PauliProduct,
DecoherenceProduct
)
number_spins = 2
# Creating a Spin Hamiltonian in struqture
hamiltonian = SpinHamiltonianSystem(number_spins)
for i in range(number_spins):
hamiltonian.set(PauliProduct().z(i), 1.0)
for i in range(number_spins-1):
hamiltonian.set(PauliProduct().x(i).x(i+1), 0.5)
# Creating noise terms in struqture
noise = SpinLindbladNoiseSystem(number_spins)
for i in range(number_spins):
noise.set((DecoherenceProduct().z(i), DecoherenceProduct().z(i)), 0.001)
# Combining noise terms and Hamiltonian to an open system
noisy_system = SpinLindbladOpenSystem.group(hamiltonian, noise)
# Transforming the open system to a qutip superoperator
(coherent_part, noisy_part) = SpinOpenSystemQutipInterface.open_system_to_qutip(noisy_system)
liouFull = coherent_part + noisy_part
# Setting up separate operators that can be measured
qi = SpinQutipInterface()
op_Z0 = PauliProduct().set_pauli(0, "Z")
op_Z1 = PauliProduct().set_pauli(1, "Z")
op_Z0Z1 = PauliProduct().set_pauli(0, "Z").set_pauli(1, "Z")
endianess = 'little' #'big'
qt_Z0 = qi.pauli_product_to_qutip(op_Z0, number_spins, endianess=endianess)
qt_Z1 = qi.pauli_product_to_qutip(op_Z1, number_spins, endianess=endianess)
qt_Z0Z1 = qi.pauli_product_to_qutip(op_Z0Z1, number_spins, endianess=endianess)
# Setting up an initial density matrix
init_spin = []
for i in range(number_spins):
init_spin.append(qt.basis(2, 1)) # initially all spins excited
init_spin_tensor = qt.tensor(list(reversed(init_spin)))
psi0 = init_spin_tensor * init_spin_tensor.dag()
# master-equation solver
time_axis = np.linspace(0, 10, 100)
result = qt.mesolve(liouFull,
psi0,
time_axis,
[], # c_op_list is left empty, since noise is already in liouFull
[qt_Z0, qt_Z1, qt_Z0Z1] # operators to be measured
).expect
time_evolution_Z0 = np.real(result[0])
time_evolution_Z1 = np.real(result[1])
time_evolution_Z0Z1 = np.real(result[2])
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file struqture_qutip_interface-0.2.0.tar.gz
.
File metadata
- Download URL: struqture_qutip_interface-0.2.0.tar.gz
- Upload date:
- Size: 91.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efe135da80697399c9693784ab9e599531ee94932204b69c26846f804b39918a |
|
MD5 | ce842724b8fce0f98baa0c50eeb33a24 |
|
BLAKE2b-256 | ecb9ec0f0a7698662d70ddc036e50c6059f3d4e32941a845918e0da61999bbf5 |
File details
Details for the file struqture_qutip_interface-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: struqture_qutip_interface-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45f4dc5aa0936c92979199a09b2debc040c7b98540582facb2c4770dc696966a |
|
MD5 | c768246564eb39398f14e781ab65431d |
|
BLAKE2b-256 | fe3fbe9098360e82431e81b1c40675550b8876c52eebb0c088f596f84f40e79f |