Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HEOM Parity support #2261

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1a2e5d0
Added FitBath and OhmicBath classes, fix spelling on solver_base
gsuarezr Oct 11, 2023
27ed772
notebooks as example
gsuarezr Oct 11, 2023
3ba219d
formatting
gsuarezr Oct 11, 2023
40a914d
added tests
gsuarezr Oct 13, 2023
3edecc0
Merge branch 'qutip:master' into master
gsuarezr Oct 19, 2023
f51033a
Make fit classes inherit, which broke tests, refactored functions and…
gsuarezr Oct 19, 2023
c880375
minor refactoring
gsuarezr Oct 24, 2023
7080102
replaced tests to match new classes
gsuarezr Oct 24, 2023
390c596
added parity support changed prints to __str__
gsuarezr Oct 25, 2023
fa563b5
deleted innecessary comments and code
gsuarezr Oct 25, 2023
c6a7d4e
Rewrote summary methods,added comments,eliminated unnecessary code
gsuarezr Oct 26, 2023
5c03d92
Rewrote summary methods,added comments,eliminated unnecessary code
gsuarezr Oct 26, 2023
5f0003c
moving parity to another branch
gsuarezr Oct 27, 2023
22cdee6
Merge branch 'qutip:master' into parity
gsuarezr Oct 27, 2023
f16d52d
added parity support
gsuarezr Oct 27, 2023
fc794bc
Merge branch 'qutip:master' into parity
gsuarezr Nov 9, 2023
26c49ed
moved example notebook to tutorials
gsuarezr Nov 8, 2023
9699687
removed mpmath
gsuarezr Nov 9, 2023
77f23a4
removed bosonic fitting tests
gsuarezr Nov 9, 2023
2c74559
removed changes from other branches
gsuarezr Nov 9, 2023
b9d8093
codeclimate sugestions
gsuarezr Nov 9, 2023
3fe627e
refactoring according to codeclimate
gsuarezr Nov 13, 2023
65a8299
added changelog entry
gsuarezr Nov 13, 2023
ca7095a
revert unrelated changes
gsuarezr Nov 27, 2023
a79a305
revert unrelated changes 2
gsuarezr Nov 27, 2023
5ee816a
revert unrelated changes 3
gsuarezr Nov 27, 2023
aaa45f1
revert unrelated changes 4
gsuarezr Nov 27, 2023
27c878d
Merge branch 'qutip:master' into parity
gsuarezr Dec 11, 2023
4172aef
Merge branch 'qutip:master' into parity
gsuarezr Dec 19, 2023
4b5cfc1
make odd parity keyword only
gsuarezr Dec 20, 2023
e7f1360
Apply suggestions from code review
gsuarezr Dec 20, 2023
87a23a0
Merge branch 'qutip:master' into parity
gsuarezr Jan 15, 2024
01058af
added simple test
gsuarezr Feb 11, 2024
dd1f104
check broken tests
gsuarezr Feb 15, 2024
adaca75
daily
gsuarezr Feb 19, 2024
a5ce6cc
set use_mkl=False so tests pass for python 3.10
gsuarezr Feb 19, 2024
ce69039
code review suggestions
gsuarezr Mar 4, 2024
e004b44
Merge branch 'master' into parity
gsuarezr Mar 4, 2024
07d1c38
missed import
gsuarezr Mar 4, 2024
41ddaba
missed comma
gsuarezr Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
38 changes: 28 additions & 10 deletions qutip/solver/heom/bofin_solvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,17 @@ class HEOMSolver(Solver):
If multiple baths are given, they must all be either fermionic
or bosonic baths.

odd_parity : Bool
For fermionic baths only. Default is "False". If set to "True",
the RHS construction differs slightly (it implies the RHS is acting on
an initial density operator which has odd parity in terms of its
representation in fermionic annhilation operators). In other words, a
state with a well defined number of excitations has even parity, but
one with superpositions of the number of excitations has odd parity.
This is normally prohibited in 'normal' electronic systems, where
charge is conserved, but is useful for the construction of
electron spectrum (under linear response assumptions).

Copy link
Member

@nwlambert nwlambert Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simon asked us to help distill and clarify this a little bit; how about:

" For fermionic baths only. Default is "False". "Parity" refers to the parity of the initial system state used with the HEOM. An example of an odd parity state is one made from applying an odd number of fermionic creation operators to a physical density operator. Physical systems have even parity, but allowing the generalization to odd-parity states allows one to calculate useful physical quantities like the system power spectrum or density of states. The form of the HEOM differs depending on the parity of the initial system state, so if this option is set to "True", a different RHS is constructed, which can then be used with a system state of odd parity. "

max_depth : int
The maximum depth of the heirarchy (i.e. the maximum number of bath
exponent "excitations" to retain).
Expand Down Expand Up @@ -602,9 +613,9 @@ class HEOMSolver(Solver):
"state_data_type": "dense",
}

def __init__(self, H, bath, max_depth, *, options=None):
def __init__(self, H, bath, max_depth, odd_parity=False, *, options=None):
gsuarezr marked this conversation as resolved.
Show resolved Hide resolved
_time_start = time()

self.odd_parity = odd_parity
gsuarezr marked this conversation as resolved.
Show resolved Hide resolved
if not isinstance(H, (Qobj, QobjEvo)):
raise TypeError("The Hamiltonian (H) must be a Qobj or QobjEvo")

Expand Down Expand Up @@ -745,6 +756,16 @@ def _grad_prev_bosonic(self, he_n, k):
)
return op

def _get_signs(self, n_excite, n_excite_before_m):
gsuarezr marked this conversation as resolved.
Show resolved Hide resolved
"""gets the correct signs according to the parity"""
if self.odd_parity:
sign1 = (-1) ** (n_excite)
sign2 = (-1) ** (n_excite_before_m + 1)
else:
sign1 = (-1) ** (n_excite + 1)
sign2 = (-1) ** (n_excite_before_m)
return sign1, sign2

def _grad_prev_fermionic(self, he_n, k):
ck = self.ados.ck
he_fermionic_n = [
Expand All @@ -753,11 +774,10 @@ def _grad_prev_fermionic(self, he_n, k):
]

n_excite = sum(he_fermionic_n)
sign1 = (-1) ** (n_excite + 1)

gsuarezr marked this conversation as resolved.
Show resolved Hide resolved
n_excite_before_m = sum(he_fermionic_n[:k])
sign2 = (-1) ** (n_excite_before_m)

sign1, sign2 = self._get_signs(
n_excite=n_excite, n_excite_before_m=n_excite_before_m
)
sigma_bar_k = k + self.ados.sigma_bar_k_offset[k]

if self.ados.exponents[k].type == BathExponent.types["+"]:
Expand Down Expand Up @@ -800,11 +820,9 @@ def _grad_next_fermionic(self, he_n, k):
for i, exp in zip(he_n, self.ados.exponents)
]
n_excite = sum(he_fermionic_n)
sign1 = (-1) ** (n_excite + 1)

n_excite_before_m = sum(he_fermionic_n[:k])
sign2 = (-1) ** (n_excite_before_m)

sign1, sign2 = self._get_signs(
n_excite=n_excite, n_excite_before_m=n_excite_before_m)
if self.ados.exponents[k].type == BathExponent.types["+"]:
if sign1 == -1:
op = _data.mul(self._s_pre_minus_post_Q[k], -1j * sign2)
Expand Down