Configuration
vectorwaves.config_stuff.Config
dataclass
Bases: SerializableConfig
Main VectorWaves Configuration.
This is the root tree for initializing an experiment. It manages the global backend, the observation plane settings, and the complex light source properties.
Example:
config = get_config()
config.op.size = (20.0, 20.0)
config.source.k_space.gaussian(sigma_k_perp=1.0)
config.source.randomize.off()
Attributes:
| Name | Type | Description |
|---|---|---|
backend |
Literal['auto', 'numpy', 'numba', 'cupy', 'cupy64']
|
Computational backend to execute evaluations. Defaults to "auto". All backends perform exactly the same physical superposition of plane waves, but scale differently based on hardware: - "numpy" : Vectorized CPU fallback (highest RAM usage, best for small sets). - "numba" : JIT compiled parallel CPU loops (low RAM usage, fast CPU). - "cupy32" : Single-precision GPU execution (fastest for massive computations). - "cupy64" : Double-precision GPU execution (slower than cupy, but exact). - "auto" : Defaults to cupy64 if available, else numba, else numpy. |
op |
OpConfig
|
Settings for the Observation Plane (grid size, center, resolution). |
source |
SourceConfig
|
Settings for the Light Source (beam axis, wavelength, spatial/spectral profiles). |
verbose |
bool
|
If True, prints execution details and deep warnings. |
Source code in src\vectorwaves\config_stuff.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | |
vectorwaves.config_stuff.SourceConfig
dataclass
Bases: SerializableConfig
Light Source Configuration.
Aggregates all physical parameters defining the initial state of the light
field, including nested properties like spatial modes and polarization.
Access this via config.source.
Example:
config.source.intensity_scale = 1e3
config.source.wavelength = 0.532
config.source.k_space.gaussian(sigma_k_perp=2.0)
config.source.randomize.off()
Attributes:
| Name | Type | Description |
|---|---|---|
k_space |
KSpaceConfig
|
Sub-configuration dictating the spatial distribution of momentum (k-vectors). |
polychromatic |
PolychromaticConfig
|
Sub-configuration dictating the spectral/wavelength envelope. |
randomize |
RandomizeConfig
|
Sub-configuration dictating random noise/coherence features. |
intensity_scale |
float
|
Scalar multiplier for total field intensity. Must be > 0. |
wavelength |
Union[float, List[float]]
|
The physical wavelength(s) of the simulation. |
pol_vect |
Tuple[complex, complex]
|
Jones vector (E1, E2) defining base polarization, normalized upon init. |
beam_axis |
Tuple[float, float, float]
|
Average propagation direction vector (kx, ky, kz), normalized upon init. |
num_modes |
int
|
Number of plane wave modes used for the angular spectrum sum. |
theta_max |
float
|
Maximum half-cone angle (radians) restricting the generated wavevectors. |
Source code in src\vectorwaves\config_stuff.py
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
vectorwaves.config_stuff.OpConfig
dataclass
Bases: SerializableConfig
Observation Plane Configuration.
Defines the spatial grid where the optical field is evaluated. Access this
via config.op.
Example:
config.op.size = (10.0, 10.0)
config.op.spacing = 0.05
Attributes:
| Name | Type | Description |
|---|---|---|
spacing |
float
|
Grid pixel spacing. Must be strictly > 0. |
size |
tuple[float, float]
|
Physical size of the rectangular plane (width, height). |
center |
tuple[float, float]
|
Center position (x, y) of the plane relative to the global origin (0,0). |
Source code in src\vectorwaves\config_stuff.py
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 | |
vectorwaves.config_stuff.KSpaceConfig
dataclass
Bases: SerializableConfig
k-Space Spatial Profile Configuration.
Controls how plane wave modes are weighted depending on their wavevector.
Access this via config.source.k_space.
Use fluent methods to modify the distribution:
config.source.k_space.gaussian(sigma_k_perp=2.0)
config.source.k_space.laguerre_gauss(p=0, l=1)
Attributes:
| Name | Type | Description |
|---|---|---|
profile |
Callable
|
The active profile function (from |
params |
Dict[str, Any]
|
Keyword arguments dynamically passed into the |
vectorised |
bool
|
If True, indicates the callable supports numpy array vectorization. |
Source code in src\vectorwaves\config_stuff.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
bessel_gauss(*, theta_deg=10.0, sigma_theta=0.05, l=0)
Sets k-space profile to a Bessel-Gauss mode, creating a non-diffracting core.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta_deg
|
float
|
Cone opening angle (in degrees) of the Bessel beam in k-space. |
10.0
|
sigma_theta
|
float
|
Angular thickness (in radians) of the Gaussian ring. |
0.05
|
l
|
int
|
Topological charge. If l != 0, creates a Higher-Order Bessel beam. |
0
|
Source code in src\vectorwaves\config_stuff.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 | |
custom(fn, vectorised=False, **params)
Sets a user-defined custom k-space profile function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
Function signature: fn(k: np.ndarray, **params) -> complex/np.ndarray |
required |
vectorised
|
bool
|
If True, |
False
|
**params
|
Any
|
Keyword arguments passed directly into |
{}
|
Notes
The provided function fn will be tested with a dummy wavevector
array (np.random.randn(3, 2) if vectorised else np.random.randn(3))
to validate its return type and shape.
Source code in src\vectorwaves\config_stuff.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
gaussian(sigma_k_perp=1.5)
Sets k-space profile to a Gaussian envelope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sigma_k_perp
|
float
|
The standard deviation of the Gaussian envelope in k-space. Inversely proportional to the real-space beam waist. |
1.5
|
Source code in src\vectorwaves\config_stuff.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
hermite_gauss(*, l=0, m=0, sigma_k_perp=0.5)
Sets k-space profile to a higher-order Hermite-Gauss transverse mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
l
|
int
|
Transverse mode index in the x-direction (l >= 0). |
0
|
m
|
int
|
Transverse mode index in the y-direction (m >= 0). |
0
|
sigma_k_perp
|
float
|
Transverse scaling parameter in k-space. |
0.5
|
Source code in src\vectorwaves\config_stuff.py
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
laguerre_gauss(*, p=0, l=0, sigma_k_perp=0.5)
Sets k-space profile to a Laguerre-Gauss mode carrying Orbital Angular Momentum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
int
|
Radial index (p >= 0). Determines the number of radial rings. |
0
|
l
|
int
|
Azimuthal index (topological charge). Determines the OAM. |
0
|
sigma_k_perp
|
float
|
Transverse scaling parameter in k-space. |
0.5
|
Source code in src\vectorwaves\config_stuff.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
tophat(k_perp_max=1.0)
Sets k-space profile to a sharp Top-Hat cutoff, producing an Airy disk in real space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
k_perp_max
|
float
|
The maximum transverse spatial frequency allowed. |
1.0
|
Source code in src\vectorwaves\config_stuff.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
uniform()
Sets k-space profile to a flat angular spectrum (Uniform k-space). Weights all plane waves equally.
Source code in src\vectorwaves\config_stuff.py
326 327 328 329 330 331 332 333 | |
vectorwaves.config_stuff.PolychromaticConfig
dataclass
Bases: SerializableConfig
Polychromatic Envelope Configuration.
Controls the spectral (wavelength) distribution of the beam. Access this
via config.source.polychromatic.
Use fluent methods to modify the distribution:
config.source.polychromatic.gaussian(center=8.0, sigma=0.5)
Attributes:
| Name | Type | Description |
|---|---|---|
profile |
Callable
|
The active profile function (from |
params |
Dict[str, Any]
|
Keyword arguments passed into the |
Source code in src\vectorwaves\config_stuff.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
custom(fn, **params)
Sets a user-defined custom polychromatic envelope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
Function signature: fn(wavelength: float, **params) -> float |
required |
**params
|
Any
|
Keyword arguments passed directly into |
{}
|
Notes
The provided function fn will be tested with a dummy wavelength
(8.0) to validate that it returns a finite scalar.
Source code in src\vectorwaves\config_stuff.py
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 | |
gaussian(center=8.0, sigma=0.5)
Sets a Gaussian spectral weight distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
float
|
The central wavelength (mean). |
8.0
|
sigma
|
float
|
The spectral bandwidth (standard deviation). |
0.5
|
Source code in src\vectorwaves\config_stuff.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 | |
lorentzian(center=8.0, gamma=0.5)
Sets a Lorentzian spectral weight distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
float
|
The central resonance wavelength. |
8.0
|
gamma
|
float
|
The Half-Width at Half-Maximum of the spectrum. |
0.5
|
Source code in src\vectorwaves\config_stuff.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 | |
tophat(center=8.0, width=1.0)
Sets a Top-Hat bandpass spectral envelope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
float
|
The central wavelength of the bandpass. |
8.0
|
width
|
float
|
The total spectral width of the bandpass. |
1.0
|
Source code in src\vectorwaves\config_stuff.py
528 529 530 531 532 533 534 535 536 537 538 539 540 541 | |
uniform()
Sets a flat spectral envelope (all wavelengths weighted equally).
Source code in src\vectorwaves\config_stuff.py
490 491 492 493 494 495 496 | |
vectorwaves.config_stuff.RandomizeConfig
dataclass
Bases: SerializableConfig
Stochastic Process Configuration.
Controls which aspects of the light field are randomized during generation
to simulate partially coherent beams, diffuse light, or specific speckle stats.
Access this via config.source.randomize.
Example:
To simulate fully coherent deterministic light:
config.source.randomize.off()
Attributes:
| Name | Type | Description |
|---|---|---|
seed |
int
|
Seed for the random number generator ensuring reproducible fields. |
phase_max |
float
|
Applies a random phase offset phi to each mode drawn from Uniform(-phase_max, +phase_max). This controls the degree of phase randomness: - phase_max = 0 for fully deterministic phase - 0 < phase_max < pi for partially randomized phase - phase_max = pi for fully randomized phase Must lie in [0, pi]. |
pol_rot_max |
float
|
Maximum random rotation angle applied to the polarization vector drawn from Uniform(-pol_rot_max, +pol_rot_max) Controls the spread of polarization orientations: - pol_rot_max = 0 for deterministic polarization orientation - 0 < pol_rot_max < pi for partially randomized orientation - pol_rot_max = pi for fully randomized orientation Must lie in [0, pi]. Ignored if |
pol_state |
bool
|
If True, samples fully random polarization states from the Poincaré sphere.
Overrides |
amplitude |
bool
|
If True, applies a complex random normal factor to the mode amplitude. |
Source code in src\vectorwaves\config_stuff.py
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 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 | |
off()
Turns off all randomness, making the beam perfectly coherent and deterministic.
Source code in src\vectorwaves\config_stuff.py
290 291 292 293 294 295 296 | |