goad-py 0.5.6__cp38-abi3-macosx_11_0_arm64.whl → 0.6.1__cp38-abi3-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of goad-py might be problematic. Click here for more details.

goad_py/_goad_py.abi3.so CHANGED
Binary file
@@ -11,6 +11,8 @@ Features:
11
11
  - Strict input validation
12
12
  - Uniform output format (UnifiedResults)
13
13
  - Support for parameter sweeps
14
+ - Full control over beam tracing, geometry transformations, and advanced optics
15
+ - Reproducible results via random seed control
14
16
  """
15
17
 
16
18
  from dataclasses import dataclass, field, asdict
@@ -211,6 +213,96 @@ class PHIPSMode(ConvergenceMode):
211
213
  # ============================================================================
212
214
 
213
215
 
216
+ @dataclass
217
+ class BeamTracingConfig:
218
+ """Beam tracing performance and accuracy parameters."""
219
+
220
+ beam_power_threshold: float = 0.01
221
+ beam_area_threshold_fac: float = 0.01
222
+ cutoff: float = 0.999
223
+ max_rec: int = 10
224
+ max_tir: int = 10
225
+
226
+ def __post_init__(self):
227
+ """Validate beam tracing parameters."""
228
+ if self.beam_power_threshold <= 0 or self.beam_power_threshold > 1:
229
+ raise ValueError(
230
+ f"beam_power_threshold must be in range (0, 1], got {self.beam_power_threshold}"
231
+ )
232
+
233
+ if self.beam_area_threshold_fac <= 0:
234
+ raise ValueError(
235
+ f"beam_area_threshold_fac must be positive, got {self.beam_area_threshold_fac}"
236
+ )
237
+
238
+ if self.cutoff < 0 or self.cutoff > 1:
239
+ raise ValueError(f"cutoff must be between 0 and 1, got {self.cutoff}")
240
+
241
+ if self.max_rec < 0:
242
+ raise ValueError(f"max_rec must be non-negative, got {self.max_rec}")
243
+
244
+ if self.max_tir < 0:
245
+ raise ValueError(f"max_tir must be non-negative, got {self.max_tir}")
246
+
247
+
248
+ @dataclass
249
+ class GeometryTransformConfig:
250
+ """Geometry transformation parameters.
251
+
252
+ Attributes:
253
+ scale: Problem scaling factor - scales the entire problem including geometry,
254
+ wavelength, and beam area thresholds (default: 1.0)
255
+ distortion: Geometry distortion factor (optional)
256
+ geom_scale: Per-axis geometry scaling [x, y, z] - scales only the geometry
257
+ in each dimension independently (optional)
258
+ """
259
+
260
+ scale: float = 1.0
261
+ distortion: Optional[float] = None
262
+ geom_scale: Optional[List[float]] = None
263
+
264
+ def __post_init__(self):
265
+ """Validate geometry transformations."""
266
+ if self.scale <= 0:
267
+ raise ValueError(f"scale must be positive, got {self.scale}")
268
+
269
+ if self.geom_scale is not None:
270
+ if len(self.geom_scale) != 3:
271
+ raise ValueError(
272
+ f"geom_scale must have exactly 3 values [x, y, z], "
273
+ f"got {len(self.geom_scale)}"
274
+ )
275
+ if any(s <= 0 for s in self.geom_scale):
276
+ raise ValueError("All geom_scale values must be positive")
277
+
278
+
279
+ @dataclass
280
+ class AdvancedConfig:
281
+ """Advanced optical calculation parameters."""
282
+
283
+ mapping: Optional[Any] = (
284
+ "ApertureDiffraction" # String that will be converted to enum in __post_init__
285
+ )
286
+ coherence: bool = True
287
+ fov_factor: Optional[float] = None
288
+
289
+ def __post_init__(self):
290
+ """Validate advanced optics settings and convert mapping string to enum."""
291
+ # Convert string mapping to enum if needed
292
+ if isinstance(self.mapping, str):
293
+ if self.mapping == "ApertureDiffraction":
294
+ self.mapping = goad.Mapping.ApertureDiffraction
295
+ elif self.mapping == "GeometricOptics":
296
+ self.mapping = goad.Mapping.GeometricOptics
297
+ else:
298
+ raise ValueError(
299
+ f"Invalid mapping '{self.mapping}'. Must be 'ApertureDiffraction' or 'GeometricOptics'"
300
+ )
301
+
302
+ if self.fov_factor is not None and self.fov_factor <= 0:
303
+ raise ValueError(f"fov_factor must be positive, got {self.fov_factor}")
304
+
305
+
214
306
  @dataclass
215
307
  class ConvergenceConfig:
216
308
  """
@@ -220,6 +312,29 @@ class ConvergenceConfig:
220
312
  - Standard convergence (integrated parameters, Mueller elements)
