Skip to content

Commit 752370c

Browse files
MesoHOPS 1.4.3
1. Fixed a bug in which integer overflow was setting flux up along modes with depth 15 to 0, terminating adaptive auxiliary basis construction. 2. Added a test that confirms the full auxiliary basis is eventually constructed when the derivative error bound is sufficiently small. As a result, the maximum hierarchy depth of 255 is now compatible with adaptivity.
1 parent 4f1ce75 commit 752370c

File tree

2 files changed

+61
-2
lines changed

2 files changed

+61
-2
lines changed

mesohops/dynamics/hops_basis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,13 +720,13 @@ def M2_mode_from_state(self):
720720
@property
721721
def K2_aux_by_mode(self):
722722
# Construct the array values of k[n] in the space of [mode, aux]
723-
K2_aux_by_mode = np.zeros([self.n_hmodes, self.n_hier], dtype=np.uint8)
723+
K2_aux_by_mode = np.zeros([self.n_hmodes, self.n_hier], dtype=np.uint16)
724724
for aux in self.hierarchy.auxiliary_list:
725725
array_index = np.array([list(self.list_absindex_mode).index(mode)
726726
for (mode, value) in aux.tuple_aux_vec
727727
if mode in self.list_absindex_mode],
728728
dtype=int)
729-
array_values = [np.uint8(value) for (mode, value) in aux.tuple_aux_vec
729+
array_values = [np.uint16(value) for (mode, value) in aux.tuple_aux_vec
730730
if mode in self.list_absindex_mode]
731731
K2_aux_by_mode[array_index, aux._index] = array_values
732732
return K2_aux_by_mode

mesohops/testing/test_hops_basis.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,3 +1468,62 @@ def test_M2_mode_from_state():
14681468
)
14691469

14701470
assert np.allclose(M2_mode_from_state_test, M2_mode_from_state_known)
1471+
1472+
1473+
def test_hier_max_adaptive():
1474+
"""
1475+
Tests that auxiliaries are constructed in full for calculations with small
1476+
delta_A up to the maximum hierarchy depth of 255 using a monomer model.
1477+
"""
1478+
nsite = 1
1479+
e_lambda = 300
1480+
gamma = 60
1481+
temp = 300
1482+
hs = np.zeros([1, 1], np.complex128)
1483+
(g_0, w_0) = bcf_convert_sdl_to_exp(e_lambda, gamma, 0, temp)
1484+
gw_sysbath = [[g_0, w_0]]
1485+
lop_list = np.ones([1, 1, 1])
1486+
1487+
sys_param = {
1488+
"HAMILTONIAN": hs,
1489+
"GW_SYSBATH": gw_sysbath,
1490+
"L_HIER": lop_list,
1491+
"L_NOISE1": lop_list,
1492+
"ALPHA_NOISE1": bcf_exp,
1493+
"PARAM_NOISE1": gw_sysbath,
1494+
}
1495+
1496+
eom_param = {"EQUATION_OF_MOTION": "NORMALIZED NONLINEAR"}
1497+
1498+
noise_param = {
1499+
"SEED": None,
1500+
"MODEL": "ZERO",
1501+
"TLEN": 3000.0,
1502+
"TAU": 0.5,
1503+
}
1504+
1505+
integrator_param = {
1506+
"INTEGRATOR": "RUNGE_KUTTA",
1507+
'EARLY_ADAPTIVE_INTEGRATOR': 'INCH_WORM',
1508+
'EARLY_INTEGRATOR_STEPS': 5,
1509+
'INCHWORM_CAP': 5,
1510+
'STATIC_BASIS': None
1511+
}
1512+
1513+
psi_0 = np.array([1.0], dtype=np.complex128)
1514+
psi_0 = psi_0 / np.linalg.norm(psi_0)
1515+
1516+
hops_ad = HOPS(
1517+
sys_param,
1518+
noise_param=noise_param,
1519+
hierarchy_param={"MAXHIER": 255},
1520+
eom_param=eom_param,
1521+
integration_param=integrator_param,
1522+
)
1523+
# Set delta_a to floating point minimum and run until all auxiliaries can be populated
1524+
hops_ad.make_adaptive(1e-323, 0, 1)
1525+
hops_ad.initialize(psi_0)
1526+
assert hops_ad.basis.n_hier < 256
1527+
1528+
hops_ad.propagate(300, 1.0)
1529+
assert hops_ad.basis.n_hier == 256

0 commit comments

Comments
 (0)