gsim 0.0.0__py3-none-any.whl → 0.0.2__py3-none-any.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.
- gsim/__init__.py +1 -1
- gsim/common/__init__.py +61 -0
- gsim/common/geometry.py +76 -0
- gsim/{palace → common}/stack/__init__.py +8 -5
- gsim/{palace → common}/stack/extractor.py +29 -103
- gsim/{palace → common}/stack/materials.py +27 -11
- gsim/palace/__init__.py +94 -43
- gsim/palace/base.py +68 -0
- gsim/palace/driven.py +1004 -0
- gsim/palace/eigenmode.py +777 -0
- gsim/palace/electrostatic.py +622 -0
- gsim/palace/mesh/generator.py +201 -20
- gsim/palace/mesh/pipeline.py +22 -1
- gsim/palace/models/__init__.py +60 -0
- gsim/palace/models/geometry.py +34 -0
- gsim/palace/models/mesh.py +95 -0
- gsim/palace/models/numerical.py +66 -0
- gsim/palace/models/ports.py +138 -0
- gsim/palace/models/problems.py +195 -0
- gsim/palace/models/results.py +159 -0
- gsim/palace/models/stack.py +59 -0
- gsim/palace/ports/config.py +1 -1
- {gsim-0.0.0.dist-info → gsim-0.0.2.dist-info}/METADATA +5 -3
- gsim-0.0.2.dist-info/RECORD +32 -0
- gsim-0.0.0.dist-info/RECORD +0 -18
- /gsim/{palace → common}/stack/visualization.py +0 -0
- {gsim-0.0.0.dist-info → gsim-0.0.2.dist-info}/WHEEL +0 -0
- {gsim-0.0.0.dist-info → gsim-0.0.2.dist-info}/top_level.txt +0 -0
gsim/palace/__init__.py
CHANGED
|
@@ -4,38 +4,25 @@ This module provides a comprehensive API for setting up and running
|
|
|
4
4
|
electromagnetic simulations using the Palace solver with gdsfactory components.
|
|
5
5
|
|
|
6
6
|
Features:
|
|
7
|
+
- Problem-specific simulation classes (DrivenSim, EigenmodeSim, ElectrostaticSim)
|
|
7
8
|
- Layer stack extraction from PDK
|
|
8
9
|
- Port configuration (inplane, via, CPW)
|
|
9
10
|
- Mesh generation with COMSOL-style presets
|
|
10
11
|
- Palace config file generation
|
|
11
12
|
|
|
12
13
|
Usage:
|
|
13
|
-
from gsim.palace import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# Via port (vertical, between two layers - for microstrip feed)
|
|
27
|
-
configure_via_port(c.ports['feed'], from_layer='metal1', to_layer='topmetal2')
|
|
28
|
-
|
|
29
|
-
# 3. Extract configured ports
|
|
30
|
-
ports = extract_ports(c, stack)
|
|
31
|
-
|
|
32
|
-
# 4. Generate mesh
|
|
33
|
-
result = generate_mesh(
|
|
34
|
-
component=c,
|
|
35
|
-
stack=stack,
|
|
36
|
-
ports=ports,
|
|
37
|
-
output_dir="./simulation",
|
|
38
|
-
)
|
|
14
|
+
from gsim.palace import DrivenSim
|
|
15
|
+
|
|
16
|
+
# Create and configure simulation
|
|
17
|
+
sim = DrivenSim()
|
|
18
|
+
sim.set_geometry(component)
|
|
19
|
+
sim.set_stack(air_above=300.0)
|
|
20
|
+
sim.add_cpw_port("P2", "P1", layer="topmetal2", length=5.0)
|
|
21
|
+
sim.set_driven(fmin=1e9, fmax=100e9)
|
|
22
|
+
|
|
23
|
+
# Generate mesh and run
|
|
24
|
+
sim.mesh("./sim", preset="fine")
|
|
25
|
+
results = sim.simulate()
|
|
39
26
|
"""
|
|
40
27
|
|
|
41
28
|
from __future__ import annotations
|
|
@@ -44,6 +31,16 @@ from functools import partial
|
|
|
44
31
|
|
|
45
32
|
from gsim.gcloud import print_job_summary
|
|
46
33
|
from gsim.gcloud import run_simulation as _run_simulation
|
|
34
|
+
|
|
35
|
+
# Common components (shared with FDTD)
|
|
36
|
+
from gsim.common import Geometry, LayerStack, Stack
|
|
37
|
+
|
|
38
|
+
# New simulation classes (composition, no inheritance)
|
|
39
|
+
from gsim.palace.driven import DrivenSim
|
|
40
|
+
from gsim.palace.eigenmode import EigenmodeSim
|
|
41
|
+
from gsim.palace.electrostatic import ElectrostaticSim
|
|
42
|
+
|
|
43
|
+
# Mesh utilities
|
|
47
44
|
from gsim.palace.mesh import (
|
|
48
45
|
GroundPlane,
|
|
49
46
|
MeshConfig,
|
|
@@ -51,6 +48,27 @@ from gsim.palace.mesh import (
|
|
|
51
48
|
MeshResult,
|
|
52
49
|
generate_mesh,
|
|
53
50
|
)
|
|
51
|
+
|
|
52
|
+
# Models (new submodule)
|
|
53
|
+
from gsim.palace.models import (
|
|
54
|
+
CPWPortConfig,
|
|
55
|
+
DrivenConfig,
|
|
56
|
+
EigenmodeConfig,
|
|
57
|
+
ElectrostaticConfig,
|
|
58
|
+
GeometryConfig,
|
|
59
|
+
MagnetostaticConfig,
|
|
60
|
+
MaterialConfig,
|
|
61
|
+
MeshConfig as MeshConfigModel,
|
|
62
|
+
NumericalConfig,
|
|
63
|
+
PortConfig,
|
|
64
|
+
SimulationResult,
|
|
65
|
+
TerminalConfig,
|
|
66
|
+
TransientConfig,
|
|
67
|
+
ValidationResult,
|
|
68
|
+
WavePortConfig,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Port utilities
|
|
54
72
|
from gsim.palace.ports import (
|
|
55
73
|
PalacePort,
|
|
56
74
|
PortGeometry,
|
|
@@ -60,13 +78,15 @@ from gsim.palace.ports import (
|
|
|
60
78
|
configure_via_port,
|
|
61
79
|
extract_ports,
|
|
62
80
|
)
|
|
63
|
-
|
|
81
|
+
|
|
82
|
+
# Stack utilities (from common, shared with FDTD)
|
|
83
|
+
from gsim.common.stack import (
|
|
64
84
|
MATERIALS_DB,
|
|
65
85
|
Layer,
|
|
66
86
|
LayerStack,
|
|
67
87
|
MaterialProperties,
|
|
68
88
|
StackLayer,
|
|
69
|
-
ValidationResult,
|
|
89
|
+
ValidationResult as StackValidationResult,
|
|
70
90
|
extract_from_pdk,
|
|
71
91
|
extract_layer_stack,
|
|
72
92
|
get_material_properties,
|
|
@@ -79,40 +99,71 @@ from gsim.palace.stack import (
|
|
|
79
99
|
print_stack,
|
|
80
100
|
print_stack_table,
|
|
81
101
|
)
|
|
102
|
+
|
|
103
|
+
# Visualization
|
|
82
104
|
from gsim.viz import plot_mesh
|
|
83
105
|
|
|
106
|
+
|
|
84
107
|
__all__ = [
|
|
108
|
+
# Primary simulation classes (new API)
|
|
109
|
+
"DrivenSim",
|
|
110
|
+
"EigenmodeSim",
|
|
111
|
+
"ElectrostaticSim",
|
|
112
|
+
# Common components (shared with FDTD)
|
|
113
|
+
"Geometry",
|
|
114
|
+
"Stack",
|
|
115
|
+
# Problem configs
|
|
116
|
+
"DrivenConfig",
|
|
117
|
+
"EigenmodeConfig",
|
|
118
|
+
"ElectrostaticConfig",
|
|
119
|
+
"MagnetostaticConfig",
|
|
120
|
+
"TransientConfig",
|
|
121
|
+
# Port configs
|
|
122
|
+
"CPWPortConfig",
|
|
123
|
+
"PortConfig",
|
|
124
|
+
"TerminalConfig",
|
|
125
|
+
"WavePortConfig",
|
|
126
|
+
# Other configs
|
|
127
|
+
"GeometryConfig",
|
|
128
|
+
"MaterialConfig",
|
|
129
|
+
"MeshConfigModel",
|
|
130
|
+
"NumericalConfig",
|
|
131
|
+
"SimulationResult",
|
|
132
|
+
"ValidationResult",
|
|
133
|
+
# Stack utilities
|
|
85
134
|
"MATERIALS_DB",
|
|
86
|
-
"GroundPlane",
|
|
87
135
|
"Layer",
|
|
88
136
|
"LayerStack",
|
|
89
137
|
"MaterialProperties",
|
|
138
|
+
"extract_from_pdk",
|
|
139
|
+
"extract_layer_stack",
|
|
140
|
+
"get_material_properties",
|
|
141
|
+
"get_stack",
|
|
142
|
+
"load_stack_yaml",
|
|
143
|
+
"material_is_conductor",
|
|
144
|
+
"material_is_dielectric",
|
|
145
|
+
"parse_layer_stack",
|
|
146
|
+
"plot_stack",
|
|
147
|
+
"print_stack",
|
|
148
|
+
"print_stack_table",
|
|
149
|
+
# Mesh utilities
|
|
150
|
+
"GroundPlane",
|
|
90
151
|
"MeshConfig",
|
|
91
152
|
"MeshPreset",
|
|
92
153
|
"MeshResult",
|
|
154
|
+
"generate_mesh",
|
|
155
|
+
"plot_mesh",
|
|
156
|
+
# Port utilities
|
|
93
157
|
"PalacePort",
|
|
94
158
|
"PortGeometry",
|
|
95
159
|
"PortType",
|
|
96
160
|
"StackLayer",
|
|
97
|
-
"ValidationResult",
|
|
98
161
|
"configure_cpw_port",
|
|
99
162
|
"configure_inplane_port",
|
|
100
163
|
"configure_via_port",
|
|
101
|
-
"extract_from_pdk",
|
|
102
|
-
"extract_layer_stack",
|
|
103
164
|
"extract_ports",
|
|
104
|
-
|
|
105
|
-
"get_material_properties",
|
|
106
|
-
"get_stack",
|
|
107
|
-
"load_stack_yaml",
|
|
108
|
-
"material_is_conductor",
|
|
109
|
-
"material_is_dielectric",
|
|
110
|
-
"parse_layer_stack",
|
|
111
|
-
"plot_mesh",
|
|
112
|
-
"plot_stack",
|
|
165
|
+
# Cloud
|
|
113
166
|
"print_job_summary",
|
|
114
|
-
"print_stack",
|
|
115
|
-
"print_stack_table",
|
|
116
167
|
"run_simulation",
|
|
117
168
|
]
|
|
118
169
|
|
gsim/palace/base.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"""Base mixin for Palace simulation classes.
|
|
2
|
+
|
|
3
|
+
Provides common visualization methods shared across all simulation types.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
if TYPE_CHECKING:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PalaceSimMixin:
|
|
16
|
+
"""Mixin providing common methods for all Palace simulation classes.
|
|
17
|
+
|
|
18
|
+
Requires the class to have:
|
|
19
|
+
- _output_dir: Path | None (private attribute)
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
_output_dir: Path | None
|
|
23
|
+
|
|
24
|
+
def plot_mesh(
|
|
25
|
+
self,
|
|
26
|
+
output: str | Path | None = None,
|
|
27
|
+
show_groups: list[str] | None = None,
|
|
28
|
+
interactive: bool = True,
|
|
29
|
+
) -> None:
|
|
30
|
+
"""Plot the mesh wireframe using PyVista.
|
|
31
|
+
|
|
32
|
+
Requires mesh() to be called first.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
output: Output PNG path (only used if interactive=False)
|
|
36
|
+
show_groups: List of group name patterns to show (None = all).
|
|
37
|
+
Example: ["metal", "P"] to show metal layers and ports.
|
|
38
|
+
interactive: If True, open interactive 3D viewer.
|
|
39
|
+
If False, save static PNG to output path.
|
|
40
|
+
|
|
41
|
+
Raises:
|
|
42
|
+
ValueError: If output_dir not set or mesh file doesn't exist
|
|
43
|
+
|
|
44
|
+
Example:
|
|
45
|
+
>>> sim.mesh(preset="default")
|
|
46
|
+
>>> sim.plot_mesh(show_groups=["metal", "P"])
|
|
47
|
+
"""
|
|
48
|
+
from gsim.viz import plot_mesh as _plot_mesh
|
|
49
|
+
|
|
50
|
+
if self._output_dir is None:
|
|
51
|
+
raise ValueError("Output directory not set. Call set_output_dir() first.")
|
|
52
|
+
|
|
53
|
+
mesh_path = self._output_dir / "palace.msh"
|
|
54
|
+
if not mesh_path.exists():
|
|
55
|
+
raise ValueError(
|
|
56
|
+
f"Mesh file not found: {mesh_path}. Call mesh() first."
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Default output path if not interactive
|
|
60
|
+
if output is None and not interactive:
|
|
61
|
+
output = self._output_dir / "mesh.png"
|
|
62
|
+
|
|
63
|
+
_plot_mesh(
|
|
64
|
+
msh_path=mesh_path,
|
|
65
|
+
output=output,
|
|
66
|
+
show_groups=show_groups,
|
|
67
|
+
interactive=interactive,
|
|
68
|
+
)
|