epsproc.geomFunc.geomUtils module
ePSproc utility functions for geometric terms and tensors.
26/02/20 v1
Code from ePSproc_MFBLM_Numba_dev_tests_120220.py
- epsproc.geomFunc.geomUtils.degenChecks(matEin, selDims, sumDims, degenDrop, verbose)[source]
Check for matrix element state degenaracies & set handling.
Note inputs all required, defaults defined in calling routine (e.g.
epsproc.afblmGeom.afblmXprod()
).- Parameters
matE (Xarray) – Xarray containing matrix elements, with QNs (l,m), as created by
readMatEle()
selDims (dict) – Selection parameters for calculations, may be be checked and appened herein.
sumDims (list) – Summation dims, will be checked herein.
degenDrop (bool) – Flag to set dropping of degenerate components.
verbose (bool or int) – Print output?
- Returns
Dictionary of degen options & settings.
- Return type
dict
- epsproc.geomFunc.geomUtils.genKQStermsFromTensors(EPR, AKQS, uniqueFlag=True, phaseConvention='S')[source]
Generate all QNs for \(\Delta_{L,M}(K,Q,S)\) from existing tensors (Xarrays) \(E_{P,R}\) and \(A^K_{Q,S}\).
Cf.
epsproc.geomFunc.genllpMatE()
, code adapted from there.- Parameters
matE (Xarray) – Xarray containing matrix elements, with QNs (l,m), as created by
readMatEle()
uniqueFlag (bool, default = True) – Check for duplicates and remove (can occur with some forms of matrix elements).
mFlag (bool, optional, default = True) – m, mp take all passed values if mFlag=True, or =0 only if mFlag=False
phaseConvention (optional, str, default = 'S') – Set phase conventions with
epsproc.geomCalc.setPhaseConventions()
. To use preset phase conventions, pass existing dictionary. If matE.attrs[‘phaseCons’] is already set, this will be used instead of passed args.
- Returns
QNs1, QNs2 (two 2D np.arrays) – Values take all allowed combinations [‘P’,’K’,’L’,’R’,’Q’,’M’] and [‘P’,’K’,’L’,’Rp’,’S’,’S-Rp’] from supplied matE. Note phase conventions not applied to QN lists as yet.
To do
—–
- Implement output options (see dev. function w3jTable).
- epsproc.geomFunc.geomUtils.genLmLamKQStermsFromTensors(matE, AKQS, mu0=[-1, 0, 1], uniqueFlag=True, phaseConvention='S')[source]
Generate all QNs for triple product \(D_{m\Lambda}^{l*}(\Omega)D_{\mu,\mu_{0}}^{1*}(\Omega)D_{Q,S}^{K*}(\Omega)\) from existing tensors (Xarrays) of matrix elements and and \(A^K_{Q,S}\).
13/01/21 rough code adapted from existing genKQStermsFromTensors() function.
Cf.
epsproc.geomFunc.genllpMatE()
, code originally adapted from there.- Parameters
matE (Xarray) – Xarray containing matrix elements, with QNs (l,m), as created by
readMatEle()
AKQS (Xarray) – Alignment parameters, as set by
setADMs()
mu0 (list, optional, default = [-1,0,1]) – Set LF polarization term. If None, calcualte for all allowed terms.
uniqueFlag (bool, default = True) – Check for duplicates and remove (can occur with some forms of matrix elements).
mFlag (bool, optional, default = True) – m, mp take all passed values if mFlag=True, or =0 only if mFlag=False
phaseConvention (optional, str, default = 'S') – Set phase conventions with
epsproc.geomCalc.setPhaseConventions()
. To use preset phase conventions, pass existing dictionary. If matE.attrs[‘phaseCons’] is already set, this will be used instead of passed args.
- Returns
QNs1, QNs2 (two 2D np.arrays) – Values take all allowed combinations [‘l’,’E’,’K’,’m’,’mu’,’Q’] and [‘l’,’E’,’K’,’Lambda’,’mu0’,’S’] from supplied matE & AKQS terms. Note phase conventions not applied to QN lists as yet.
To do
—–
- Implement output options (see dev. function w3jTable).
- Write generalised functions for D and 3j multiplication terms. Lots of repeated code here otherwise.
- epsproc.geomFunc.geomUtils.genllL(Lmin=0, Lmax=10, mFlag=True)[source]
Generate quantum numbers for angular momentum contractions (l, lp, L)
- Parameters
Lmin (int, optional, default 0, 10) – Integer values for Lmin and Lmax respectively.
Lmax (int, optional, default 0, 10) – Integer values for Lmin and Lmax respectively.
mFlag (bool, optional, default = True) – m, mp take all values -l…+l if mFlag=True, or =0 only if mFlag=False
- Returns
QNs – Values take all allowed combinations [‘l’,’lp’,’L’,’m’,’mp’,’M’] up to l=lp=Lmax, one set per row.
- Return type
2D np.array
Examples
>>> # Calculate up to Lmax = 2 >>> QNs = genllL(Lmax=2) >>> # Use with w3jTable function to calculate Wigner 3j terms >>> w3j = w3jTable(QNs = QNs)
To do
Implement output options (see dev. function w3jTable).
- epsproc.geomFunc.geomUtils.genllLList(Llist, uniqueFlag=True, mFlag=True)[source]
Generate quantum numbers for angular momentum contractions (l, lp, L) from a passed list, (m, mp, M)=0 or all allowed terms.
- Parameters
Llist (list) – Values [l, lp, L] to use for calculations. Note this needs to be 2D array in current form of function, i.e. defined as np.array([[L1,L2,L3],…])
uniqueFlag (bool, optional, default = True) – Drop duplicate [l,lp,L] sets from list.
mFlag (bool, optional, default = True) – m, mp take all values -l…+l if mFlag=True, or =0 only if mFlag=False
- Returns
QNs – Values take all allowed combinations [‘l’,’lp’,’L’,’m’,’mp’,’M’] up to l=lp=Lmax, one set per row.
- Return type
2D np.array
Examples
>>> # Set from an array >>> QNs = genllLList(np.array([[1,1,2],[1,3,2],[1,1,2]]), mFlag = True) >>> # Use with w3jTable function to calculate Wigner 3j terms >>> w3j = w3jTable(QNs = QNs)
To do
Implement output options (see dev. function w3jTable).
- epsproc.geomFunc.geomUtils.genllpMatE(matE, uniqueFlag=True, mFlag=True, phaseConvention='S')[source]
Generate quantum numbers for angular momentum contractions (l, lp, L, m, mp, M) from sets of matrix elements.
- Parameters
matE (Xarray) – Xarray containing matrix elements, with QNs (l,m), as created by
readMatEle()
uniqueFlag (bool, default = True) – Check for duplicates and remove (can occur with some forms of matrix elements).
mFlag (bool, optional, default = True) – m, mp take all passed values if mFlag=True, or =0 only if mFlag=False
phaseConvention (optional, str, default = 'S') – Set phase conventions with
epsproc.geomCalc.setPhaseConventions()
. To use preset phase conventions, pass existing dictionary. If matE.attrs[‘phaseCons’] is already set, this will be used instead of passed args.
- Returns
QNs – Values take all allowed combinations [‘l’,’lp’,’L’,’m’,’mp’,’M’] from supplied matE
- Return type
2D np.array
Examples
>>> # From demo matrix elements >>> dataFile = os.path.join(dataPath, 'n2_3sg_0.1-50.1eV_A2.inp.out') # Set for sample N2 data for testing >>> # Scan data file >>> dataSet = ep.readMatEle(fileIn = dataFile) >>> QNs = genllpMatE(dataSet[0]) >>> # Use with w3jTable function to calculate Wigner 3j terms >>> w3j = w3jTable(QNs = QNs)
To do
Implement output options (see dev. function w3jTable).
- epsproc.geomFunc.geomUtils.selQNsRow(QNs, QNmask, fields=None, verbose=1)[source]
Basic routine for selecting/filtering valid rows from an input array of QNs.
This is similar to methods used in Matlab version, but likely rather slow.
- Parameters
QNs (np.array) – Values to be filtered.
QNmask (list or np.array) – Values to be matched. Must be same dims as QNs, unless fields is also set. If set to None field will be skipped (i.e. match all values)
fields (list or np.array, optional, default = None) – Which fields to match in QNs.
verbose (int, optional, default = 1) – Print info to terminal.
- Returns
QNs[boolMask] (np.array of selected values.)
boolMask (np.array corresponding to selected values.)
Examples
>>> QNsMask, mask = selQNsRow(QNs,[None, None, None, 0, 0, 0], verbose = False) >>> # With fields >>> QNsMask, mask = selQNsRow(QNs,[0, 0, 0], fields = [3,4,5], verbose = False)