Skip to content

Commit

Permalink
Merge pull request qutip#2512 from Ericgig/misc.fix_merge_conflict
Browse files Browse the repository at this point in the history
Merge master into `dev.major`
  • Loading branch information
Ericgig authored Aug 19, 2024
2 parents 7bb0603 + e98b666 commit 9f412f5
Show file tree
Hide file tree
Showing 41 changed files with 1,016 additions and 463 deletions.
1 change: 1 addition & 0 deletions doc/changes/2261.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It adds odd parity support to HEOM's fermionic solver
1 change: 1 addition & 0 deletions doc/changes/2484.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This change makes expm, cosm, sinm work with jax.
1 change: 1 addition & 0 deletions doc/changes/2491.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix stochastic solver step method
1 change: 1 addition & 0 deletions doc/changes/2493.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support measurement statistics for `jax` and `jaxdia` dtypes
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ def qutip_version():
'CoefficientLike': 'CoefficientLike',
'ElementType': 'ElementType',
'QobjEvoLike': 'QobjEvoLike',
'EopsLike': 'EopsLike',
'LayerType': 'LayerType',
'ArrayLike': 'ArrayLike'
}
Expand Down
77 changes: 67 additions & 10 deletions qutip/core/blochredfield.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
import os
import inspect
import numpy as np
from qutip.settings import settings as qset
from typing import overload

from qutip.settings import settings as qset
from . import Qobj, QobjEvo, liouvillian, coefficient, sprepost
from ._brtools import SpectraCoefficient, _EigenBasisTransform
from .cy.coefficient import InterCoefficient, Coefficient
from ._brtensor import _BlochRedfieldElement

from ..typing import CoeffProtocol

__all__ = ['bloch_redfield_tensor', 'brterm']


def bloch_redfield_tensor(H, a_ops, c_ops=[], sec_cutoff=0.1,
fock_basis=False, sparse_eigensolver=False,
br_dtype='sparse'):
@overload
def bloch_redfield_tensor(
H: Qobj,
a_ops: list[tuple[Qobj, Coefficient | str | CoeffProtocol]],
c_ops: list[Qobj] = None,
sec_cutoff: float = 0.1,
fock_basis: bool = False,
sparse_eigensolver: bool = False,
br_dtype: str = 'sparse',
) -> Qobj: ...

@overload
def bloch_redfield_tensor(
H: Qobj | QobjEvo,
a_ops: list[tuple[Qobj | QobjEvo, Coefficient | str | CoeffProtocol]],
c_ops: list[Qobj | QobjEvo] = None,
sec_cutoff: float = 0.1,
fock_basis: bool = False,
sparse_eigensolver: bool = False,
br_dtype: str = 'sparse',
) -> QobjEvo: ...

def bloch_redfield_tensor(
H: Qobj | QobjEvo,
a_ops: list[tuple[Qobj | QobjEvo, Coefficient | str | CoeffProtocol]],
c_ops: list[Qobj | QobjEvo] = None,
sec_cutoff: float = 0.1,
fock_basis: bool = False,
sparse_eigensolver: bool = False,
br_dtype: str = 'sparse',
) -> Qobj | QobjEvo:
"""
Calculates the Bloch-Redfield tensor for a system given
a set of operators and corresponding spectral functions that describes the
Expand Down Expand Up @@ -46,10 +75,10 @@ def bloch_redfield_tensor(H, a_ops, c_ops=[], sec_cutoff=0.1,
.. code-block::
a_ops = [
(a+a.dag(), ('w>0', args={"w": 0})),
(a+a.dag(), coefficient('w>0', args={"w": 0})),
(QobjEvo(a+a.dag()), 'w > exp(-t)'),
(QobjEvo([b+b.dag(), lambda t: ...]), lambda w: ...)),
(c+c.dag(), SpectraCoefficient(coefficient(array, tlist=ws))),
(c+c.dag(), SpectraCoefficient(coefficient(ws, tlist=ts))),
]
Expand Down Expand Up @@ -101,9 +130,37 @@ def bloch_redfield_tensor(H, a_ops, c_ops=[], sec_cutoff=0.1,
False, br_dtype=br_dtype)[0]
return R, H_transform.as_Qobj()


def brterm(H, a_op, spectra, sec_cutoff=0.1,
fock_basis=False, sparse_eigensolver=False, br_dtype='sparse'):
@overload
def brterm(
H: Qobj,
a_op: Qobj,
spectra: Coefficient | CoeffProtocol | str,
sec_cutoff: float = 0.1,
fock_basis: bool = False,
sparse_eigensolver: bool = False,
br_dtype: str = 'sparse',
) -> Qobj: ...

@overload
def brterm(
H: Qobj | QobjEvo,
a_op: Qobj | QobjEvo,
spectra: Coefficient | CoeffProtocol | str,
sec_cutoff: float = 0.1,
fock_basis: bool = False,
sparse_eigensolver: bool = False,
br_dtype: str = 'sparse',
) -> QobjEvo: ...

def brterm(
H: Qobj | QobjEvo,
a_op: Qobj | QobjEvo,
spectra: Coefficient | CoeffProtocol | str,
sec_cutoff: float = 0.1,
fock_basis: bool = False,
sparse_eigensolver: bool = False,
br_dtype: str = 'sparse',
) -> Qobj | QobjEvo:
"""
Calculates the contribution of one coupling operator to the Bloch-Redfield
tensor.
Expand Down
1 change: 1 addition & 0 deletions qutip/core/coefficient.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def _return(base, **kwargs):
np.ndarray: InterCoefficient,
scipy.interpolate.PPoly: InterCoefficient.from_PPoly,
scipy.interpolate.BSpline: InterCoefficient.from_Bspline,
numbers.Number: ConstantCoefficient,
}


Expand Down
2 changes: 1 addition & 1 deletion qutip/core/cy/coefficient.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ cdef class ConstantCoefficient(Coefficient):
"""
cdef complex value

def __init__(self, complex value):
def __init__(self, complex value, **_):
self.value = value

def replace_arguments(self, _args=None, **kwargs):
Expand Down
Loading

0 comments on commit 9f412f5

Please sign in to comment.