Giter Club home page Giter Club logo

struqture-qutip-interface's Introduction

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])

struqture-qutip-interface's People

Contributors

dberthault avatar dgupta-hqs avatar kbarkhqs avatar mlodi-hqs avatar nfwvogt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.