Quanlse/QHamiltonian.py
def simulate(self, job: QJob = None, state0: ndarray = None, recordEvolution: bool = False, shot: int = None,
                 isOpen: bool = False, jobList: QJobList = None, refreshCache: bool = True, accelerate: bool = False,
                 adaptive: bool = False, tolerance: float = 0.01) -> QResult:
        """
        Calculate the unitary evolution operator with a given Hamiltonian. This function supports
        both single-job and batch-job processing.

        To activate acceleration, please install ``Numba`` JIT compiler, please visit its official website
        https://numba.pydata.org/ for more details.

        :param job: the QJob object to simulate.
        :param state0: the initial state vector. If None is given, this function will return the time-ordered
                       evolution operator, otherwise returns the final state vector.
        :param recordEvolution: the detailed procedure will be recorded if True
        :param shot: return the population of the eigenstates when ``shot`` is provided
        :param isOpen: simulate the evolution using Lindblad equation
        :param jobList: a job list containing the waveform list
        :param refreshCache: it will neither clear nor rebuild cache if refreshCache is set to be True
        :param adaptive: use the adaptive solver if True
        :param tolerance: the greatest error of approximation for the adaptive solver
        :param accelerate: use numba expm if true

        :return: result dictionary (or a list of result dictionaries when ``jobList`` is provided)

        This function does provide the option of simulating on local devices. However, Quanlse also provides
        cloud computing services which are significantly faster.

        **Example 1** (single-job processing):

        If ``jobList`` is None, the waveforms in ham will be used for simulation, and return a result dictionary.

        .. code-block:: python

                result = ham.simulate()

        **Example 2** (batch-job processing):

        If ``jobList`` is not None, simulation will use the waveform list for batch-job processing provided in
        jobList, and return a list of result dictionaries.

        .. code-block:: python

                result = ham.simulate(ham, jobList=jobs)

        Here, jobs is a QJobList object, indicating the the waveforms to be used.
        """

        resultList = QResult("built-in simulator")

        if jobList is None:
            jobList = self.createJobList()
            if job is None:
                jobList.addJob(self.job)
            else:
                jobList.addJob(job)

        # Transverse all the jobs
        _tmpHam = copy.deepcopy(self)
        for waveList in jobList.jobs:
            # Clear all waves
            _tmpHam.job.clearWaves()
            _tmpHam.job.LO = waveList.LO
            # Add waves in current job
            _tmpHam.job.appendJob(waveList)
            # Build cache
            if refreshCache:
                _tmpHam.buildCache()
            # Start calculation
            if isOpen:
                if not adaptive:
                    from Quanlse.Utils.ODESolver import solverOpenSystem
                    result = solverOpenSystem(_tmpHam, state0=state0, recordEvolution=recordEvolution,
                                              accelerate=accelerate)
                else:
                    raise Error.ArgumentError("Adaptive solver is not available when solving open system.")
            else:
                if not adaptive:
                    from Quanlse.Utils.ODESolver import solverNormal
                    result = solverNormal(_tmpHam, state0=state0, shot=shot, recordEvolution=recordEvolution,
                                          accelerate=accelerate)
                else:
                    from Quanlse.Utils.ODESolver import solverAdaptive
                    result = solverAdaptive(_tmpHam, state0=state0, shot=shot, tolerance=tolerance,
                                            accelerate=accelerate)
            resultList.append(result)
            if refreshCache:
                self.clearCache()
        return resultList

        Calculate the unitary evolution operator with a given Hamiltonian. This function supports
        both single-job and batch-job processing.

        To activate acceleration, please install ``Numba`` JIT compiler, please visit its official website
        https://numba.pydata.org/ for more details.

        :param job: the QJob object to simulate.
        :param state0: the initial state vector. If None is given, this function will return the time-ordered
                       evolution operator, otherwise returns the final state vector.
        :param recordEvolution: the detailed procedure will be recorded if True
        :param shot: return the population of the eigenstates when ``shot`` is provided
        :param isOpen: simulate the evolution using Lindblad equation
        :param jobList: a job list containing the waveform list
        :param refreshCache: it will neither clear nor rebuild cache if refreshCache is set to be True
        :param adaptive: use the adaptive solver if True
        :param tolerance: the greatest error of approximation for the adaptive solver
        :param accelerate: use numba expm if true

        :return: result dictionary (or a list of result dictionaries when ``jobList`` is provided)

        This function does provide the option of simulating on local devices. However, Quanlse also provides
        cloud computing services which are significantly faster.

        **Example 1** (single-job processing):

        If ``jobList`` is None, the waveforms in ham will be used for simulation, and return a result dictionary.

        .. code-block:: python

                result = ham.simulate()

        **Example 2** (batch-job processing):

        If ``jobList`` is not None, simulation will use the waveform list for batch-job processing provided in
        jobList, and return a list of result dictionaries.

        .. code-block:: python

                result = ham.simulate(ham, jobList=jobs)

        Here, jobs is a QJobList object, indicating the the waveforms to be used.
        
