forked from jan/fdfd_tools
Cleaner conductor implementation
This commit is contained in:
parent
a3dac5c8f8
commit
8daab636ea
@ -178,7 +178,7 @@ def test1():
|
|||||||
H_overlap = waveguide_mode.compute_overlap_e(**wg_args, **wg_results)
|
H_overlap = waveguide_mode.compute_overlap_e(**wg_args, **wg_results)
|
||||||
|
|
||||||
pecg = gridlock.Grid(edge_coords, initial=0.0, num_grids=3)
|
pecg = gridlock.Grid(edge_coords, initial=0.0, num_grids=3)
|
||||||
# pecg.draw_cuboid(center=[700, 0, 0], dimensions=[80, 1e8, 1e8], eps=1)
|
pecg.draw_cuboid(center=[700, 0, 0], dimensions=[80, 1e8, 1e8], eps=1)
|
||||||
# pecg.visualize_isosurface()
|
# pecg.visualize_isosurface()
|
||||||
|
|
||||||
pmcg = gridlock.Grid(edge_coords, initial=0.0, num_grids=3)
|
pmcg = gridlock.Grid(edge_coords, initial=0.0, num_grids=3)
|
||||||
|
@ -71,25 +71,23 @@ def e_full(omega: complex,
|
|||||||
ce = curl_e(dxes)
|
ce = curl_e(dxes)
|
||||||
ch = curl_h(dxes)
|
ch = curl_h(dxes)
|
||||||
|
|
||||||
ev = epsilon
|
|
||||||
if numpy.any(numpy.equal(pec, None)):
|
if numpy.any(numpy.equal(pec, None)):
|
||||||
pe = sparse.eye(epsilon.size)
|
pe = sparse.eye(epsilon.size)
|
||||||
else:
|
else:
|
||||||
pe = sparse.diags(numpy.where(pec, 0, 1)) # Set pe to (not PEC)
|
pe = sparse.diags(numpy.where(pec, 0, 1)) # Set pe to (not PEC)
|
||||||
ev = numpy.where(pec, 1.0, ev) # Set epsilon to 1 at PEC
|
|
||||||
|
|
||||||
if numpy.any(numpy.equal(pmc, None)):
|
if numpy.any(numpy.equal(pmc, None)):
|
||||||
pm = sparse.eye(epsilon.size)
|
pm = sparse.eye(epsilon.size)
|
||||||
else:
|
else:
|
||||||
pm = sparse.diags(numpy.where(pmc, 0, 1)) # set pm to (not PMC)
|
pm = sparse.diags(numpy.where(pmc, 0, 1)) # set pm to (not PMC)
|
||||||
|
|
||||||
e = sparse.diags(ev)
|
e = sparse.diags(epsilon)
|
||||||
if numpy.any(numpy.equal(mu, None)):
|
if numpy.any(numpy.equal(mu, None)):
|
||||||
m_div = sparse.eye(epsilon.size)
|
m_div = sparse.eye(epsilon.size)
|
||||||
else:
|
else:
|
||||||
m_div = sparse.diags(1 / mu)
|
m_div = sparse.diags(1 / mu)
|
||||||
|
|
||||||
op = pe @ ch @ pm @ m_div @ ce @ pe - omega**2 * e
|
op = pe @ (ch @ pm @ m_div @ ce - omega**2 * e) @ pe
|
||||||
return op
|
return op
|
||||||
|
|
||||||
|
|
||||||
@ -143,26 +141,23 @@ def h_full(omega: complex,
|
|||||||
ec = curl_e(dxes)
|
ec = curl_e(dxes)
|
||||||
hc = curl_h(dxes)
|
hc = curl_h(dxes)
|
||||||
|
|
||||||
if mu is None:
|
|
||||||
mv = numpy.ones_like(epsilon)
|
|
||||||
else:
|
|
||||||
mv = mu
|
|
||||||
|
|
||||||
if numpy.any(numpy.equal(pmc, None)):
|
|
||||||
pm = sparse.eye(epsilon.size)
|
|
||||||
else:
|
|
||||||
pm = sparse.diags(numpy.where(pmc, 0, 1)) # Set pe to (not PMC)
|
|
||||||
mv = numpy.where(pmc, 1.0, mv) # Set mu to 1 at PMC
|
|
||||||
|
|
||||||
if numpy.any(numpy.equal(pec, None)):
|
if numpy.any(numpy.equal(pec, None)):
|
||||||
pe = sparse.eye(epsilon.size)
|
pe = sparse.eye(epsilon.size)
|
||||||
else:
|
else:
|
||||||
pe = sparse.diags(numpy.where(pec, 0, 1)) # set pe to (not PEC)
|
pe = sparse.diags(numpy.where(pec, 0, 1)) # set pe to (not PEC)
|
||||||
|
|
||||||
e_div = sparse.diags(1 / epsilon)
|
if numpy.any(numpy.equal(pmc, None)):
|
||||||
m = sparse.diags(mv)
|
pm = sparse.eye(epsilon.size)
|
||||||
|
else:
|
||||||
|
pm = sparse.diags(numpy.where(pmc, 0, 1)) # Set pe to (not PMC)
|
||||||
|
|
||||||
A = pm @ ec @ pe @ e_div @ hc @ pm - omega**2 * m
|
e_div = sparse.diags(1 / epsilon)
|
||||||
|
if mu is None:
|
||||||
|
m = sparse.eye(epsilon.size)
|
||||||
|
else:
|
||||||
|
m = sparse.diags(mu)
|
||||||
|
|
||||||
|
A = pm @ (ec @ pe @ e_div @ hc - omega**2 * m) @ pm
|
||||||
return A
|
return A
|
||||||
|
|
||||||
|
|
||||||
@ -197,10 +192,11 @@ def eh_full(omega, dxes, epsilon, mu=None, pec=None, pmc=None):
|
|||||||
else:
|
else:
|
||||||
pm = sparse.diags(numpy.where(pmc, 0, 1)) # set pm to (not PMC)
|
pm = sparse.diags(numpy.where(pmc, 0, 1)) # set pm to (not PMC)
|
||||||
|
|
||||||
iwe = pe @ (1j * omega * sparse.diags(epsilon))
|
iwe = pe @ (1j * omega * sparse.diags(epsilon)) @ pe
|
||||||
iwm = pm * 1j * omega
|
iwm = 1j * omega
|
||||||
if not numpy.any(numpy.equal(mu, None)):
|
if not numpy.any(numpy.equal(mu, None)):
|
||||||
iwm *= sparse.diags(mu)
|
iwm *= sparse.diags(mu)
|
||||||
|
iwm = pm @ iwm @ pm
|
||||||
|
|
||||||
A1 = pe @ curl_h(dxes) @ pm
|
A1 = pe @ curl_h(dxes) @ pm
|
||||||
A2 = pm @ curl_e(dxes) @ pe
|
A2 = pm @ curl_e(dxes) @ pe
|
||||||
|
Loading…
Reference in New Issue
Block a user