def _liouvillian(hamiltonian, gammas, lindblad_operators):
    """Lindbladian for a specific Hamiltonian, gammas and lindblad_operators.
    """
    liouvillian = -1j * commutator(hamiltonian)
    for gamma, op in zip(gammas, lindblad_operators):
        op_dagger = op.conjugate().T
        liouvillian += gamma * (left_right_super(op, op_dagger) \
                                - 0.5 * acommutator(np.dot(op_dagger, op)))
    return liouvillian
Beispiel #2
0
    def __init__(
            self,
            bath: Bath,
            start_time: float,
            end_time: float,
            parameters: PtTempoParameters,
            backend: Optional[Text] = None,
            backend_config: Optional[Dict] = None,
            name: Optional[Text] = None,
            description: Optional[Text] = None,
            description_dict: Optional[Dict] = None) -> None:
        """Create a PtTempo object. """
        self._backend_class, self._backend_config = \
            get_pt_tempo_backend(backend, backend_config)

        assert isinstance(bath, Bath), \
            "Argument 'bath' must be an instance of Bath."
        self._bath = bath
        self._dimension = self._bath.dimension

        assert isinstance(parameters, PtTempoParameters), \
            "Argument 'parameters' must be an instance of PtTempoParameters."
        self._parameters = parameters

        try:
            __start_time = float(start_time)
        except Exception as e:
            raise AssertionError("Start time must be a float.") from e
        self._start_time = __start_time

        try:
            __end_time = float(end_time)
        except Exception as e:
            raise AssertionError("End time must be a float.") from e
        self._end_time = __end_time

        super().__init__(name, description, description_dict)

        __coupling_comm = commutator(self._bath._coupling_operator)
        __coupling_acomm = acommutator(self._bath._coupling_operator)
        self._coupling_comm = __coupling_comm.diagonal()
        self._coupling_acomm = __coupling_acomm.diagonal()

        __num_steps = int((end_time - self._start_time)/self._parameters.dt)
        assert __num_steps >= 2, \
            "Parameter `end_time` must be more than two times steps " \
            + "larger than the parameter `start_time`!"
        self._num_steps = __num_steps

        self._backend_instance = None
        self._init_pt_tempo_backend()
Beispiel #3
0
    def __init__(self,
                 system: BaseSystem,
                 bath: Bath,
                 parameters: TempoParameters,
                 initial_state: ndarray,
                 start_time: float,
                 backend: Optional[Text] = None,
                 backend_config: Optional[Dict] = None,
                 name: Optional[Text] = None,
                 description: Optional[Text] = None,
                 description_dict: Optional[Dict] = None) -> None:
        """Create a Tempo object. """
        self._backend_class, self._backend_config = \
            get_tempo_backend(backend, backend_config)

        assert isinstance(system, BaseSystem), \
            "Argument 'system' must be an instance of BaseSystem."
        self._system = system

        assert isinstance(bath, Bath), \
            "Argument 'bath' must be an instance of Bath."
        self._bath = bath

        assert isinstance(parameters, TempoParameters), \
            "Argument 'parameters' must be an instance of TempoParameters."
        self._parameters = parameters

        try:
            __initial_state = np.array(initial_state, dtype=NpDtype)
            __initial_state.setflags(write=False)
        except Exception as e:
            raise AssertionError("Initial state must be numpy array.") from e
        assert len(__initial_state.shape) == 2, \
            "Initial state is not a matrix."
        assert __initial_state.shape[0] == \
            __initial_state.shape[1], \
            "Initial state is not a square matrix."
        self._initial_state = __initial_state
        self._dimension = self._initial_state.shape[0]

        try:
            __start_time = float(start_time)
        except Exception as e:
            raise AssertionError("Start time must be a float.") from e
        self._start_time = __start_time

        assert self._bath.dimension == self._dimension and \
            self._system.dimension == self._dimension, \
            "Hilbertspace dimensions are unequal: " \
            + "system ({}), ".format(self._system.dimension) \
            + "initial state ({}), ".format(self._dimension) \
            + "and bath coupling ({}), ".format(self._bath.dimension)

        super().__init__(name, description, description_dict)

        __coupling_comm = commutator(self._bath._coupling_operator)
        __coupling_acomm = acommutator(self._bath._coupling_operator)
        self._coupling_comm = __coupling_comm.diagonal()
        self._coupling_acomm = __coupling_acomm.diagonal()

        self._dynamics = None
        self._backend_instance = None

        self._init_tempo_backend()