Source code for qiskit_experiments.test.noisy_delay_aer_simulator
# This code is part of Qiskit.## (C) Copyright IBM 2022.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals."""Temporary backend to be used to apply T2 and T1 noise."""fromtypingimportListfromqiskitimportQuantumCircuitfromqiskit.circuitimportDelayfromqiskit_aerimportAerSimulatorfromqiskit_aer.jobs.aerjobimportAerJobfromqiskit_aer.noise.passesimportRelaxationNoisePassfromqiskit_experiments.frameworkimportBackendData
[docs]classNoisyDelayAerBackend(AerSimulator):"""Backend for T1 and T2Ramsey experiments."""def__init__(self,t1:List[float]=None,t2:List[float]=None,dt:float=None,backend=None,**backend_options,):"""configure backend noise"""super().__init__(**backend_options)self._t2=t2or[1e-4]self._t1=t1or[2e-4]ifbackend:dt=BackendData(backend).dtifdtisnotNone:self._dt_unit=Trueself._dt_factor=dtelse:self._dt_unit=Falseself._dt_factor=dtor1e-9self._op_types=[Delay]# pylint: disable=arguments-differ
[docs]defrun(self,run_input:List[QuantumCircuit],**run_options)->AerJob:""" Add noise pass to all circuits and then run the circuits. Args: run_input: List of circuit to run. run_options (kwargs): additional run time backend options. Returns: AerJob: A job that contains the simulated data. """relax_pass=RelaxationNoisePass(self._t1,self._t2,dt=self._dt_factor,op_types=self._op_types)noisy_circuits=[]forcircinrun_input:noisy_circuits.append(relax_pass(circ))returnsuper().run(noisy_circuits,**run_options)