Fixup slices

This commit is contained in:
Jan Petykiewicz 2019-08-07 01:01:35 -07:00
parent 2c91ea249f
commit 1a04bab361

View File

@ -346,16 +346,26 @@ def compute_source_e(QE: field_t,
mu: field_t = None, mu: field_t = None,
) -> field_t: ) -> field_t:
""" """
Want (AQ-QA) E = -iwJ, where Q is a mask Want AQE = -iwJ, where Q is mask and normally AE = -iwJ
If E is an eigenmode, AE = 0 so just AQE = -iwJ ## Want (AQ-QA) E = -iwJ, where Q is a mask
Really only need E in 4 cells along axis (0, 0, Emode1, Emode2), find AE (1 fdtd step), then use center 2 cells as src ## If E is an eigenmode, AE = 0 so just AQE = -iwJ
Really only need E in 4 cells along axis (0, 0, Emode1, Emode2), find AE (1 iteration), then use center 2 cells as src
Maybe better to use (0, Emode1, Emode2, Emode3), find AE (1 iteration), then use left 2 cells as src?
""" """
slices = tuple(slices) slices = tuple(slices)
# Trim a cell from each end of the propagation axis # Trim a cell from each end of the propagation axis
slices_reduced = list(slices) slices_reduced = list(slices)
slices_reduced[axis] = slice(slices[axis].start + 1, slices[axis].stop - 1) for aa in range(3):
slices_reduced = tuple(slice(None), *slices_reduced) if aa == axis:
if polarity > 0:
slices_reduced[axis] = slice(slices[axis].start, slices[axis].start+2)
else:
slices_reduced[axis] = slice(slices[axis].stop-2, slices[axis].stop)
else:
start = slices[aa].start
stop = slices[aa].stop
slices_reduced = (slice(None), *slices_reduced)
# Don't actually need to mask out E here since it needs to be pre-masked (QE) # Don't actually need to mask out E here since it needs to be pre-masked (QE)
@ -410,7 +420,7 @@ def compute_overlap_ce(E: field_t,
slices2 = list(slices) slices2 = list(slices)
slices2[axis] = slice(start, stop) slices2[axis] = slice(start, stop)
slices2 = tuple(slice(None), slices2) slices2 = (slice(None), *slices2)
Etgt = numpy.zeros_like(Ee) Etgt = numpy.zeros_like(Ee)
Etgt[slices2] = Ee[slices2] Etgt[slices2] = Ee[slices2]