Skip to content

Commit

Permalink
add new function to get_epsilon_grid and material_grid
Browse files Browse the repository at this point in the history
  • Loading branch information
smartalecH committed Mar 23, 2022
1 parent 89e0f35 commit 54bef04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 5 additions & 2 deletions python/tests/test_get_epsilon_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import parameterized
import numpy as np
import meep as mp
try:
import meep.adjoint as mpa
except:
import adjoint as mpa
from meep.materials import SiN, Co

class TestGetEpsilonGrid(unittest.TestCase):
Expand All @@ -12,8 +16,7 @@ def setUp(self):

matgrid_resolution = 200
matgrid_size = mp.Vector3(1.0,1.0,mp.inf)
Nx = int(matgrid_resolution*matgrid_size.x) + 1
Ny = int(matgrid_resolution*matgrid_size.y) + 1
Nx, Ny = mpa.compute_mg_dims(matgrid_size.x,matgrid_size.y,matgrid_resolution)
x = np.linspace(-0.5*matgrid_size.x,0.5*matgrid_size.x,Nx)
y = np.linspace(-0.5*matgrid_size.y,0.5*matgrid_size.y,Ny)
xv, yv = np.meshgrid(x,y)
Expand Down
10 changes: 6 additions & 4 deletions python/tests/test_material_grid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import meep as mp
try:
import meep.adjoint as mpa
except:
import adjoint as mpa
import numpy as np
from scipy.ndimage import gaussian_filter
import unittest
Expand All @@ -14,8 +18,7 @@ def compute_transmittance(matgrid_symmetry=False):
matgrid_size = mp.Vector3(2,2,0)
matgrid_resolution = 2*resolution

Nx = int(matgrid_resolution*matgrid_size.x) + 1
Ny = int(matgrid_resolution*matgrid_size.y) + 1
Nx, Ny = mpa.compute_mg_dims(matgrid_size.x,matgrid_size.y,matgrid_resolution)

# ensure reproducible results
rng = np.random.RandomState(2069588)
Expand Down Expand Up @@ -90,8 +93,7 @@ def compute_resonant_mode(res,default_mat=False):

# for a fixed resolution, compute the number of grid points
# necessary which are defined on the corners of the voxels
Nx = int(matgrid_resolution*matgrid_size.x) + 1
Ny = int(matgrid_resolution*matgrid_size.y) + 1
Nx, Ny = mpa.compute_mg_dims(matgrid_size.x,matgrid_size.y,matgrid_resolution)

x = np.linspace(-0.5*matgrid_size.x,0.5*matgrid_size.x,Nx)
y = np.linspace(-0.5*matgrid_size.y,0.5*matgrid_size.y,Ny)
Expand Down

0 comments on commit 54bef04

Please sign in to comment.