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

Sweep Fabrication #1309

Merged
merged 9 commits into from Feb 20, 2023
Merged

Sweep Fabrication #1309

merged 9 commits into from Feb 20, 2023

Conversation

simbilod
Copy link
Collaborator

@simbilod simbilod commented Feb 19, 2023

some cleaned up work I had lying around to treat morphological transformations as parameters to the model builder, e.g.

Initial geometry:

image

Dilation and erosion (ports are shrunk and grown too):

image

Offsets between layers (ports are also translated):

image

Corner rounding (ports are padded to maintain continuity):

image

This can be swept just like any other Component or LayerStack parameters in the model builder:

image

Next step is to include better distributed processing in the generic model builder. I think with Ray we can scale from local, to cluster, to cloud seamlessly, so just need to format the remote decorator properly

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 19, 2023

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 10.04%.

Quality metrics Before After Change
Complexity 2.20 ⭐ 6.27 ⭐ 4.07 👎
Method Length 56.69 ⭐ 77.81 🙂 21.12 👎
Working memory 7.45 🙂 8.44 🙂 0.99 👎
Quality 74.97% 🙂 64.93% 🙂 -10.04% 👎
Other metrics Before After Change
Lines 420 706 286
Changed files Quality Before Quality After Quality Change
gdsfactory/simulation/sax/build_model.py 71.61% 🙂 71.63% 🙂 0.02% 👍
gdsfactory/simulation/sax/femwell_waveguide_model.py 75.52% ⭐ 76.19% ⭐ 0.67% 👍
gdsfactory/simulation/sax/meep_FDTD_model.py 79.57% ⭐ 79.74% ⭐ 0.17% 👍
gdsfactory/simulation/sax/parameter.py 80.67% ⭐ 57.19% 🙂 -23.48% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
gdsfactory/simulation/sax/parameter.py LithoParameter.layer_dilation_erosion 26 😞 202 😞 12 😞 32.87% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/sax/parameter.py LithoParameter.layer_round_corners 17 🙂 225 ⛔ 14 😞 34.41% 😞 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/sax/parameter.py LithoParameter.layer_x_offset 10 🙂 134 😞 10 😞 54.99% 🙂 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/sax/parameter.py LithoParameter.layer_y_offset 10 🙂 134 😞 10 😞 54.99% 🙂 Try splitting into smaller methods. Extract out complex expressions
gdsfactory/simulation/sax/parameter.py LayerStackThickness.__init__ 4 ⭐ 142 😞 9 🙂 61.87% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@codecov
Copy link

codecov bot commented Feb 19, 2023

Codecov Report

Merging #1309 (a99fdbe) into main (7c5bb0e) will decrease coverage by 0.18%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1309      +/-   ##
==========================================
- Coverage   70.14%   69.97%   -0.18%     
==========================================
  Files         363      364       +1     
  Lines       21468    21569     +101     
  Branches     3074     3086      +12     
==========================================
+ Hits        15058    15092      +34     
- Misses       5524     5583      +59     
- Partials      886      894       +8     
Impacted Files Coverage Δ
gdsfactory/generic_tech/__init__.py 70.37% <0.00%> (-29.63%) ⬇️
gdsfactory/export/to_stl.py 25.92% <0.00%> (-6.08%) ⬇️
gdsfactory/components/edge_coupler_array.py 82.22% <0.00%> (-3.83%) ⬇️
gdsfactory/widgets/layout_viewer.py 14.01% <0.00%> (-3.32%) ⬇️
gdsfactory/show.py 47.05% <0.00%> (-2.95%) ⬇️
gdsfactory/pdk.py 56.88% <0.00%> (-1.87%) ⬇️
gdsfactory/component.py 67.24% <0.00%> (-1.06%) ⬇️
gdsfactory/port.py 66.08% <0.00%> (-0.17%) ⬇️
gdsfactory/__init__.py 94.00% <0.00%> (-0.12%) ⬇️
gdsfactory/config.py 66.00% <0.00%> (ø)
... and 7 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@joamatab
Copy link
Contributor

Looks great Simon,

I think you should merge the polygons before rounding them

