
    {	i                         S r SSKrSSKJrJrJrJr  SSKrSSK	J
r
Jr  SSKJr  SSKJr  SSKJr  S	S
KJr  S	SKJr   " S S\5      rg)z 
Thermal relaxation noise pass.
    N)OptionalUnionSequenceList)InstructionQuantumCircuit)Target)apply_prefix   )LocalNoisePass   )thermal_relaxation_error)
NoiseErrorc                      ^  \ rS rSrSr    SS\\   S\\   S\\   S\\\	\
\	   4      S\\\      S\4U 4S	 jjjrS
\S\
\   4S jrSrU =r$ )RelaxationNoisePass   zCAdd duration dependent thermal relaxation noise after instructions.t1st2sdtop_typesexcited_state_populationstargetc                 B  > [         R                  " U5      U l        [         R                  " U5      U l        Ub  [         R                  " U5      U l        O$[         R
                  " [        U5      5      U l        X0l        X`l        [        TU ])  U R                  USS9  g)a  Initialize RelaxationNoisePass.

Args:
    t1s: List of T1 times in seconds for each qubit.
    t2s: List of T2 times in seconds for each qubit.
    dt: Backend sample time (resolution) in seconds. This is required
        for converting dt-unit op durations to times in scheduled circuits.
    op_types: Optional, the operation types to add relaxation to. If None
        relaxation will be added to all operations.
    excited_state_populations: Optional, list of excited state populations
        for each qubit at thermal equilibrium. If not supplied or obtained
        from the backend this will be set to 0 for each qubit.
    target: Optional, target instance with instruction duration information.
Nappend)r   method)npasarray_t1s_t2s_p1szeroslen_dt_targetsuper__init___thermal_relaxation_error)selfr   r   r   r   r   r   	__class__s          g/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_aer/noise/passes/relaxation_noise_pass.pyr&   RelaxationNoisePass.__init__   ss    . JJsO	JJsO	$0

#<=DIS*DI77(S[\    opqubitsc                 L   SnU R                   b  UR                  S:X  ar  UR                  nUbb  UR                  S:X  a2  U R                  c  [        S5      eUR                  U R                  -  nO[        UR                  UR                  5      nOU R                   R                  UR                  5      nUb)  UR                  [        U5      5      nUb  [        US5      nOr UR                  nUbb  UR                  S:X  a2  U R                  c  [        S5      eUR                  U R                  -  nO [        UR                  UR                  5      nUc*  [        R                  " SUR                   S3[        5        gU R                  U   nU R                  U   nU R                   U   nUR"                  S:X  aC  US	   US	   US	   pn	U	[$        R&                  :X  a  U
[$        R&                  :X  a  g[)        XX;5      $ [+        UR"                  5      n[-        [/        XgU5      5       H`  u  nu  pnU	[$        R&                  :X  a  U
[$        R&                  :X  a  M3  [)        XX;5      nUR1                  UR3                  5       U/5        Mb     U$ ! [         a    Sn GNLf = f)
z5Return thermal relaxation error on each operand qubitNdelayr   zURelaxationNoisePass cannot apply noise to a 'dt' unit duration without a dt time set.durationz#Instruction duration not found for z. RelaxationNoisePass ignores instructions without duration. To avoid this warning, provide the corresponding duration information via `target`.r   r   )r$   namer1   unitr#   r   r
   gettuplegetattrAttributeErrorwarningswarnUserWarningr   r   r    
num_qubitsr   infr   r   	enumeratezipr   to_instruction)r(   r-   r.   r1   op_props
inst_propsr   r   p1st1t2p1noisequbiterrors                  r*   r'   -RelaxationNoisePass._thermal_relaxation_error@   sX    <<#ww'!;;'ww$88+",!:#  $&;;#9#/RWW#E<<++BGG4'!)eFm!<J!-#*:z#B ;;'ww$88+",!:#  $&;;#9#/RWW#E
 MM5bggY ?f f 	 iiiiii ==AQQQBBRVV|bff+BHAA r}}-#,S3-?#@E<BBRVV|bff,RXBELL--/%9 $A A "   s   %AJ 6 J J#"J#)r#   r    r   r   r$   )NNNN)__name__
__module____qualname____firstlineno____doc__r   floatr   r   typer   r	   r&   r   intr'   __static_attributes____classcell__)r)   s   @r*   r   r      s    M #:>;?]%[] %[] UO	]
 5x~!567] $,DK#8] ] ]BIK I# I Ir,   r   )rN   r8   typingr   r   r   r   numpyr   qiskit.circuitr   r   qiskit.transpilerr	   qiskit.utils.unitsr
   local_noise_passr   errors.standard_errorsr   
noiseerrorr   r    r,   r*   <module>r]      s8     2 2  6 $ + , = #m. mr,   