Numerics
Numerics
The Numerics
class is used for numerical computations in the YASF (Yet Another Scattering
Framework) library, providing methods for computing associated Legendre polynomials, translation
tables, Fibonacci sphere points, and spherical unity vectors.
The __init__
function initializes the Numerics class with various parameters and sets up the
necessary attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lmax |
int
|
The maximum degree of the spherical harmonics expansion. |
required |
sampling_points_number |
Union[int, ndarray]
|
The |
100
|
polar_angles |
ndarray
|
An array containing the polar angles of the sampling points on the unit sphere. |
None
|
polar_weight_func |
Callable
|
The |
lambda : x
|
azimuthal_angles |
ndarray
|
An array containing the azimuthal angles of the sampling points on the unit sphere. |
None
|
gpu |
bool
|
A flag indicating whether to use GPU acceleration. If set to True, the computations will be performed on a GPU if available. If set to False, the computations will be performed on the CPU. |
False
|
particle_distance_resolution |
float
|
The parameter "particle_distance_resolution" represents the resolution of the particle distance. It determines the accuracy of the numerical computations related to particle distances in the code. The value of this parameter is set to 10.0 by default. |
10.0
|
solver |
Solver
|
The |
None
|
Source code in yasfpy/numerics.py
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 |
|
log = log.scattering_logger(__name__)
instance-attribute
lmax = lmax
instance-attribute
sampling_points_number = np.squeeze(sampling_points_number)
instance-attribute
polar_angles_linspace = np.pi * polar_weight_func(np.linspace(0, 1, sampling_points_number[1]))
instance-attribute
azimuthal_angles_linspace = 2 * np.pi * np.linspace(0, 1, sampling_points_number[0] + 1)[:-1]
instance-attribute
polar_angles = polar_angles
instance-attribute
azimuthal_angles = azimuthal_angles
instance-attribute
gpu = gpu
instance-attribute
particle_distance_resolution = particle_distance_resolution
instance-attribute
solver = solver
instance-attribute
__compute_nmax
The function computes the maximum number of coefficients based on the values of lmax.
Source code in yasfpy/numerics.py
115 116 117 118 119 |
|
__plm_coefficients
The function computes the coefficients for the associated Legendre polynomials using the sympy library.
Source code in yasfpy/numerics.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
__setup
The function performs the setup for numerical computations.
Source code in yasfpy/numerics.py
141 142 143 |
|
compute_plm_coefficients
The function computes the coefficients for the associated Legendre polynomials.
Source code in yasfpy/numerics.py
147 148 149 150 151 |
|
compute_translation_table
The function computes a translation table using Wigner 3j symbols and stores the results in a numpy array.
Source code in yasfpy/numerics.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 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 |
|
compute_fibonacci_sphere_points
staticmethod
Computes the points on a Fibonacci sphere using the given number of points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
The number of points to be computed on the Fibonacci sphere. Defaults to 100. |
100
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
ndarray
|
A tuple containing: - points (np.ndarray): The Cartesian points of the Fibonacci sphere. - theta (np.ndarray): The polar angles of the points on the Fibonacci sphere. - phi (np.ndarray): The azimuthal angles of the points on the Fibonacci sphere. |
Source code in yasfpy/numerics.py
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 |
|
compute_spherical_unity_vectors
The function computes the spherical unity vectors e_r, e_theta, and e_phi based on the given polar and azimuthal angles.
Source code in yasfpy/numerics.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|