2 from qpms
import TMatrixGenerator
, BaseSpec
, eV
, hbar
8 def tmg_diagonal_fun(tmatrix
, omega
):
10 Example of a python function used as a custom T-matrix generator
12 It receives a CTMatrix argument with pre-filled BaseSpec
13 (in tmatrix.spec) and angular frequency.
15 It has to fill in the T-matrix elements tmatrix[...]
16 (a numpy array of shape (len(tmatrix.spec),len(tmatrix.spec)))
17 and return zero (on success) or other integral value on error.
19 Note that this in justa an example of using the API,
20 not supposed to be anything physical.
23 tmatrix
[...] = np
.diag(1./l
**2)
26 # Wrap the function as an actual TMatrixGenerator
27 tmg_diagonal
= TMatrixGenerator(tmg_diagonal_fun
)
29 bspec
= BaseSpec(lMax
=2)
31 tmatrix
= tmg_diagonal(bspec
, (2.0+.01j
) * eV
/hbar
)
33 errors
+= np
.sum(tmatrix
[...] != np
.diag(1./bspec
.l()**2))