@@ -285,6 +285,13 @@ def calc_exp_qn(self, qn: str) -> float:
285285 if qn .startswith ("raw_value_" ):
286286 return self .calc_reduced_matrix_element (self , qn , unit = "a.u." ) # type: ignore [call-overload,no-any-return]
287287
288+ if qn .startswith ("operator_" ):
289+ qn_name = qn [len ("operator_" ) :]
290+ exp_q2 = self .calc_matrix_element (self , "squared_" + qn_name , q = 0 , unit = "a.u." ) # type: ignore [call-overload]
291+ # exp_q2 returns the reduced matrix element of the operator \abs{\hat{S}}
292+ # (which for the concrete (non reduced) matrix element gives -> sqrt(S(S+1)))
293+ return - 0.5 + math .sqrt (1 / 4 + exp_q2 )
294+
288295 if is_angular_momentum_quantum_number (qn ):
289296 if qn not in self .rydberg_kets [0 ].angular .quantum_number_names :
290297 coupling_scheme = get_coupling_scheme_for_quantum_number (qn , [self .coupling_scheme ])
@@ -308,6 +315,9 @@ def calc_std_qn(self, qn: str) -> float:
308315 return 0
309316 return math .sqrt (exp_q2 - exp_q ** 2 )
310317
318+ if qn .startswith ("operator_" ):
319+ raise NotImplementedError ("Standard deviation for operator quantum numbers is not implemented." )
320+
311321 if is_angular_momentum_quantum_number (qn ):
312322 if qn not in self .rydberg_kets [0 ].angular .quantum_number_names :
313323 coupling_scheme = get_coupling_scheme_for_quantum_number (qn , [self .coupling_scheme ])
0 commit comments