221
313
  - PHIPS detector convergence
222
314
  - Single geometry or ensemble averaging
315
+
316
+ Attributes:
317
+ geometry: Path to .obj file or directory of .obj files (ensemble)
318
+ mode: ConvergenceMode instance (StandardMode or PHIPSMode)
319
+ convergence_targets: List of convergence target dicts
320
+
321
+ wavelength: Wavelength in microns (default: 0.532)
322
+ particle_refr_index_re: Real part of particle refractive index (default: 1.31)
323
+ particle_refr_index_im: Imaginary part of particle refractive index (default: 0.0)
324
+ medium_refr_index_re: Real part of medium refractive index (default: 1.0)
325
+ medium_refr_index_im: Imaginary part of medium refractive index (default: 0.0)
326
+
327
+ batch_size: Orientations per batch (default: 24)
328
+ max_orientations: Maximum orientations (default: 100,000)
329
+ min_batches: Minimum batches before convergence check (default: 10)
330
+
331
+ beam_tracing: BeamTracingConfig instance for beam tracing parameters
332
+ geometry_transform: GeometryTransformConfig instance for geometry transformations
333
+ advanced_config: AdvancedConfig instance for advanced optical parameters
334
+ seed: Random seed for reproducibility (optional)
335
+
336
+ mueller_1d: Compute 1D Mueller matrix (default: True, standard mode only)
337
+ output_dir: Output directory path (optional)
223
338
  """
224
339
 
225
340
  # Required fields
@@ -239,6 +354,20 @@ class ConvergenceConfig:
239
354
  max_orientations: int = 100_000
240
355
  min_batches: int = 10
241
356
 
357
+ # Beam tracing configuration
358
+ beam_tracing: BeamTracingConfig = field(default_factory=BeamTracingConfig)
359
+
360
+ # Geometry transformations
361
+ geometry_transform: GeometryTransformConfig = field(
362
+ default_factory=GeometryTransformConfig
363
+ )
364
+
365
+ # Advanced optics
366
+ advanced_config: AdvancedConfig = field(default_factory=AdvancedConfig)
367
+
368
+ # Random seed for reproducibility
369
+ seed: Optional[int] = None
370
+
242
371
  # Mueller matrix output (only for StandardMode)
243
372
  mueller_1d: bool = True
244
373
 
@@ -312,6 +441,24 @@ class ConvergenceConfig:
312
441
  "batch_size": self.batch_size,
313
442
  "max_orientations": self.max_orientations,
314
443
  "min_batches": self.min_batches,
444
+ "beam_tracing": {
445
+ "beam_power_threshold": self.beam_tracing.beam_power_threshold,
446
+ "beam_area_threshold_fac": self.beam_tracing.beam_area_threshold_fac,
447
+ "cutoff": self.beam_tracing.cutoff,
448
+ "max_rec": self.beam_tracing.max_rec,
449
+ "max_tir": self.beam_tracing.max_tir,
450
+ },
451
+ "geometry_transform": {
452
+ "scale": self.geometry_transform.scale,
453
+ "distortion": self.geometry_transform.distortion,
454
+ "geom_scale": self.geometry_transform.geom_scale,
455
+ },
456
+ "advanced_config": {
457
+ "mapping": str(self.advanced_config.mapping),
458
+ "coherence": self.advanced_config.coherence,
459
+ "fov_factor": self.advanced_config.fov_factor,
460
+ },
461
+ "seed": self.seed,
315
462
  "mueller_1d": self.mueller_1d,
316
463
  "is_ensemble": self.is_ensemble(),
317
464
  }
@@ -664,7 +811,7 @@ class UnifiedConvergence:
664
811
  else:
665
812
  geom_path_str = str(self.config.geometry)
666
813
 
667
- # Create GOAD settings
814
+ # Create GOAD settings with all parameters
668
815
  settings = goad.Settings(
669
816
  geom_path=geom_path_str,
670
817
  wavelength=self.config.wavelength,
@@ -673,8 +820,32 @@ class UnifiedConvergence:
673
820
  medium_refr_index_re=self.config.medium_refr_index_re,
674
821
  medium_refr_index_im=self.config.medium_refr_index_im,
675
822
  binning=self.config.mode.get_binning(),
823
+ # Beam tracing parameters
824
+ beam_power_threshold=self.config.beam_tracing.beam_power_threshold,
825
+ beam_area_threshold_fac=self.config.beam_tracing.beam_area_threshold_fac,
826
+ cutoff=self.config.beam_tracing.cutoff,
827
+ max_rec=self.config.beam_tracing.max_rec,
828
+ max_tir=self.config.beam_tracing.max_tir,
829
+ # Geometry transformations
830
+ scale=self.config.geometry_transform.scale,
831
+ # Advanced configuration
832
+ mapping=self.config.advanced_config.mapping,
833
+ coherence=self.config.advanced_config.coherence,
676
834
  )
677
835
 
836
+ # Set optional parameters if provided
837
+ if self.config.seed is not None:
838
+ settings.seed = self.config.seed
839
+
840
+ if self.config.geometry_transform.distortion is not None:
841
+ settings.distortion = self.config.geometry_transform.distortion
842
+
843
+ if self.config.geometry_transform.geom_scale is not None:
844
+ settings.geom_scale = self.config.geometry_transform.geom_scale
845
+
846
+ if self.config.advanced_config.fov_factor is not None:
847
+ settings.fov_factor = self.config.advanced_config.fov_factor
848
+
678
849
  # Create convergence instance based on mode
679
850
  if isinstance(self.config.mode, StandardMode):
680
851
  self._setup_standard(settings)
@@ -881,19 +1052,46 @@ def run_convergence(
881
1052
  tolerance_type: "relative" or "absolute"
882
1053
  mode: ConvergenceMode instance, or string "auto"/"standard"/"phips"
883
1054
  **kwargs: Additional settings:
1055
+ # Optical settings
884
1056
  - wavelength: Wavelength in microns (default: 0.532)
885
1057
  - particle_refr_index_re: Real part of particle refractive index
886
1058
  - particle_refr_index_im: Imaginary part of particle refractive index
887
1059
  - medium_refr_index_re: Real part of medium refractive index
888
1060
  - medium_refr_index_im: Imaginary part of medium refractive index
1061
+
1062
+ # Convergence parameters
889
1063
  - batch_size: Orientations per batch (default: 24)
890
1064
  - max_orientations: Maximum orientations (default: 100,000)
891
1065
  - min_batches: Minimum batches before convergence (default: 10)
892
1066
  - mueller_1d: Compute 1D Mueller matrix (default: True, standard mode only)
1067
+
1068
+ # Mode settings
893
1069
  - phips_bins_file: Path to PHIPS bins TOML (required if mode="phips")
894
1070
  - n_theta: Number of theta bins for standard mode (default: 181)
895
1071
  - n_phi: Number of phi bins for standard mode (default: 181)
896
1072
 
1073
+ # Beam tracing parameters
1074
+ - beam_power_threshold: Beam power threshold (default: 0.05)
1075
+ - beam_area_threshold_fac: Beam area threshold factor (default: 4.0)
1076
+ - cutoff: Ray power cutoff (default: 0.001)
1077
+ - max_rec: Max recursion depth (default: 100)
1078
+ - max_tir: Max TIR bounces (default: 100)
1079
+
1080
+ # Geometry transformations
1081
+ - scale: Problem scaling factor - scales entire problem including geometry,
1082
+ wavelength, and beam area thresholds (default: 1.0)
1083
+ - distortion: Geometry distortion factor (optional)
1084
+ - geom_scale: Per-axis geometry scaling [x, y, z] - scales only geometry
1085
+ in each dimension independently (optional)
1086
+
1087
+ # Advanced configuration
1088
+ - mapping: DSCS mapping scheme (default: goad.Mapping.ApertureDiffraction)
1089
+ - coherence: Enable coherent scattering (default: False)
1090
+ - fov_factor: Field of view factor (optional)
1091
+
1092
+ # Reproducibility
1093
+ - seed: Random seed for orientations (optional)
1094
+
897
1095
  Returns:
898
1096
  UnifiedResults object
899
1097
 
@@ -924,7 +1122,44 @@ def run_convergence(
924
1122
  [{"variable": "S11", "tolerance": 0.1, "theta_indices": [180]}],
925
1123
  batch_size=12
926
1124
  )
1125
+
1126
+ # Advanced: custom beam tracing and geometry scaling
1127
+ results = run_convergence(
1128
+ "complex_particle.obj",
1129
+ "asymmetry",
1130
+ max_rec=200,
1131
+ max_tir=150,
1132
+ cutoff=0.0001,
1133
+ scale=2.0,
1134
+ seed=42
1135
+ )
927
1136
  """
