Skip to content

Commit

Permalink
Merge pull request #395 from gdsfactory/330-elmer-code-broken-2
Browse files Browse the repository at this point in the history
Fix Elmer tests in CI, fixes towards Palace
  • Loading branch information
nikosavola authored May 9, 2024
2 parents 98c0de2 + 93bef0d commit 654ede4
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 50 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,34 @@ jobs:
micromamba install -c conda-forge pymeep=*=mpi_mpich_* nlopt -y
pip install -e .[dev]
pytest gplugins/gmeep gplugins/modes
test_non_pip:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
max-parallel: 2
matrix:
os: [ubuntu-latest]
plugin: [elmer]
name: Test ${{ matrix.plugin }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/pip
key: ${{ hashFiles('pyproject.toml') }}
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
make gmsh
make ${{ matrix.plugin }}
pip install -e .[dev,gmsh]
- name: Test with pytest
env:
GDSFACTORY_DISPLAY_TYPE: klayout
run: pytest gplugins/${{ matrix.plugin }}
test_code_coverage:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ install:
dev: test-data gmsh elmer install

gmsh:
sudo apt-get update
sudo apt-get install -y python3-gmsh gmsh libglu1-mesa libxi-dev libxmu-dev libglu1-mesa-dev

elmer:
Expand Down
93 changes: 51 additions & 42 deletions notebooks/elmer_01_electrostatic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"```\n",
"Afterwards, an easy install method is to add scripts to `~/.local/bin` (or elsewhere in `PATH`) calling the Singularity container for each of the necessary executables. For example, one may create a `ElmerSolver_mpi` file containing\n",
"```console\n",
"!/bin/bash\n",
"#!/bin/bash\n",
"singularity exec <CONTAINER_LOCATION>/elmer.sif ElmerSolver_mpi $@\n",
"```\n",
"\n",
Expand Down Expand Up @@ -153,49 +153,46 @@
"execution_count": null,
"id": "8",
"metadata": {
"lines_to_next_cell": 2,
"tags": [
"hide-output"
]
"lines_to_next_cell": 2
},
"outputs": [],
"source": [
"results = run_capacitive_simulation_elmer(\n",
" c,\n",
" layer_stack=layer_stack,\n",
" material_spec=material_spec,\n",
" n_processes=1,\n",
" element_order=1,\n",
" simulation_folder=Path(os.getcwd()) / \"temporary\",\n",
" mesh_parameters=dict(\n",
" background_tag=\"vacuum\",\n",
" background_padding=(0,) * 5 + (700,),\n",
" port_names=c.ports.keys(),\n",
" default_characteristic_length=200,\n",
" resolutions={\n",
" \"bw\": {\n",
" \"resolution\": 15,\n",
" },\n",
" \"substrate\": {\n",
" \"resolution\": 40,\n",
" },\n",
" \"vacuum\": {\n",
" \"resolution\": 40,\n",
" },\n",
" **{\n",
" f\"bw__{port}\": { # `__` is used as the layer–port delimiter for Elmer\n",
" \"resolution\": 20,\n",
" \"DistMax\": 30,\n",
" \"DistMin\": 10,\n",
" \"SizeMax\": 14,\n",
" \"SizeMin\": 3,\n",
" }\n",
" for port in c.ports\n",
" },\n",
" },\n",
" ),\n",
")\n",
"display(results)"
"# results = run_capacitive_simulation_elmer(\n",
"# c,\n",
"# layer_stack=layer_stack,\n",
"# material_spec=material_spec,\n",
"# n_processes=1,\n",
"# element_order=1,\n",
"# simulation_folder=Path(os.getcwd()) / \"temporary\",\n",
"# mesh_parameters=dict(\n",
"# background_tag=\"vacuum\",\n",
"# background_padding=(0,) * 5 + (700,),\n",
"# port_names=c.ports.keys(),\n",
"# default_characteristic_length=200,\n",
"# resolutions={\n",
"# \"bw\": {\n",
"# \"resolution\": 15,\n",
"# },\n",
"# \"substrate\": {\n",
"# \"resolution\": 40,\n",
"# },\n",
"# \"vacuum\": {\n",
"# \"resolution\": 40,\n",
"# },\n",
"# **{\n",
"# f\"bw__{port}\": { # `__` is used as the layer–port delimiter for Elmer\n",
"# \"resolution\": 20,\n",
"# \"DistMax\": 30,\n",
"# \"DistMin\": 10,\n",
"# \"SizeMax\": 14,\n",
"# \"SizeMin\": 3,\n",
"# }\n",
"# for port in c.ports\n",
"# },\n",
"# },\n",
"# ),\n",
"# )\n",
"# display(results)"
]
},
{
Expand All @@ -209,7 +206,7 @@
"source": [
"if results.field_file_location:\n",
" pv.start_xvfb()\n",
" pv.set_jupyter_backend(\"panel\")\n",
" pv.set_jupyter_backend(\"trame\")\n",
" field = pv.read(results.field_file_location)\n",
" field_slice = field.slice_orthogonal(z=layer_stack.layers[\"bw\"].zmin * 1e-6)\n",
"\n",
Expand Down Expand Up @@ -244,6 +241,18 @@
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/palace_01_electrostatic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"Alternatively, [Singularity / Apptainer](https://apptainer.org/) containers may be used. Instructions for building and an example definition file are found at [Palace – Build using Singularity/Apptainer](https://awslabs.github.io/palace/dev/install/#Build-using-Singularity/Apptainer).\n",
"Afterwards, an easy install method is to add a script to `~/.local/bin` (or elsewhere in `PATH`) calling the Singularity container. For example, one may create a `palace` file containing\n",
"```console\n",
"!/bin/bash\n",
"#!/bin/bash\n",
"singularity exec ~/palace.sif /opt/palace/bin/palace \"$@\"\n",
"```\n",
"\n",
Expand Down Expand Up @@ -206,7 +206,7 @@
"source": [
"if results.field_file_location:\n",
" pv.start_xvfb()\n",
" pv.set_jupyter_backend(\"panel\")\n",
" pv.set_jupyter_backend(\"trame\")\n",
" field = pv.read(results.field_file_location)\n",
" field_slice = field.slice_orthogonal(z=layer_stack.layers[\"bw\"].zmin * 1e-6)\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/palace_02_fullwave.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"Alternatively, [Singularity / Apptainer](https://apptainer.org/) containers may be used. Instructions for building and an example definition file are found at [Palace – Build using Singularity/Apptainer](https://awslabs.github.io/palace/dev/install/#Build-using-Singularity/Apptainer).\n",
"Afterwards, an easy install method is to add a script to `~/.local/bin` (or elsewhere in `PATH`) calling the Singularity container. For example, one may create a `palace` file containing\n",
"```console\n",
"!/bin/bash\n",
"#!/bin/bash\n",
"singularity exec ~/palace.sif /opt/palace/bin/palace \"$@\"\n",
"```\n",
"\n",
Expand Down Expand Up @@ -290,7 +290,7 @@
"source": [
"if results.field_file_locations:\n",
" pv.start_xvfb()\n",
" pv.set_jupyter_backend(\"panel\")\n",
" pv.set_jupyter_backend(\"trame\")\n",
" field = pv.read(results.field_file_locations[0])\n",
" slice = field.slice_orthogonal(z=layer_stack.layers[\"bw\"].zmin * 1e-6)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/sax_01_sax.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2061,7 +2061,7 @@
"custom_cell_magics": "kql"
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ dev = [
]
devsim = [
"devsim",
"pyvista<=0.40",
"pyvista<=0.43",
"tidy3d>=2.5.2,<2.7"
]
docs = [
"jupytext",
"matplotlib",
"jupyter-book==1.0.0",
"pyvista[jupyter]<=0.40"
"pyvista[all,trame]<=0.43"
]
femwell = [
"femwell>=0.1.6,<0.2",
Expand All @@ -77,7 +77,7 @@ gmsh = [
"mapbox_earcut",
"meshio",
"pygmsh",
"pyvista<=0.40",
"pyvista<=0.43",
"trimesh",
"shapely",
"meshwell>=1.0.7,<=1.1"
Expand Down

0 comments on commit 654ede4

Please sign in to comment.