Experiments
metasurface_py.experiments
Reproducible experiment management.
ExperimentConfig
Bases: BaseModel
Serializable experiment configuration.
Describes a complete experiment: geometry, cell model, optimization objective, and solver settings. Can be saved/loaded as TOML.
ExperimentResult
dataclass
Result of an experiment run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ExperimentConfig
|
The experiment configuration used. |
required |
optimization
|
OptimizationResult
|
The optimization result. |
required |
environment
|
dict[str, Any]
|
Environment metadata for reproducibility. |
dict()
|
build_from_config(config)
Instantiate objects from an experiment config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ExperimentConfig
|
Experiment configuration. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Metasurface, Any, AngleGrid]
|
Tuple of (Metasurface, Objective, AngleGrid). |
capture_environment()
Capture current environment for reproducibility.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with package version, Python version, platform, |
dict[str, Any]
|
git commit hash, and timestamp. |
run_experiment(config)
Execute an experiment from a configuration.
Builds the metasurface, objective, and angles from config, then runs relax_then_quantize optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ExperimentConfig
|
Experiment configuration. |
required |
Returns:
| Type | Description |
|---|---|
ExperimentResult
|
ExperimentResult with optimization result and provenance. |
set_global_seed(seed)
Set global random seed for reproducibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int
|
Random seed value. |
required |