"""
import os
import numpy as np
import numpy.matlib as mat
from numpy.matlib import kron
from scipy.sparse import csr_matrix
import matplotlib.pyplot as plt
import datetime
from scipy.optimize import check_grad
from numpy.testing import (
    assert_, assert_almost_equal, run_module_suite, assert_equal)

#QuTiP
from qutip import Qobj, identity, sigmax, sigmay, sigmaz, tensor
import qutip.logging_utils as logging
logger = logging.get_logger()
#QuTiP control modules
import qutip.control.pulseoptim as cpo
import qutip.control.pulsegen as pulsegen
from qutip.qip.algorithms import qft

example_name = 'QFT-dump'
log_level=logging.INFO
# ****************************************************************
# Define the physics of the problem
Sx = sigmax()
Sy = sigmay()
Sz = sigmaz()
Si = 0.5*identity(2)

# Drift Hamiltonian
Esempio n. 2
0
# NumPy/SciPy
import numpy as np
import scipy.sparse as sp
# Conditionally import CVXPY
try:
    import cvxpy
except ImportError:
    cvxpy = None

Complex = namedtuple('Complex', ['re', 'im'])

from qutip.tensor import tensor_swap
from qutip.operators import qeye

from qutip.logging_utils import get_logger
logger = get_logger()


def complex_var(rows=1, cols=1, name=None):
    return Complex(re=cvxpy.Variable((rows, cols),
                                     name=(name + "_re") if name else None),
                   im=cvxpy.Variable((rows, cols),
                                     name=(name + "_im") if name else None))


def herm(*Xs):
    return sum([[X.re == X.re.T, X.im == -X.im.T] for X in Xs], [])


def pos_noherm(*Xs):
    constraints = [cvxpy.bmat([[X.re, -X.im], [X.im, X.re]]) >> 0 for X in Xs]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 31 13:14:40 2019

@author: fred
"""
import datetime
import matplotlib.pyplot as plt
import numpy as np
from qutip import cnot, sigmax, sigmay, identity, sigmaz, tensor
#from qutip.control import *
import qutip.logging_utils as logging
logger = logging.get_logger()
log_level = logging.INFO
import qutip.control.pulseoptim as cpo
import qutip.control.pulsegen as pulsegen

example_name = 'CNOT'

## MODEL
Sx = sigmax()
Sy = sigmay()
Sz = sigmaz()
Si = 0.5 * identity(2)
H_d = 0.5 * (tensor(Sx, Sx) + tensor(Sy, Sy) + tensor(Sz, Sz)
             )  # Drift Hamiltonian
H_c = [tensor(Sx, Si),
       tensor(Sy, Si),
       tensor(Si, Sx),
       tensor(Si, Sy)]  # The (four) control Hamiltonians
Esempio n. 4
0
import numpy as np

# Conditionally import CVXPY
try:
    import cvxpy
except:
    cvxpy = None

Complex = namedtuple('Complex', ['re', 'im'])

from qutip.qip.gates import swap
from qutip.tensor import tensor_swap
from qutip.operators import qeye

from qutip.logging_utils import get_logger
logger = get_logger()

def complex_var(rows=1, cols=1, name=None):
    return Complex(
        re=cvxpy.Variable(rows, cols, name=(name + "_re") if name else None),
        im=cvxpy.Variable(rows, cols, name=(name + "_im") if name else None)
    )    


def herm(*Xs):
    return sum([
        [X.re == X.re.T, X.im == -X.im.T]
        for X in Xs
    ], [])