1137
+ # Extract beam tracing parameters from kwargs
1138
+ beam_tracing = BeamTracingConfig(
1139
+ beam_power_threshold=kwargs.pop("beam_power_threshold", 0.05),
1140
+ beam_area_threshold_fac=kwargs.pop("beam_area_threshold_fac", 4.0),
1141
+ cutoff=kwargs.pop("cutoff", 0.001),
1142
+ max_rec=kwargs.pop("max_rec", 100),
1143
+ max_tir=kwargs.pop("max_tir", 100),
1144
+ )
1145
+
1146
+ # Extract geometry transform parameters
1147
+ geometry_transform = GeometryTransformConfig(
1148
+ scale=kwargs.pop("scale", 1.0),
1149
+ distortion=kwargs.pop("distortion", None),
1150
+ geom_scale=kwargs.pop("geom_scale", None),
1151
+ )
1152
+
1153
+ # Extract advanced configuration parameters
1154
+ advanced_config = AdvancedConfig(
1155
+ mapping=kwargs.pop("mapping", "ApertureDiffraction"),
1156
+ coherence=kwargs.pop("coherence", False),
1157
+ fov_factor=kwargs.pop("fov_factor", None),
1158
+ )
1159
+
1160
+ # Extract seed
1161
+ seed = kwargs.pop("seed", None)
1162
+
928
1163
  # Normalize targets to list of dicts
