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

StepCount setting #233

Open adriendilonardo opened 1 year ago

adriendilonardo commented 1 year ago

Platform and Environment

What is happening?

StepCount is being increased by 1 whenever there is a time dependent sweep

How can we reproduce the issue?

import quanguru as qg
import numpy as np

qub = qg.Qubit(frequency=wq, alias='qubit')
qub.initialState = qg.identity(qub.dimension)

qub.stepCount = 10
qub.totalTime = 1

omegaSweep = qub.simulation.timeDependency.createSweep(
    system=qub,
    sweepKey='frequency',
    sweepList=5*nd.array(qub.timeList),
    alias="fSweep"
)

stepCountBefore = qub.stepCount

qub.run()

print(stepCountBefore == qub.stepCount)

I've located the error to this code block in modularSweep.py under timeDependent function

qSim._timeBase__stepCount._value = qSim.timeDependency.indMultip # pylint: disable=protected-access
for pro, sim in qSim.subSys.items(): # pylint: disable=protected-access
    sim.simulation._timeBase__stepCount._value = sim.simulation.timeDependency.indMultip # pylint: disable=protected-access
    pro.simulation._timeBase__stepCount._value = pro.simulation.timeDependency.indMultip # pylint: disable=protected-access

The following line will also need to be changed in timeEvolDefault:

for ind in range(qSim.stepCount):

to either

for ind in range(qSim.stepCount+1):

or

for ind in range(qSim.timeDependency.indMultip):

What should happen?

The stepCount shouldn't change

Please put error messages in this block

No response

Any suggestions?

No response