Calculate the unitary evolution operator with a given Hamiltonian. This function supports
both single-job and batch-job processing.


Calculate the unitary evolution operator with a given Hamiltonian . This function supports both single - job and batch - job processing .
def simulate(self, job: QJob = None, state0: ndarray = None, recordEvolution: bool = False, shot: int = None,
                 isOpen: bool = False, jobList: QJobList = None, refreshCache: bool = True, accelerate: bool = False,
                 adaptive: bool = False, tolerance: float = 0.01) -> QResult:
        resultList = QResult("built-in simulator")
        if jobList is None:
            jobList = self.createJobList()
            if job is None:
                jobList.addJob(self.job)
            else:
                jobList.addJob(job)
        _tmpHam = copy.deepcopy(self)
        for waveList in jobList.jobs:
            _tmpHam.job.clearWaves()
            _tmpHam.job.LO = waveList.LO
            _tmpHam.job.appendJob(waveList)
            if refreshCache:
                _tmpHam.buildCache()
            if isOpen:
                if not adaptive:
                    from Quanlse.Utils.ODESolver import solverOpenSystem
                    result = solverOpenSystem(_tmpHam, state0=state0, recordEvolution=recordEvolution,
                                              accelerate=accelerate)
                else:
                    raise Error.ArgumentError("Adaptive solver is not available when solving open system.")
            else:
                if not adaptive:
                    from Quanlse.Utils.ODESolver import solverNormal
                    result = solverNormal(_tmpHam, state0=state0, shot=shot, recordEvolution=recordEvolution,
                                          accelerate=accelerate)
                else:
                    from Quanlse.Utils.ODESolver import solverAdaptive
                    result = solverAdaptive(_tmpHam, state0=state0, shot=shot, tolerance=tolerance,
                                            accelerate=accelerate)
            resultList.append(result)
            if refreshCache:
                self.clearCache()
        return resultList