@joamatab
Copy link
Contributor

The docs also have some issues, can merge once it's fixed

https://github.com/gdsfactory/gdsfactory/actions/runs/4218770431/jobs/7323514671

@simbilod
Copy link
Collaborator Author

Thanks @joamatab , I was already fusing the polygons for the erosion/dilation so that was an easy addition :)

@HelgeGehring the notebook now crashes because femwell tries to convert something complex to real. The plugin test fails for the same reason. Do you know the easiest fix?

Traceback (most recent call last):
  File "/home/simbil/Github/gdsfactory/gdsfactory/simulation/fem/test_mode_solver.py", line 71, in <module>
    test_compute_cross_section_mode_cache()
  File "/home/simbil/Github/gdsfactory/gdsfactory/simulation/fem/test_mode_solver.py", line 56, in test_compute_cross_section_mode_cache
    lams, basis, xs = compute_modes(with_cache=True, overwrite=False)
  File "/home/simbil/Github/gdsfactory/gdsfactory/simulation/fem/test_mode_solver.py", line 35, in compute_modes
    lams, basis, xs = compute_cross_section_modes(
  File "/home/simbil/Github/gdsfactory/gdsfactory/simulation/fem/mode_solver.py", line 63, in compute_cross_section_modes
    return compute_component_slice_modes(
  File "/home/simbil/Github/gdsfactory/gdsfactory/simulation/fem/mode_solver.py", line 191, in compute_component_slice_modes
    lams, basis, xs = mode_solver.compute_modes(
  File "/home/simbil/miniconda3/envs/gdsfactory/lib/python3.10/site-packages/femwell/mode_solver.py", line 83, in compute_modes
    lams, xs = solve(
  File "/home/simbil/miniconda3/envs/gdsfactory/lib/python3.10/site-packages/skfem/utils.py", line 262, in solve
    out = solve_eigen(A, b, x, I, solver, **kwargs)  # type: ignore
  File "/home/simbil/miniconda3/envs/gdsfactory/lib/python3.10/site-packages/skfem/utils.py", line 215, in solve_eigen
    return solver(A, M, **kwargs)
  File "/home/simbil/miniconda3/envs/gdsfactory/lib/python3.10/site-packages/femwell/solver.py", line 114, in solver
    K_ = PETSc.Mat().createAIJ(size=K.shape, csr=(K.indptr, K.indices, K.data))
  File "PETSc/Mat.pyx", line 357, in petsc4py.PETSc.Mat.createAIJ
  File "PETSc/petscmat.pxi", line 823, in petsc4py.PETSc.Mat_AllocAIJ
  File "PETSc/petscmat.pxi", line 794, in petsc4py.PETSc.Mat_AllocAIJ_CSR
  File "include/arraynpy.pxi", line 155, in petsc4py.PETSc.iarray_s
  File "include/arraynpy.pxi", line 130, in petsc4py.PETSc.iarray
TypeError: Cannot cast array data from dtype('complex128') to dtype('float64') according to the rule 'safe'

@HelgeGehring
Copy link
Collaborator

Might it be, that the "real" conversion of slepc is installed instead of the "complex" version?
Also, you can try to not specify the solver (to use scipy)

@simbilod
Copy link
Collaborator Author

strange, the gdsfactory makefile installs the complex version

Anyway, I am now making it use whatever is default in femwell and now it works!

@simbilod
Copy link
Collaborator Author

seems like scipy works locally but not on the build server for docs

@joamatab
Copy link
Contributor

Happy to merge it when the tests pass

@simbilod
Copy link
Collaborator Author

Changed it to slepc again. Worked locally on my VM, and seems to work here too

@joamatab joamatab merged commit fa89931 into gdsfactory:main Feb 20, 2023
simbilod pushed a commit to simbilod/gdsfactory that referenced this pull request Mar 2, 2023
Sweep Fabrication

Former-commit-id: d626661 [formerly fa89931]
Former-commit-id: a39444ef9689b87ff5ba6b5a7b333bcaee85e9f1
@simbilod simbilod deleted the variability2 branch April 5, 2023 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants