Skip to content

Commit

Permalink
Force supported layer–port delimiter for Elmer & Palace
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosavola committed Oct 17, 2023
1 parent d24d7c2 commit da5dbee
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
3 changes: 1 addition & 2 deletions docs/notebooks/elmer_01_electrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
c.add_ports(cap.ports)
substrate = gf.components.bbox(bbox=simulation_box, layer=LAYER.WAFER)
c << substrate
c = c.flatten()
c.plot()

# %% [markdown]
Expand Down Expand Up @@ -135,7 +134,7 @@
"resolution": 40,
},
**{
f"bw{port}": {
f"bw__{port}": { # `__` is used as the layer–port delimiter for Elmer
"resolution": 20,
"DistMax": 30,
"DistMin": 10,
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/palace_01_electrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
c.add_ports(cap.ports)
substrate = gf.components.bbox(bbox=simulation_box, layer=LAYER.WAFER)
c << substrate
c.flatten()
c.plot()

# %% [markdown]
# ## Running the simulation
Expand Down Expand Up @@ -132,7 +132,7 @@
"resolution": 40,
},
**{
f"bw{port}": {
f"bw__{port}": { # `__` is used as the layer–port delimiter for Palace
"resolution": 20,
"DistMax": 30,
"DistMin": 10,
Expand Down
1 change: 0 additions & 1 deletion docs/notebooks/palace_02_fullwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@

substrate = gf.components.bbox(bbox=simulation_box, layer=LAYER.WAFER)
c << substrate
c.flatten()
c.show()

# %% [markdown]
Expand Down
6 changes: 2 additions & 4 deletions gplugins/elmer/get_capacitance.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def run_capacitive_simulation_elmer(
simulation_folder = Path(simulation_folder or temp_dir.name)
simulation_folder.mkdir(exist_ok=True, parents=True)

port_delimiter = "__" # won't cause trouble unlike #
filename = component.name + ".msh"
if mesh_file:
shutil.copyfile(str(mesh_file), str(simulation_folder / filename))
Expand All @@ -225,7 +226,7 @@ def run_capacitive_simulation_elmer(
type="3D",
filename=simulation_folder / filename,
layer_stack=layer_stack,
**(mesh_parameters or {}),
**((mesh_parameters or {}) | {"layer_port_delimiter": port_delimiter}),
)

# `interruptible` works on gmsh versions >= 4.11.2
Expand All @@ -248,9 +249,6 @@ def run_capacitive_simulation_elmer(
next(k for k, v in layer_stack.layers.items() if v.layer == port.layer)
for port in component.get_ports()
} # ports allowed only on metal
# TODO infer port delimiter from somewhere
# TODO raise error for port delimiters not supported by Elmer MATC or find how to escape
port_delimiter = "__"
metal_surfaces = [
e for e in mesh_surface_entities if any(ground in e for ground in ground_layers)
]
Expand Down
3 changes: 0 additions & 3 deletions gplugins/elmer/tests/test_elmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_reasonable_mesh_parameters(c: Component):
)


@pytest.mark.skip(reason="FIXME")
def test_elmer_capacitance_simulation_runs(geometry) -> None:
c = geometry
run_capacitive_simulation_elmer(
Expand All @@ -91,7 +90,6 @@ def test_elmer_capacitance_simulation_runs(geometry) -> None:
)


@pytest.mark.skip(reason="FIXME")
@pytest.mark.parametrize("n_processes", [(1), (2), (4)])
def test_elmer_capacitance_simulation_n_processes(geometry, n_processes):
c = geometry
Expand All @@ -104,7 +102,6 @@ def test_elmer_capacitance_simulation_n_processes(geometry, n_processes):
)


@pytest.mark.skip(reason="FIXME")
@pytest.mark.parametrize("element_order", [(1), (2), (3)])
def test_elmer_capacitance_simulation_element_order(geometry, element_order) -> None:
c = geometry
Expand Down
5 changes: 2 additions & 3 deletions gplugins/palace/get_capacitance.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def run_capacitive_simulation_palace(
simulation_folder = Path(simulation_folder or temp_dir.name)
simulation_folder.mkdir(exist_ok=True, parents=True)

port_delimiter = "__" # won't cause trouble unlike #
filename = component.name + ".msh"
if mesh_file:
shutil.copyfile(str(mesh_file), str(simulation_folder / filename))
Expand All @@ -244,7 +245,7 @@ def run_capacitive_simulation_palace(
layer_stack=layer_stack,
n_threads=n_processes,
gmsh_version=2.2, # see https://mfem.org/mesh-formats/#gmsh-mesh-formats
**(mesh_parameters or {}),
**((mesh_parameters or {}) | {"layer_port_delimiter": port_delimiter}),
)

# re-read the mesh
Expand All @@ -267,8 +268,6 @@ def run_capacitive_simulation_palace(
next(k for k, v in layer_stack.layers.items() if v.layer == port.layer)
for port in component.get_ports()
} # ports allowed only on metal
# TODO infer port delimiter from somewhere
port_delimiter = "__"
metal_surfaces = [
e for e in mesh_surface_entities if any(ground in e for ground in ground_layers)
]
Expand Down

0 comments on commit da5dbee

Please sign in to comment.