CirQuS-UTS / QuanGuru

QuanGuru (pronounced Kangaroo) is a Python library for numerical modelling of quantum systems. It is still under-development, and it consists of tools for numerical simulations of Quantum systems.
BSD 3-Clause "New" or "Revised" License
5 stars 7 forks source link

First simulation in a sweep of cavity dimension just copies the value of the last simulation in the sweep #265

Closed github-actions[bot] closed 2 months ago

github-actions[bot] commented 2 months ago

closes #264

adriendilonardo commented 2 months ago

The issue is not arising from the results of the last iteration being copy-pasted into the results for the first iteration, but rather a result of the sweep index starting from -1 (e.g. sweepIndex follows -1, 0, 1, 2, ..., len-3, len-2). This means that for the following sweepFunction defining the action of the sweep:

def cavity_sweep_func(sweep):
    val = sweep.sweepList[sweep._sweepIndex]
    H_cavity.dimension = val
    ...

The sweep starts using the last value of the sweepList, and then goes back to the start.

I'm not sure if this is a bug or intended functionality.

adriendilonardo commented 2 months ago

It appears that this isn't a bug. The attribute/property that is expected to be used to access the sweepIndex is sweep.index instead of sweep._sweepIndex:

    @property
    def index(self):
        r"""
        returns ``self._sweepIndex + 1``. reason for +1 is explained in :py:attr:`~_sweepIndex`. There is no setter,
        the value of _sweepIndex is updated by the :meth:`~runSweep` and is an internal process.
        """
        return self._sweepIndex + 1