further fdfd_tools->meanas updates
This commit is contained in:
parent
f61bcf3dfa
commit
94ff3f7853
@ -1,5 +1,5 @@
|
|||||||
import numpy, scipy, gridlock, fdfd_tools
|
import numpy, scipy, gridlock, meanas
|
||||||
from fdfd_tools import bloch
|
from meanas.fdfd import bloch
|
||||||
from numpy.linalg import norm
|
from numpy.linalg import norm
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -2,11 +2,10 @@ import importlib
|
|||||||
import numpy
|
import numpy
|
||||||
from numpy.linalg import norm
|
from numpy.linalg import norm
|
||||||
|
|
||||||
from fdfd_tools import vec, unvec, waveguide_mode
|
import meanas
|
||||||
import fdfd_tools
|
from meanas import vec, unvec
|
||||||
import fdfd_tools.functional
|
from meanas.fdfd import waveguide_mode, functional, scpml
|
||||||
import fdfd_tools.grid
|
from meanas.fdfd.solvers import generic as generic_solver
|
||||||
from fdfd_tools.solvers import generic as generic_solver
|
|
||||||
|
|
||||||
import gridlock
|
import gridlock
|
||||||
|
|
||||||
@ -57,8 +56,8 @@ def test0(solver=generic_solver):
|
|||||||
dxes = [grid.dxyz, grid.autoshifted_dxyz()]
|
dxes = [grid.dxyz, grid.autoshifted_dxyz()]
|
||||||
for a in (0, 1, 2):
|
for a in (0, 1, 2):
|
||||||
for p in (-1, 1):
|
for p in (-1, 1):
|
||||||
dxes = fdfd_tools.grid.stretch_with_scpml(dxes, axis=a, polarity=p, omega=omega,
|
dxes = meanas.scpml.stretch_with_scpml(dxes, axis=a, polarity=p, omega=omega,
|
||||||
thickness=pml_thickness)
|
thickness=pml_thickness)
|
||||||
|
|
||||||
J = [numpy.zeros_like(grid.grids[0], dtype=complex) for _ in range(3)]
|
J = [numpy.zeros_like(grid.grids[0], dtype=complex) for _ in range(3)]
|
||||||
J[1][15, grid.shape[1]//2, grid.shape[2]//2] = 1e5
|
J[1][15, grid.shape[1]//2, grid.shape[2]//2] = 1e5
|
||||||
@ -68,7 +67,7 @@ def test0(solver=generic_solver):
|
|||||||
'''
|
'''
|
||||||
x = solver(J=vec(J), **sim_args)
|
x = solver(J=vec(J), **sim_args)
|
||||||
|
|
||||||
A = fdfd_tools.functional.e_full(omega, dxes, vec(grid.grids)).tocsr()
|
A = functional.e_full(omega, dxes, vec(grid.grids)).tocsr()
|
||||||
b = -1j * omega * vec(J)
|
b = -1j * omega * vec(J)
|
||||||
print('Norm of the residual is ', norm(A @ x - b))
|
print('Norm of the residual is ', norm(A @ x - b))
|
||||||
|
|
||||||
@ -113,8 +112,8 @@ def test1(solver=generic_solver):
|
|||||||
dxes = [grid.dxyz, grid.autoshifted_dxyz()]
|
dxes = [grid.dxyz, grid.autoshifted_dxyz()]
|
||||||
for a in (0, 1, 2):
|
for a in (0, 1, 2):
|
||||||
for p in (-1, 1):
|
for p in (-1, 1):
|
||||||
dxes = fdfd_tools.grid.stretch_with_scpml(dxes,omega=omega, axis=a, polarity=p,
|
dxes = scpml.stretch_with_scpml(dxes,omega=omega, axis=a, polarity=p,
|
||||||
thickness=pml_thickness)
|
thickness=pml_thickness)
|
||||||
|
|
||||||
half_dims = numpy.array([10, 20, 15]) * dx
|
half_dims = numpy.array([10, 20, 15]) * dx
|
||||||
dims = [-half_dims, half_dims]
|
dims = [-half_dims, half_dims]
|
||||||
@ -155,7 +154,7 @@ def test1(solver=generic_solver):
|
|||||||
x = solver(J=vec(J), **sim_args)
|
x = solver(J=vec(J), **sim_args)
|
||||||
|
|
||||||
b = -1j * omega * vec(J)
|
b = -1j * omega * vec(J)
|
||||||
A = fdfd_tools.operators.e_full(**sim_args).tocsr()
|
A = operators.e_full(**sim_args).tocsr()
|
||||||
print('Norm of the residual is ', norm(A @ x - b))
|
print('Norm of the residual is ', norm(A @ x - b))
|
||||||
|
|
||||||
E = unvec(x, grid.shape)
|
E = unvec(x, grid.shape)
|
||||||
@ -181,9 +180,9 @@ def test1(solver=generic_solver):
|
|||||||
|
|
||||||
def poyntings(E):
|
def poyntings(E):
|
||||||
e = vec(E)
|
e = vec(E)
|
||||||
h = fdfd_tools.operators.e2h(omega, dxes) @ e
|
h = operators.e2h(omega, dxes) @ e
|
||||||
cross1 = fdfd_tools.operators.poynting_e_cross(e, dxes) @ h.conj()
|
cross1 = operators.poynting_e_cross(e, dxes) @ h.conj()
|
||||||
cross2 = fdfd_tools.operators.poynting_h_cross(h.conj(), dxes) @ e
|
cross2 = operators.poynting_h_cross(h.conj(), dxes) @ e
|
||||||
s1 = unvec(0.5 * numpy.real(cross1), grid.shape)
|
s1 = unvec(0.5 * numpy.real(cross1), grid.shape)
|
||||||
s2 = unvec(0.5 * numpy.real(-cross2), grid.shape)
|
s2 = unvec(0.5 * numpy.real(-cross2), grid.shape)
|
||||||
return s1, s2
|
return s1, s2
|
||||||
|
@ -10,7 +10,7 @@ import time
|
|||||||
import numpy
|
import numpy
|
||||||
import h5py
|
import h5py
|
||||||
|
|
||||||
from fdfd_tools import fdtd
|
from meanas import fdtd
|
||||||
from masque import Pattern, shapes
|
from masque import Pattern, shapes
|
||||||
import gridlock
|
import gridlock
|
||||||
import pcgen
|
import pcgen
|
||||||
|
@ -2,11 +2,9 @@ import importlib
|
|||||||
import numpy
|
import numpy
|
||||||
from numpy.linalg import norm
|
from numpy.linalg import norm
|
||||||
|
|
||||||
from fdfd_tools import vec, unvec, waveguide_mode
|
from meanas import vec, unvec
|
||||||
import fdfd_tools
|
from meanas.fdfd import waveguide_mode, functional, scpml
|
||||||
import fdfd_tools.functional
|
from meanas.fdfd.solvers import generic as generic_solver
|
||||||
import fdfd_tools.grid
|
|
||||||
from fdfd_tools.solvers import generic as generic_solver
|
|
||||||
|
|
||||||
import gridlock
|
import gridlock
|
||||||
|
|
||||||
@ -50,8 +48,8 @@ def test1(solver=generic_solver):
|
|||||||
dxes = [grid.dxyz, grid.autoshifted_dxyz()]
|
dxes = [grid.dxyz, grid.autoshifted_dxyz()]
|
||||||
for a in (1, 2):
|
for a in (1, 2):
|
||||||
for p in (-1, 1):
|
for p in (-1, 1):
|
||||||
dxes = fdfd_tools.grid.stretch_with_scpml(dxes, omega=omega, axis=a, polarity=p,
|
dxes = scmpl.stretch_with_scpml(dxes, omega=omega, axis=a, polarity=p,
|
||||||
thickness=pml_thickness)
|
thickness=pml_thickness)
|
||||||
|
|
||||||
wg_args = {
|
wg_args = {
|
||||||
'omega': omega,
|
'omega': omega,
|
||||||
|
@ -13,7 +13,7 @@ def curl_h(dxes: dx_lists_t = None) -> field_updater:
|
|||||||
"""
|
"""
|
||||||
Curl operator for use with the H field.
|
Curl operator for use with the H field.
|
||||||
|
|
||||||
:param dxes: Grid parameters [dx_e, dx_h] as described in fdfd_tools.operators header
|
:param dxes: Grid parameters [dx_e, dx_h] as described in meanas.types
|
||||||
:return: Function for taking the discretized curl of the H-field, F(H) -> curlH
|
:return: Function for taking the discretized curl of the H-field, F(H) -> curlH
|
||||||
"""
|
"""
|
||||||
if dxes:
|
if dxes:
|
||||||
@ -42,7 +42,7 @@ def curl_e(dxes: dx_lists_t = None) -> field_updater:
|
|||||||
"""
|
"""
|
||||||
Curl operator for use with the E field.
|
Curl operator for use with the E field.
|
||||||
|
|
||||||
:param dxes: Grid parameters [dx_e, dx_h] as described in fdfd_tools.operators header
|
:param dxes: Grid parameters [dx_e, dx_h] as described in meanas.types
|
||||||
:return: Function for taking the discretized curl of the E-field, F(E) -> curlE
|
:return: Function for taking the discretized curl of the E-field, F(E) -> curlE
|
||||||
"""
|
"""
|
||||||
if dxes is not None:
|
if dxes is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user