refloxide.pxr.tjf4x4¶
refloxide.pxr.tjf4x4
¶
uniaxial_reflectivity(q, layers, tensor, energy)
¶
EMpy implementation of the uniaxial 4x4 matrix formalism.
for calculating reflectivity from a stratified medium.
Uses the implementation developed by FSRStools - https://github.com/ddietze/FSRStools - written by Daniel Dietze
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
NDArray
|
q values for which to calculate the reflectivity. Units: 1/Angstroms |
required |
layers
|
NDArray
|
coefficients required for the calculation, has shape (2 + N, 4), where N is the number of layers - layers[0, 1] - SLD of fronting (/1e-6 Angstrom-2) - layers[0, 2] - iSLD of fronting (/1e-6 Angstrom-2) - layers[N, 0] - thickness of layer N - layers[N, 1] - SLD of layer N (/1e-6 Angstrom-2) - layers[N, 2] - iSLD of layer N (/1e-6 Angstrom-2) - layers[N, 3] - roughness between layer N-1/N - layers[-1, 1] - SLD of backing (/1e-6 Angstrom-2) - layers[-1, 2] - iSLD of backing (/1e-6 Angstrom-2) - layers[-1, 3] - roughness between backing and last layer |
required |
tensor
|
NDArray
|
contains the 1x3x3 dimensions First dimension may change in teh fiture to account for multi-energy currently it will just cycle |
required |
scale
|
Multiply all reflectivities by this value. |
required | |
bkg
|
Linear background to be added to all reflectivities |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Reflectivity |
ndarray
|
Calculated reflectivity values for each q value. |
Source code in src/refloxide/pxr/tjf4x4.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
calculate_kz_uni(ep, kx, ky, k0, opticaxis=None)
¶
Calculate the z-component of the wavevector for uniaxial media.
This function calculates the z-components of both ordinary and extraordinary waves in a uniaxial medium, given the permittivity tensor and the x,y components of the wavevector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ep
|
ndarray
|
3x3 permittivity tensor of the material |
required |
kx
|
ndarray
|
x-component of the wavevector |
required |
ky
|
ndarray
|
y-component of the wavevector |
required |
k0
|
float
|
Free space wavevector magnitude |
required |
opticaxis
|
tuple
|
Unit vector defining the optical axis direction. Defaults to [0.0, 1.0, 0.0] |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of shape (len(kx), 4) containing the z-components of the wavevector: - [:, 0]: forward extraordinary wave - [:, 1]: backward extraordinary wave - [:, 2]: forward ordinary wave - [:, 3]: backward ordinary wave |
Notes
The calculation assumes the material is uniaxial with the extraordinary axis aligned with the optic axis. The ordinary and extraordinary components are calculated using the standard dispersion relations for uniaxial media.
Source code in src/refloxide/pxr/tjf4x4.py
calculate_Dpol_uni(ep, kx, ky, kz, k0, opticaxis=None)
¶
Calculate electric and magnetic dipole polarizations for uniaxial materials.
This function computes the electric and magnetic dipole polarization vectors for a uniaxial anisotropic material, given the permittivity tensor and wavevector components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ep
|
ndarray
|
3x3 permittivity tensor for the uniaxial material. |
required |
kx
|
ndarray
|
x-component of the wavevector. |
required |
ky
|
ndarray
|
y-component of the wavevector. |
required |
kz
|
ndarray
|
z-component of the wavevector. |
required |
k0
|
float
|
Free-space wavevector magnitude. |
required |
opticaxis
|
list[float] | None
|
Unit vector defining the optical axis. Default is |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dpol_temp |
ndarray
|
Normalized electric dipole polarization vectors. |
hpol_temp |
ndarray
|
Normalized magnetic dipole polarization vectors. |
Notes
The optical axis should not be collinear with the k-vector and should be a unit vector. The function handles ordinary and extraordinary waves in the uniaxial medium.
Source code in src/refloxide/pxr/tjf4x4.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
calculate_D(numpnts, nlayers, Dpol, Hpol)
¶
Transfer matrices D and its inverse Di for a multilayer optical system.
This function constructs the transfer matrix D and calculates its inverse Di for each point and layer in the system using polarization components from D-polarized and H-polarized fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
numpnts
|
int
|
Number of points (typically wavelengths or angles) to calculate for |
required |
nlayers
|
int
|
Number of layers in the optical system |
required |
Dpol
|
ndarray
|
D-polarization transfer matrix components with shape (numpnts, nlayers, 4, 4) |
required |
Hpol
|
ndarray
|
H-polarization transfer matrix components with shape (numpnts, nlayers, 4, 4) |
required |
Returns:
| Type | Description |
|---|---|
list
|
A list containing two elements: - D_Temp : ndarray of shape (numpnts, nlayers, 4, 4) The constructed transfer matrix D - Di_Temp : ndarray of shape (numpnts, nlayers, 4, 4) The inverse of D_Temp, calculated using np.linalg.inv() or np.linalg.pinv() as fallback |
Notes
The function attempts to use numpy.linalg.inv() for matrix inversion first, and falls back to numpy.linalg.pinv() (pseudo-inverse) if the regular inversion fails.
Source code in src/refloxide/pxr/tjf4x4.py
calculate_P(_numpnts, _nlayers, kz, d)
¶
Calculate the propagation matrix using the previously calculated values for kz.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_numpnts
|
int
|
Number of points in the calculation grid (not used directly in this function). |
required |
_nlayers
|
int
|
Number of layers in the model (not used directly in this function). |
required |
kz
|
ndarray
|
Array of shape (numpnts, nlayers, 4) containing the z-component of the wavevector for each point, layer, and solution. |
required |
d
|
ndarray
|
Array of shape (nlayers,) containing the thickness of each layer. |
required |
Source code in src/refloxide/pxr/tjf4x4.py
calculate_W(numpnts, nlayers, kz1, kz2, r)
¶
Calculate matrix W for uniaxial model fitting.
This function calculates the W matrix used in uniaxial model fitting, which involves exponential terms of wavevectors for different layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
numpnts
|
int
|
Number of points in the calculation grid |
required |
nlayers
|
int
|
Number of layers in the model |
required |
kz1
|
ndarray
|
Array of shape (numpnts, nlayers, 4) containing z-component of wavevector 1 |
required |
kz2
|
ndarray
|
Array of shape (numpnts, nlayers, 4) containing z-component of wavevector 2 |
required |
r
|
ndarray
|
Array of shape (nlayers,) containing roughness parameters for each layer |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
4D array of shape (numpnts, nlayers, 4, 4) containing the W matrix elements with exponential terms for interface roughness |
Notes
The function calculates exponential terms for interface roughness using the sum and difference of wavevectors, and arranges them in a 4x4 matrix format for each point and layer.
Source code in src/refloxide/pxr/tjf4x4.py
calculate_TMM(_numpnts, nlayers, M, D, Di, P, W)
¶
Calculate Transfer Matrix Method (TMM) for multilayered optical system.
This function computes the total transfer matrix for a multilayer optical system using the Transfer Matrix Method (TMM). It iteratively multiplies matrices representing different layers to obtain the overall system response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_numpnts
|
int
|
Unused; retained for signature compatibility. Number of points is implied by array axes. |
required |
nlayers
|
int
|
Number of layers in the optical system. |
required |
M
|
ndarray
|
Initial transfer matrix, shape (numpnts, 2, 2). |
required |
D
|
ndarray
|
Dynamic matrices for each layer, shape (numpnts, nlayers, 2, 2). |
required |
Di
|
ndarray
|
Inverse dynamic matrices for each layer, shape (numpnts, nlayers-1, 2, 2). |
required |
P
|
ndarray
|
Propagation matrices for each layer, shape (numpnts, nlayers-1, 2, 2). |
required |
W
|
ndarray
|
Interface matrices between layers, shape (numpnts, nlayers, 2, 2). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Final transfer matrix M after considering all layers, shape (numpnts, 2, 2). |
Notes
The function implements the TMM calculation following the sequence: 1. Iterates through internal layers 2. Multiplies appropriate matrices using Einstein summation 3. Includes final layer calculation separately
Source code in src/refloxide/pxr/tjf4x4.py
calculate_output(numpnts, M_full)
¶
Extract reflectivity and transmittance amplitudes from the system matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
numpnts
|
int
|
Number of angular or momentum samples. |
required |
M_full
|
ndarray
|
System transfer matrix with shape |
required |
Returns:
| Name | Type | Description |
|---|---|---|
refl |
ndarray
|
Real reflectivity values, shape |
tran |
ndarray
|
Complex transmittance-related amplitudes, shape |
Notes
The full Yeh 4x4 extraction from M_full is not yet implemented in this
port; the returned arrays are zero-filled so the module remains importable
and documentable while the optical reduction is completed.