Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add QElmerRenderer #882

Merged
merged 111 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
f487fba
Added initial code for rendering
Jun 1, 2022
6535d9a
Successful poly and junction rendering; fix path rendering
Jun 1, 2022
891b9ae
Fix: path rendering
AbeerVaishnav13 Jun 1, 2022
09b4120
Fix: path surface creation; small bugs
AbeerVaishnav13 Jun 1, 2022
242a534
Added bounding box, fix for fillet=0, and extended everything to use …
AbeerVaishnav13 Jun 6, 2022
caf8d8b
Added add_endcaps method
AbeerVaishnav13 Jun 6, 2022
93bf958
Added code for asign_physical_groups and minor bug fixes
AbeerVaishnav13 Jun 7, 2022
171ec6a
Added meshing capability; future: make meshing modular
AbeerVaishnav13 Jun 9, 2022
dfc44a7
Added mesh size fields and other changes to enable simulation in Elme…
AbeerVaishnav13 Jun 14, 2022
06c64f4
Moved commonly used functions to renderers/utils.py
AbeerVaishnav13 Jun 15, 2022
b80aa0e
Reformatted code and added docstrings
AbeerVaishnav13 Jun 17, 2022
7066303
Merge branch 'main' into gmsh_elmer_renderer
AbeerVaishnav13 Jun 18, 2022
25e397a
Added more flexible custom meshing
AbeerVaishnav13 Jul 8, 2022
6d4c7c7
Changed Vec3D to use numpy array within dataclass
AbeerVaishnav13 Jul 8, 2022
e1f8836
Removed redundant code for 'get_clean_name'
AbeerVaishnav13 Jul 8, 2022
b40376c
Merge branch 'main' into gmsh_elmer_renderer
AbeerVaishnav13 Jul 8, 2022
7cb225e
Multiple changes
AbeerVaishnav13 Jul 11, 2022
93c87af
Fix CI/CD issues
AbeerVaishnav13 Jul 11, 2022
5c4a368
Bug fix for selection in get_bounding_box
AbeerVaishnav13 Jul 12, 2022
5413018
Merge branch 'main' into gmsh_renderer
AbeerVaishnav13 Jul 13, 2022
8d6a18c
Multiple changes
AbeerVaishnav13 Jul 15, 2022
54ff8b9
Added unit tests
AbeerVaishnav13 Jul 15, 2022
511c00b
Merge branch 'main' into gmsh_renderer
AbeerVaishnav13 Jul 15, 2022
5c82774
Added 'gmsh' as a dependency in:
AbeerVaishnav13 Jul 15, 2022
11e74a8
Added method to enable importing post-processing views
AbeerVaishnav13 Jul 18, 2022
61fe27a
Bug fix with OSError
AbeerVaishnav13 Jul 18, 2022
bdaa931
Modified docstring to have error description
AbeerVaishnav13 Jul 19, 2022
cfd95ae
Added preliminary example notebook for QGmshRenderer
AbeerVaishnav13 Jul 20, 2022
ea43251
Fix mesh scaling (meters -> mm) for export_mesh
AbeerVaishnav13 Jul 20, 2022
c28d5d9
Merge branch 'main' into gmsh_renderer
AbeerVaishnav13 Jul 22, 2022
9a08ecd
reformatted some things, removed x-y rectangle code
AbeerVaishnav13 Jul 22, 2022
fecacb5
Merge branch 'gmsh_renderer' of https://github.com/Qiskit/qiskit-meta…
AbeerVaishnav13 Jul 22, 2022
3a8ac55
Merge branch 'main' into gmsh_renderer
priti-ashvin-shah-ibm Jul 25, 2022
fb98e5e
Merge branch 'main' into gmsh_renderer
priti-ashvin-shah-ibm Jul 25, 2022
15c5e13
A lot of things
AbeerVaishnav13 Jul 26, 2022
0eea4b2
Multiple changes
AbeerVaishnav13 Jul 26, 2022
f9808a1
Fix bug with rendering straight paths with fillet=0/nan
AbeerVaishnav13 Jul 26, 2022
7fe28f0
Merge branch 'gmsh_renderer' into elmer_renderer
AbeerVaishnav13 Jul 26, 2022
2785875
Bug fix with not import cap matrix if arg not provided
AbeerVaishnav13 Jul 26, 2022
9b18c54
Added pyyaml in environments.yml and requirements.txt
AbeerVaishnav13 Jul 27, 2022
f28962a
Moved get_capacitance_matrixoutside QElmerRenderer
AbeerVaishnav13 Jul 27, 2022
72bf456
Added example notebook for QElmerREnderer
AbeerVaishnav13 Jul 27, 2022
c7abbdd
Added methods to save and load cap matrix; updated tutorial notebook
AbeerVaishnav13 Jul 27, 2022
ec1e215
Modified tutorial notebook
AbeerVaishnav13 Jul 27, 2022
438c0f0
Updated mask for geopandas tables
AbeerVaishnav13 Jul 29, 2022
99cd98f
Updated tutorial notebook
AbeerVaishnav13 Aug 3, 2022
a01a3f6
Added print statements for design parameters
AbeerVaishnav13 Aug 4, 2022
6acffe7
Added installation instructions for Gmsh and ElmerFEM
AbeerVaishnav13 Aug 4, 2022
f1bcc7d
Typo fix
AbeerVaishnav13 Aug 4, 2022
24e9b94
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Aug 4, 2022
5f79417
corrected installation instructions
AbeerVaishnav13 Aug 4, 2022
6a07afb
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Oct 5, 2022
ffc7c2c
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Oct 5, 2022
56e4949
change input design type in QElmerRenderer from DesignPlanar to Multi…
diemilio Oct 13, 2022
df2bc3b
add adjacent layer checks when generating netlist
diemilio Oct 13, 2022
26fd92c
add sorting of layers by z coordinate for netlist generation
diemilio Oct 17, 2022
35843d9
add code to define correct bodies and boundaries when using `Multilay…
diemilio Nov 10, 2022
6812a57
add gmsh error notebooks
diemilio Nov 10, 2022
b4b3833
update gmsh issue 3 notebook
diemilio Nov 10, 2022
f5d25de
Update gmsh_renderer.py
diemilio Nov 10, 2022
488b42d
fix small typos
diemilio Nov 10, 2022
41ab4e5
changes in gmsh to fix meshing errors
diemilio Nov 23, 2022
aa6c562
fix net assignments when nodes are connected in upper layers
diemilio Nov 28, 2022
71f50d9
modify part of assign_nets to renumber nodes in netlist id and avoid …
diemilio Nov 29, 2022
1891454
fix some unnecessary comprehensions
diemilio Nov 30, 2022
0ae2305
Merge branch 'main' into elmer_renderer
diemilio Dec 6, 2022
3e76edc
remove issue notebooks from branch to be able to submit PR
diemilio Dec 6, 2022
04d8b58
fix range of rebase_dict to match length of
diemilio Dec 13, 2022
4b7d41f
fix case in `BiCGstabl_polynomial_degree` to avoid duplicate
diemilio Dec 13, 2022
9e9ae80
add docstrings
diemilio Dec 13, 2022
6a43915
more docstrings
diemilio Dec 13, 2022
160974f
more docstrings
diemilio Dec 14, 2022
80f7af0
linting
diemilio Dec 14, 2022
1543ffe
Create `get_qgeometry_table` function.
diemilio Dec 21, 2022
6c375db
Create `get_gnd_qgeoms` function
diemilio Dec 21, 2022
205cf40
Modify `define_boundaries` to support gnd pins
diemilio Dec 21, 2022
e53fe72
remove debug statement
diemilio Dec 21, 2022
6151d21
Add error checking within QGmshRenderer to warn user if items in open…
diemilio Dec 21, 2022
b1c22a4
: update/add docstrings and type hints.
diemilio Dec 22, 2022
fddf279
docs: Add/update docstrings and type hinting (WIP)
diemilio Dec 22, 2022
5ae75d8
docs: Add/update docstrings and type hinting (WIP)
diemilio Dec 22, 2022
d219eef
fix: reinstantiate , methods
diemilio Dec 23, 2022
bec98fc
fix: correctly handle in when equal to None
diemilio Dec 23, 2022
1a95d2d
feat: add warning for no bodies present in model
diemilio Dec 24, 2022
998be54
Merge branch 'main' into elmer_renderer
diemilio Dec 24, 2022
a73556c
Merge branch 'main' into elmer_renderer
obrienpja Dec 27, 2022
35baceb
fix: update ElmerFEM tutorial to support MultiPlanar
diemilio Dec 29, 2022
3abecde
Merge branch 'elmer_renderer' of https://github.com/diemilio/qiskit-m…
diemilio Dec 29, 2022
fbfe790
style: change imports from relative to absolute paths
diemilio Jan 3, 2023
060df89
test: add test_renderers tests for QElmerRenderer
diemilio Jan 4, 2023
ae54e24
Add docstrings and fix imports
AbeerVaishnav13 Jan 4, 2023
8c62798
Add gmsh and elmer renderers to config.py and minor changes for using…
AbeerVaishnav13 Jan 9, 2023
3c7e5f0
Change (List, Tuple, Dict_) --> (list, tuple, dict) for type hints
AbeerVaishnav13 Jan 9, 2023
9174190
Added description for default setup in QElmerRenderer.
AbeerVaishnav13 Jan 9, 2023
6dc875b
Updated Gmsh and ElmerFEM installation instructions.
AbeerVaishnav13 Jan 14, 2023
9ac13f1
Linked README_Gmsh_Elmer.md in README_developers.md
AbeerVaishnav13 Jan 15, 2023
d7d8f2a
Update README_Gmsh_Elmer.md
AbeerVaishnav13 Jan 15, 2023
7b4e4de
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Jan 20, 2023
4787d2c
Add omit_ground_for_layers for providing option to omit ground plane …
AbeerVaishnav13 Jan 25, 2023
512479f
Update docstring for `subtract_from_layers`
AbeerVaishnav13 Jan 25, 2023
f732710
Remove unnecessary line from docstring
AbeerVaishnav13 Jan 28, 2023
8b94f26
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Feb 2, 2023
187a07a
Merge branch 'main' into elmer_renderer
priti-ashvin-shah-ibm Feb 2, 2023
2b1967c
docs: add docstrings to elmer_configs.py
diemilio Feb 2, 2023
baf76f2
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Feb 9, 2023
9f6a359
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Feb 14, 2023
3e0a5f5
Fix: Use `gmsh.open` instead of `gmsh.merge` for viewing post-process…
AbeerVaishnav13 Feb 14, 2023
ac7a3a6
Fix: correct the type hint for netlist
AbeerVaishnav13 Feb 17, 2023
4fadf1e
Merge branch 'main' into elmer_renderer
AbeerVaishnav13 Mar 7, 2023
68b1444
Fix: exclude common surfaces in Gmsh physical groups
AbeerVaishnav13 Mar 7, 2023
0073ad7
Merge branch 'main' into elmer_renderer
priti-ashvin-shah-ibm Mar 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions README_Gmsh_Elmer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Softwares to Install for Open-source simulation toolchain for Qiskit Metal
## Gmsh
- This is a design rendering and meshing software that we will be using to render our design and then divide it into fine elements (called a `mesh`), in order to solve the necessary differential equations (PDE's of Maxwell's Electromagnetic Laws). This is completely integrated with Qiskit Metal and is semi-automated.
- This will be automatically installed when you make a new `venv` environment and install qiskit metal using the instructions given above (except in Apple Silicon Macs, see the Note below).

### Test if Gmsh is properly installed
- Run the following in your terminal. A blank Gmsh window should open up. If it does, then hurray, you did it! 😄
```bash
$ gmsh
```

- Open a python REPL in your terminal and type `import gmsh` in the REPL. If `gmsh` gets imported without any errors, then it's installed properly with python.
```python
$ python
...
...
>>> import gmsh # No Error
>>>
```

**NOTE:**
- On Apple Silicon Macs (with M1 and M2-series chips), installing Gmsh using `pip install gmsh` might not work for importing the package using python. Therefore, to successfully install Gmsh, and point it to the `gmsh` installed using `pip`, you need to install `gmsh` binary through [Homebrew](https://brew.sh/) as follows:
```bash
$ brew install gmsh
```
- Restart your terminal, activate the environment, and check if you're able to do `import gmsh` in a python REPL or a scratch jupyter notebook. If the import is successful, then congratulations, you've installed Gmsh successfully!

- **Note:** If the above steps still gives error in importing gmsh using `import gmsh` in your python environment, refer [this issue](https://gitlab.onelab.info/gmsh/gmsh/-/issues/1705), on the Gmsh GitLab repository, for more information. Also please feel free to contact us through the Qiskit Slack workspace on the `#metal` channel.