929
1164
  target_dicts = _normalize_targets(targets, tolerance, tolerance_type)
930
1165
 
@@ -946,9 +1181,16 @@ def run_convergence(
946
1181
  f"Invalid mode string '{mode}'. Must be 'auto', 'standard', or 'phips'"
947
1182
  )
948
1183
 
949
- # Build config
1184
+ # Build config with new parameters
950
1185
  config = ConvergenceConfig(
951
- geometry=geometry, mode=mode, convergence_targets=target_dicts, **kwargs
1186
+ geometry=geometry,
1187
+ mode=mode,
1188
+ convergence_targets=target_dicts,
1189
+ beam_tracing=beam_tracing,
1190
+ geometry_transform=geometry_transform,
1191
+ advanced_config=advanced_config,
1192
+ seed=seed,
1193
+ **kwargs, # Remaining kwargs (wavelength, particle_refr_index_re, etc.)
952
1194
  )
953
1195
 
954
1196
  # Run
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: goad-py
3
- Version: 0.5.6
3
+ Version: 0.6.1
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Science/Research
6
6
  Classifier: Topic :: Scientific/Engineering :: Physics
@@ -0,0 +1,9 @@
1
+ goad_py-0.6.1.dist-info/METADATA,sha256=kGFetpGrkXnyWZ4SgfvDOMh1Sgo9inQOS4poCBSVFLU,3238
2
+ goad_py-0.6.1.dist-info/WHEEL,sha256=gnJiauUA-C9eduukCSYPRAnEnckuUqP6yenZ8c1xV7c,102
3
+ goad_py/__init__.py,sha256=iGJg-Oj9btk4I4GITkE7olNRm38uFRjENMJqXaDJmpM,1083
4
+ goad_py/_goad_py.abi3.so,sha256=hJ2SL2WtyQTYxPhdiNYojSexIWZxK4B-u-rbt3XxIP4,1844320
5
+ goad_py/convergence.py,sha256=hXVvlfjVEKpOlxoiJ_NGDzDlCoSqyo6V7g3OxNp2xUA,35209
6
+ goad_py/goad_py.pyi,sha256=7Y79-TV-NjEN8DWPEqSRGQ7alCrkylL6y1ZK8d6FYSg,14502
7
+ goad_py/phips_convergence.py,sha256=sA7XIjKRLaRTIDCTjgq0i6xFxYhTD1rcu6ZMYAetDPE,21803
8
+ goad_py/unified_convergence.py,sha256=mZzMDAjQha_bx3NENnHQw2EdBW0pgRV5ApKucsYwUBg,49210
9
+ goad_py-0.6.1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- goad_py-0.5.6.dist-info/METADATA,sha256=B4caJBKrQJM6QzfTQB4CyUNNbkjND3ZFYh-4_0XJL-Y,3238
2
- goad_py-0.5.6.dist-info/WHEEL,sha256=gnJiauUA-C9eduukCSYPRAnEnckuUqP6yenZ8c1xV7c,102
3
- goad_py/__init__.py,sha256=iGJg-Oj9btk4I4GITkE7olNRm38uFRjENMJqXaDJmpM,1083
4
- goad_py/_goad_py.abi3.so,sha256=BEEzN1AGmxU3r4T6xR_7Wui8iCpxdhQ8hZ0bl6cqnkg,1844256
5
- goad_py/convergence.py,sha256=hXVvlfjVEKpOlxoiJ_NGDzDlCoSqyo6V7g3OxNp2xUA,35209
6
- goad_py/goad_py.pyi,sha256=7Y79-TV-NjEN8DWPEqSRGQ7alCrkylL6y1ZK8d6FYSg,14502
7
- goad_py/phips_convergence.py,sha256=sA7XIjKRLaRTIDCTjgq0i6xFxYhTD1rcu6ZMYAetDPE,21803
8
- goad_py/unified_convergence.py,sha256=ZVlyaTpMiZ80dG_NLWjmO1CukFkBeWy4P7KAkUW7Zmo,39362
9
- goad_py-0.5.6.dist-info/RECORD,,