@@ -262,7 +262,7 @@ def _control_matrix_at_timestep_derivative(
262
262
The individual control matrices of all time steps
263
263
ctrlmat_g_deriv: ndarray, shape (n_dt, n_nops, d**2, n_ctrl, n_omega)
264
264
The corresponding derivative with respect to the control
265
- strength :math:`\frac{\partial\mathcal{B}_{\alpha j}^{(g)}(\omega)}
265
+ strength :math:`\frac{\partial\mathcal{B}_{\alpha j}^{(g)}(\omega)}`
266
266
267
267
Notes
268
268
-----
@@ -384,8 +384,6 @@ def calculate_derivative_of_control_matrix_from_scratch(
384
384
n_opers : Sequence [Operator ],
385
385
n_coeffs : Sequence [Coefficients ],
386
386
c_opers : Sequence [Operator ],
387
- all_identifiers : Sequence [str ],
388
- control_identifiers : Optional [Sequence [str ]] = None ,
389
387
n_coeffs_deriv : Optional [Sequence [Coefficients ]] = None ,
390
388
intermediates : Optional [Dict [str , ndarray ]] = None
391
389
) -> ndarray :
@@ -421,28 +419,16 @@ def calculate_derivative_of_control_matrix_from_scratch(
421
419
n_coeffs: array_like, shape (n_nops, n_dt)
422
420
The sensitivities of the system to the noise operators given by
423
421
*n_opers* at the given time step.
424
- c_opers: array_like, shape (n_cops, d, d)
425
- Control operators :math:`H_k`.
426
- all_identifiers: array_like, shape (n_cops)
427
- Identifiers of all control operators.
428
- control_identifiers: Sequence[str], shape (n_ctrl), Optional
429
- Sequence of strings with the control identifiers to distinguish
430
- between accessible control and drift Hamiltonian. The default is
431
- None.
422
+ c_opers: array_like, shape (n_ctrl, d, d)
423
+ Control operators :math:`H_k` with respect to which the
424
+ derivative is computed.
432
425
n_coeffs_deriv: array_like, shape (n_nops, n_ctrl, n_dt)
433
426
The derivatives of the noise susceptibilities by the control
434
427
amplitudes. Defaults to None.
435
428
intermediates: Dict[str, ndarray], optional
436
429
Optional dictionary containing intermediate results of the
437
430
calculation of the control matrix.
438
431
439
- Raises
440
- ------
441
- ValueError
442
- If the given identifiers *control_identifier* are not subset of
443
- the total identifiers *all_identifiers* of all control
444
- operators.
445
-
446
432
Returns
447
433
-------
448
434
ctrlmat_deriv: ndarray, shape (n_ctrl, n_omega, n_dt, n_nops, d**2)
@@ -470,24 +456,16 @@ def calculate_derivative_of_control_matrix_from_scratch(
470
456
_liouville_derivative
471
457
_control_matrix_at_timestep_derivative
472
458
"""
473
- # Distinction between control and drift operators and only
474
- # calculate the derivatives in control direction
475
- try :
476
- idx = util .get_indices_from_identifiers (all_identifiers , control_identifiers )
477
- except ValueError as err :
478
- raise ValueError ('Given control identifiers have to be a subset of (drift+control) ' +
479
- 'Hamiltonian!' ) from err
480
-
481
459
d = eigvecs .shape [- 1 ]
482
460
n_dt = len (dt )
483
- n_ctrl = len (idx )
461
+ n_ctrl = len (c_opers )
484
462
n_nops = len (n_opers )
485
463
n_omega = len (omega )
486
464
487
465
# Precompute some transformations or grab from cache if possible
488
466
basis_transformed = numeric ._transform_by_unitary (eigvecs [:, None ], basis [None ],
489
467
out = np .empty ((n_dt , d ** 2 , d , d ), complex ))
490
- c_opers_transformed = numeric ._transform_hamiltonian (eigvecs , c_opers [ idx ] ).swapaxes (0 , 1 )
468
+ c_opers_transformed = numeric ._transform_hamiltonian (eigvecs , c_opers ).swapaxes (0 , 1 )
491
469
if not intermediates :
492
470
# None or empty
493
471
n_opers_transformed = numeric ._transform_hamiltonian (eigvecs , n_opers ,
@@ -575,6 +553,7 @@ def infidelity_derivative(
575
553
spectrum : Coefficients ,
576
554
omega : Coefficients ,
577
555
control_identifiers : Optional [Sequence [str ]] = None ,
556
+ n_oper_identifiers : Optional [Sequence [str ]] = None ,
578
557
n_coeffs_deriv : Optional [Sequence [Coefficients ]] = None
579
558
) -> ndarray :
580
559
r"""Calculate the entanglement infidelity derivative of the
@@ -599,11 +578,29 @@ def infidelity_derivative(
599
578
omega: array_like, shape (n_omega,)
600
579
The frequencies at which the integration is to be carried out.
601
580
control_identifiers: Sequence[str], shape (n_ctrl,)
602
- Sequence of strings with the control identifiern to distinguish
603
- between accessible control and drift Hamiltonian.
581
+ Sequence of strings with the control identifiers to
582
+ distinguish between control and drift Hamiltonian. The
583
+ default is None, in which case the derivative is computed
584
+ for all known non-noise operators.
585
+ n_oper_identifiers: Sequence[str], shape (n_nops,)
586
+ Sequence of strings with the noise identifiers for which to
587
+ compute the derivative contribution. The default is None, in
588
+ which case it is computed for all known noise operators.
604
589
n_coeffs_deriv: array_like, shape (n_nops, n_ctrl, n_dt)
605
590
The derivatives of the noise susceptibilities by the control
606
- amplitudes. Defaults to None.
591
+ amplitudes. The rows and columns should be in the same order
592
+ as the corresponding identifiers above. Defaults to None, in
593
+ which case the coefficients are assumed to be constant and
594
+ hence their derivative vanishing.
595
+
596
+ .. warning::
597
+
598
+ Internally, control and noise terms of the Hamiltonian
599
+ are stored alphanumerically sorted by their identifiers.
600
+ If the noise and/or control identifiers above are not
601
+ explicitly given, the rows and/or columns of this
602
+ parameter need to be sorted in the same fashion.
603
+
607
604
608
605
Raises
609
606
------
@@ -616,7 +613,9 @@ def infidelity_derivative(
616
613
infid_deriv: ndarray, shape (n_nops, n_dt, n_ctrl)
617
614
Array with the derivative of the infidelity for each noise
618
615
source taken for each control direction at each time step
619
- :math:`\frac{\partial I_e}{\partial u_h(t_{g'})}`.
616
+ :math:`\frac{\partial I_e}{\partial u_h(t_{g'})}`. Sorted in
617
+ the same fashion as `n_coeffs_deriv` or, if not given,
618
+ alphanumerically by the identifiers.
620
619
621
620
Notes
622
621
-----
@@ -658,7 +657,9 @@ def infidelity_derivative(
658
657
https://doi.org/10.1016/S0375-9601(02)01272-0
659
658
"""
660
659
spectrum = numeric ._parse_spectrum (spectrum , omega , range (len (pulse .n_opers )))
661
- filter_function_deriv = pulse .get_filter_function_derivative (omega , control_identifiers ,
660
+ filter_function_deriv = pulse .get_filter_function_derivative (omega ,
661
+ control_identifiers ,
662
+ n_oper_identifiers ,
662
663
n_coeffs_deriv )
663
664
664
665
integrand = np .einsum ('ao,atho->atho' , spectrum , filter_function_deriv )
0 commit comments