def simulate ( self , job : QJob = None , state0 : ndarray = None , recordEvolution : bool = False , shot : int = None , isOpen : bool = False , jobList : QJobList = None , refreshCache : bool = True , accelerate : bool = False , adaptive : bool = False , tolerance : float = 0.01 ) -> QResult : resultList = QResult ( "built-in simulator" ) if jobList is None : jobList = self . createJobList ( ) if job is None : jobList . addJob ( self . job ) else : jobList . addJob ( job ) _tmpHam = copy . deepcopy ( self ) for waveList in jobList . jobs : _tmpHam . job . clearWaves ( ) _tmpHam . job . LO = waveList . LO _tmpHam . job . appendJob ( waveList ) if refreshCache : _tmpHam . buildCache ( ) if isOpen : if not adaptive : from Quanlse . Utils . ODESolver import solverOpenSystem result = solverOpenSystem ( _tmpHam , state0 = state0 , recordEvolution = recordEvolution , accelerate = accelerate ) else : raise Error . ArgumentError ( "Adaptive solver is not available when solving open system." ) else : if not adaptive : from Quanlse . Utils . ODESolver import solverNormal result = solverNormal ( _tmpHam , state0 = state0 , shot = shot , recordEvolution = recordEvolution , accelerate = accelerate ) else : from Quanlse . Utils . ODESolver import solverAdaptive result = solverAdaptive ( _tmpHam , state0 = state0 , shot = shot , tolerance = tolerance , accelerate = accelerate ) resultList . append ( result ) if refreshCache : self . clearCache ( ) return resultList
Calculate the unitary evolution operator with a given Hamiltonian.
Calculate the unitary evolution operator with a given Hamiltonian .
"""
        Calculate the unitary evolution operator with a given Hamiltonian. This function supports
        both single-job and batch-job processing.

        To activate acceleration, please install ``Numba`` JIT compiler, please visit its official website
        https://numba.pydata.org/ for more details.

        :param job: the QJob object to simulate.
        :param state0: the initial state vector. If None is given, this function will return the time-ordered
                       evolution operator, otherwise returns the final state vector.
        :param recordEvolution: the detailed procedure will be recorded if True
        :param shot: return the population of the eigenstates when ``shot`` is provided
        :param isOpen: simulate the evolution using Lindblad equation
        :param jobList: a job list containing the waveform list
        :param refreshCache: it will neither clear nor rebuild cache if refreshCache is set to be True
        :param adaptive: use the adaptive solver if True
        :param tolerance: the greatest error of approximation for the adaptive solver
        :param accelerate: use numba expm if true

        :return: result dictionary (or a list of result dictionaries when ``jobList`` is provided)

        This function does provide the option of simulating on local devices. However, Quanlse also provides
        cloud computing services which are significantly faster.

        **Example 1** (single-job processing):

        If ``jobList`` is None, the waveforms in ham will be used for simulation, and return a result dictionary.

        .. code-block:: python

                result = ham.simulate()

        **Example 2** (batch-job processing):

        If ``jobList`` is not None, simulation will use the waveform list for batch-job processing provided in
        jobList, and return a list of result dictionaries.

        .. code-block:: python

                result = ham.simulate(ham, jobList=jobs)

        Here, jobs is a QJobList object, indicating the the waveforms to be used.
        """ # Transverse all the jobs # Clear all waves # Add waves in current job # Build cache # Start calculation
result dictionary (or a list of result dictionaries when ``jobList`` is provided)
This function does provide the option of simulating on local devices. However, Quanlse also provides
cloud computing services which are significantly faster.

Example 1** (single-job processing).

If ``jobList`` is None, the waveforms in ham will be used for simulation, and return a result dictionary.

code-block:: python

result = ham.simulate()

Example 2** (batch-job processing).

If ``jobList`` is not None, simulation will use the waveform list for batch-job processing provided in
jobList, and return a list of result dictionaries.

code-block:: python

result = ham.simulate(ham, jobList=jobs)

Here, jobs is a QJobList object, indicating the the waveforms to be used.
result dictionary ( or a list of result dictionaries when ` ` jobList ` ` is provided ) This function does provide the option of simulating on local devices . However Quanlse also provides cloud computing services which are significantly faster . Example 1 ** ( single - job processing ) . If ` ` jobList ` ` is None the waveforms in ham will be used for simulation and return a result dictionary . code - block :: python result = ham . simulate () Example 2 ** ( batch - job processing ) . If ` ` jobList ` ` is not None simulation will use the waveform list for batch - job processing provided in jobList and return a list of result dictionaries . code - block :: python result = ham . simulate ( ham jobList = jobs ) Here jobs is a QJobList object indicating the the waveforms to be used .
self
job
QJob
the QJob object to simulate.
the QJob object to simulate .
state0
ndarray
the initial state vector. If None is given, this function will return the time-ordered
evolution operator, otherwise returns the final state vector.
the initial state vector . If None is given this function will return the time - ordered evolution operator otherwise returns the final state vector .
recordEvolution
bool
the detailed procedure will be recorded if True
the detailed procedure will be recorded if True
shot
int
return the population of the eigenstates when ``shot`` is provided
return the population of the eigenstates when ` ` shot ` ` is provided
isOpen
bool
simulate the evolution using Lindblad equation
simulate the evolution using Lindblad equation
jobList
QJobList
a job list containing the waveform list
a job list containing the waveform list
refreshCache
bool
it will neither clear nor rebuild cache if refreshCache is set to be True
it will neither clear nor rebuild cache if refreshCache is set to be True
accelerate
bool
use numba expm if true
use numba expm if true
adaptive
bool
use the adaptive solver if True
use the adaptive solver if True
tolerance
float
the greatest error of approximation for the adaptive solver
the greatest error of approximation for the adaptive solver