## ElmerFEM
- Congratulations on making it until here! Now we'll see how to install ElmerFEM.
- ElmerFEM is a Finite Element Method (FEM) solver that we'll be using to take the mesh generated by Gmsh, and the solve the Maxwell's equations on top of our meshed design. Right now, Qiskit Metal only supports capacitance-type simulations (Poisson equaiton solver provided by `StatElecSolver`) with ElmerFEM, so only LOM 2.0 analysis can be performed for tuning the qubits using the results obtained from ElmerFEM in the form of a Maxwell Capacitance matrix.
- ElmerFEM doesn't come as a python library and has different installation options on your operating system.
- Please follow the official guide provided by Elmer Foundation CSC, [here](https://github.com/ElmerCSC/elmerfem#elmer-fem)

**NOTE:** For MacOS, please consider building the software from source rather than using Homebrew on Mac, as the homebrew install isn't very consistent and may cause issues in the future.

### After you complete your installation
- Add your installation path directory to your system's `PATH` environment variable (you can skip this on Windows and MacOS, as it is automatically done on those OS platforms during the installation steps).
- Restart your terminal.
- Check if ElmerFEM is installed successfully by checking installation for `ElmerGrid` and `ElmerSolver`.
- For testing ElmerGrid, type `ElmerGrid` in your terminal and if the PATH variable is set correctly, it should print a long output text. Check if you see the following at the end of the text:
```bash
$ ElmerGrid
Starting program Elmergrid
****************** Elmergrid ************************
This program can create simple 2D structured meshes consisting of
linear, quadratic or cubic rectangles or triangles. The meshes may
also be extruded and revolved to create 3D forms. In addition many
mesh formats may be imported into Elmer software. Some options have
not been properly tested. Contact the author if you face problems.

...
...
...

Thank you for using Elmergrid!
Send bug reports and feature wishes to elmeradm@csc.fi
```

- For testing ElmerSolver, type `ElmerSolver` in your terminal and if the PATH variable is set correctly, it should print a long output text. Check if you see the following:

```bash
$ ElmerSolver
ELMER SOLVER (v 9.0) STARTED AT: 2023/01/11 09:42:44
ParCommInit: Initialize #PEs: 1
MAIN: OMP_NUM_THREADS not set. Using only 1 thread per task.
MAIN:
MAIN: =============================================================
MAIN: ElmerSolver finite element software, Welcome!
MAIN: This program is free software licensed under (L)GPL
MAIN: Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.
MAIN: Webpage http://www.csc.fi/elmer, Email elmeradm@csc.fi
MAIN: Version: 9.0 (Rev: 02f61d697, Compiled: 2022-11-08)
MAIN: Running one task without MPI parallelization.
MAIN: Running with just one thread per task.
MAIN: =============================================================
ERROR:: ElmerSolver: Unable to find ELMERSOLVER_STARTINFO, can not execute.
Note: The following floating-point exceptions are signalling: IEEE_OVERFLOW_FLAG
STOP 1
```

If you see the above lines in the text in your terminal, then CONGRATULATIONS!!! You've successfully installed everything needed for using Gmsh and ElmerFEM with Qiskit Metal! 😄

**NOTE:** If you face issues at any of the steps above, feel free to contact us on #metal channel on Qiskit slack!!
8 changes: 7 additions & 1 deletion README_developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ Here are some things to consider when setting up a development environment:
* Library errors when activating conda environments, or initializing jupyter notebook/lab, might indicate a conflict between python libraries in the base and sub environments. Go ahead and manually delete the library from the base environment `site-packages` folder, shown in the error message. You might need to reinstall them in the sub environment, or create a new one.
* If Jupyter notebook has trouble finding a dll for a package that works in the new environment outside of Jupyter, then try opening Jupyter notebook from the new environment instead of from `base`

### Installing other dependencies for Open-source Renderers (Gmsh and ElmerFEM)

If you want to use the recently added open-source renderers for [Gmsh](./qiskit_metal/renderers/renderer_gmsh) and [ElmerFEM](./qiskit_metal/renderers/renderer_elmer) for simulation of your design, please make sure that both of them have been installed successfully in your system before running Qiskit Metal. On Windows, Linux, and MacOS (with x86_64 architecture CPUs), Gmsh will be installed automatically using the `environment.yml` file during the conda installation step above. For more detailed steps to install ElmerFEM, please refer to [this](./README_Gmsh_Elmer.md) document.

**NOTE:** We would like to give a disclaimer for users on Apple silicon Macs (M1 and M2-series). Currently, Qiskit Metal uses PySide2 which is not natively supported on the ARM architecture. This will lead to error in instantiating the `MetalGUI` as of now. However, if you still want to use Qiskit Metal without the GUI, the process for installing Gmsh software is a bit different and can be found in [this](./README_Gmsh_Elmer.md) document.

# Other Common Issues

For other common installation issues, please refer to the [FAQ](https://qiskit.org/documentation/metal/faq.html)
Expand Down Expand Up @@ -149,4 +155,4 @@ Go to directory with qiskit-metal/.style.yapf file and run the above command to
rm /hooks/pre-commit
```

If you need to uninstall the precommit hook, go to the root of the project and run the above command.
If you need to uninstall the precommit hook, go to the root of the project and run the above command.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- shapely==2.0.1
- jupyter==1.0.0
- scqubits==3.1.0
- pyyaml==6.0
- pip==23.0
- pip:
- pyaedt==0.6.46
Expand Down
4 changes: 4 additions & 0 deletions qiskit_metal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
class_name='QQ3DRenderer'),
gds=Dict(path_name='qiskit_metal.renderers.renderer_gds.gds_renderer',
class_name='QGDSRenderer'),
gmsh=Dict(path_name='qiskit_metal.renderers.renderer_gmsh.gmsh_renderer',
class_name='QGmshRenderer'),
elmer=Dict(path_name='qiskit_metal.renderers.renderer_elmer.elmer_renderer',
class_name='QElmerRenderer'),
)
"""
Define the renderes to load. Just provide the module names here.
Expand Down
2 changes: 1 addition & 1 deletion qiskit_metal/renderers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@
from .renderer_ansys.q3d_renderer import QQ3DRenderer

from .renderer_gmsh.gmsh_utils import Vec3DArray
from .renderer_gmsh.gmsh_renderer import QGmshRenderer
from .renderer_gmsh.gmsh_renderer import QGmshRenderer
14 changes: 14 additions & 0 deletions qiskit_metal/renderers/renderer_elmer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-

# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
""" ElmerFEM QRenderer """
74 changes: 74 additions & 0 deletions qiskit_metal/renderers/renderer_elmer/elmer_configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""Configuration settings used by ElemerFEM. For details, please refer
to the ElmerFEM documentation http://www.elmerfem.org/blog/documentation/
"""

# Dictionary containing a database of materials and their properties to be
# assigned to an ElmerFEM model.
materials = dict(
diemilio marked this conversation as resolved.
Show resolved Hide resolved
vacuum={
"Electric Conductivity": 0.0,
"Relative Permittivity": 1,
},
silicon={
"Relative Permittivity": 11.45,
},
)

# Dictionary containing valid ElmerFEM simulation types and dimensions with
# their correspoding settings (e.g. steady state 3D, transient 2D, etc.).
simulations = dict(
steady_3D={
"Max Output Level": 5,
"Coordinate System": "Cartesian",
"Coordinate Mapping(3)": "1 2 3",
"Simulation Type": "Steady state",
"Steady State Max Iterations": 1,
"Output Intervals": 1,
"Timestepping Method": "BDF",
"BDF Order": 1,
"Solver Input File": "case.sif",
"Post File": "case.ep",
"Output File": "case.result",
})

# Dictionary containing valid ElmerFEM solvers and their correspoding
# settings (e.g. StatElecSolver, ResultOutputSolve, etc.).
solvers = dict(
capacitance={
"Equation": "Electrostatics",
"Calculate Electric Field": True,
"Calculate Capacitance Matrix": True,
"Capacitance Matrix Filename": "capacitance.txt",
"Procedure": '"StatElecSolve" "StatElecSolver"',
"Variable": "Potential",
"Calculate Electric Energy": True,
"Exec Solver": "Always",
"Stabilize": True,
"Bubbles": False,
"Lumped Mass Matrix": False,
"Optimize Bandwidth": True,
"Steady State Convergence Tolerance": 1.0e-5,
"Nonlinear System Convergence Tolerance": 1.0e-7,
"Nonlinear System Max Iterations": 20,
"Nonlinear System Newton After Iterations": 3,
"Nonlinear System Newton After Tolerance": 1.0e-3,
"Nonlinear System Relaxation Factor": 1,
"Linear System Solver": "Iterative",
"Linear System Iterative Method": "BiCGStab",
"Linear System Max Iterations": 500,
"Linear System Convergence Tolerance": 1.0e-10,
"BiCGstabl polynomial degree": 2,
"Linear System Preconditioning": "ILU0",
"Linear System ILUT Tolerance": 1.0e-3,
"Linear System Abort Not Converged": False,
"Linear System Residual Output": 10,
"Linear System Precondition Recompute": 1,
},
postprocessing_gmsh={
"Exec Solver": "Always",
"Equation": "Result Output",
"Procedure": '"ResultOutputSolve" "ResultOutputSolver"',
"Output File Name": '"case"',
"Output Format": "gmsh",
},
)
Loading