你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Tidying line lengths and comments
这个提交包含在:
@@ -21,7 +21,7 @@ cimport numpy as np
|
||||
from cython.parallel import prange
|
||||
|
||||
|
||||
cpdef void cython_update_electric_os(
|
||||
cpdef void update_electric_os(
|
||||
np.float64_t[:, :] updatecoeffsE,
|
||||
np.uint32_t[:, :, :, :] ID,
|
||||
int face,
|
||||
@@ -48,6 +48,7 @@ cpdef void cython_update_electric_os(
|
||||
Args:
|
||||
subgrid: Subgrid class instance.
|
||||
n: string for the normal to the face to update.
|
||||
|
||||
nwn: int for the number of working cell in the normal direction
|
||||
to the face.
|
||||
lookup_id: int id of the H component to update at each node.
|
||||
@@ -62,9 +63,9 @@ cpdef void cython_update_electric_os(
|
||||
s: int for separation of inner and outer surfaces.
|
||||
nb: int for number of boundary cells.
|
||||
"""
|
||||
# Comments here as as per left and right face
|
||||
|
||||
cdef Py_ssize_t l, m, l_s, m_s, n_s_l, n_s_r, material_e_l, material_e_r, i0, j0, k0, i1, j1, k1, i2, j2, k2, i3, j3, k3
|
||||
cdef Py_ssize_t l, m, l_s, m_s, n_s_l, n_s_r, material_e_l, material_e_r
|
||||
cdef Py_ssize_t i0, j0, k0, i1, j1, k1, i2, j2, k2, i3, j3, k3
|
||||
cdef int os
|
||||
cdef double inc_n, inc_f
|
||||
|
||||
@@ -94,21 +95,21 @@ cpdef void cython_update_electric_os(
|
||||
else:
|
||||
m_s = os + (m - m_l) * r + r // 2
|
||||
|
||||
# left and right
|
||||
# Left and right
|
||||
if face == 2:
|
||||
# main grid index
|
||||
# Main grid index
|
||||
i0, j0, k0 = n_l, l, m
|
||||
# equivalent subgrid index
|
||||
# Equivalent subgrid index
|
||||
i1, j1, k1 = n_s_l, l_s, m_s
|
||||
i2, j2, k2 = n_u, l, m
|
||||
i3, j3, k3 = n_s_r, l_s, m_s
|
||||
# front and back
|
||||
# Front and back
|
||||
if face == 3:
|
||||
i0, j0, k0 = l, n_l, m
|
||||
i1, j1, k1 = l_s, n_s_l, m_s
|
||||
i2, j2, k2 = l, n_u, m
|
||||
i3, j3, k3 = l_s, n_s_r, m_s
|
||||
# top bottom
|
||||
# Top and bottom
|
||||
if face == 1:
|
||||
i0, j0, k0 = l, m, n_l
|
||||
i1, j1, k1 = l_s, m_s, n_s_l
|
||||
@@ -129,7 +130,7 @@ cpdef void cython_update_electric_os(
|
||||
field[i2, j2, k2] += updatecoeffsE[material_e_r, co] * inc_f
|
||||
|
||||
|
||||
cpdef void cython_update_magnetic_os(
|
||||
cpdef void update_magnetic_os(
|
||||
np.float64_t[:, :] updatecoeffsH,
|
||||
np.uint32_t[:, :, :, :] ID,
|
||||
int face,
|
||||
@@ -154,12 +155,10 @@ cpdef void cython_update_magnetic_os(
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
r: int for subgrid ratio.
|
||||
s: int for separation of inner and outer surfaces.
|
||||
nb: int for number of boundary cells.
|
||||
"""
|
||||
|
||||
cdef Py_ssize_t l, m, l_s, m_s, n_s_l, n_s_r, material_e_l, material_e_r, i0, j0, k0, i1, j1, k1, i2, j2, k2, i3, j3, k3
|
||||
cdef Py_ssize_t l, m, l_s, m_s, n_s_l, n_s_r, material_e_l, material_e_r
|
||||
cdef Py_ssize_t i0, j0, k0, i1, j1, k1, i2, j2, k2, i3, j3, k3
|
||||
cdef int os
|
||||
cdef double inc_n, inc_f
|
||||
|
||||
@@ -168,43 +167,43 @@ cpdef void cython_update_magnetic_os(
|
||||
# Normal index for the subgrid far face e node
|
||||
n_s_r = nb + nwn + s * r
|
||||
|
||||
# os inner index for the sub grid
|
||||
# OS inner index for the sub grid
|
||||
os = nb - r * s
|
||||
|
||||
for l in prange(l_l, l_u, nogil=True, schedule='static', num_threads=nthreads):
|
||||
|
||||
# y coord of the Ex field component
|
||||
# y-coord of the Ex field component
|
||||
if mid == 1:
|
||||
l_s = os + (l - l_l) * r + r // 2
|
||||
# y coord of the Ez field component
|
||||
# y-coord of the Ez field component
|
||||
else:
|
||||
l_s = os + (l - l_l) * r
|
||||
|
||||
for m in range(m_l, m_u):
|
||||
|
||||
# z coordinate of the Ex node in the subgrid
|
||||
# z-coord of the Ex node in the subgrid
|
||||
if mid == 1:
|
||||
m_s = os + (m - m_l) * r
|
||||
else:
|
||||
m_s = os + (m - m_l) * r + r // 2
|
||||
|
||||
# associate the given indices with their i, j, k values
|
||||
# Associate the given indices with their i, j, k values
|
||||
|
||||
# left and right
|
||||
# Left and right
|
||||
if face == 2:
|
||||
# main grid index
|
||||
# Main grid index
|
||||
i0, j0, k0 = n_l, l, m
|
||||
# equivalent subgrid index
|
||||
# Equivalent subgrid index
|
||||
i1, j1, k1 = n_s_l, l_s, m_s
|
||||
i2, j2, k2 = n_u, l, m
|
||||
i3, j3, k3 = n_s_r, l_s, m_s
|
||||
# front and back
|
||||
# Front and back
|
||||
if face == 3:
|
||||
i0, j0, k0 = l, n_l, m
|
||||
i1, j1, k1 = l_s, n_s_l, m_s
|
||||
i2, j2, k2 = l, n_u, m
|
||||
i3, j3, k3 = l_s, n_s_r, m_s
|
||||
# top bottom
|
||||
# Top and bottom
|
||||
if face == 1:
|
||||
i0, j0, k0 = l, m, n_l
|
||||
i1, j1, k1 = l_s, m_s, n_s_l
|
||||
@@ -214,7 +213,7 @@ cpdef void cython_update_magnetic_os(
|
||||
material_e_l = ID[lookup_id, i0, j0, k0]
|
||||
inc_n = inc_field[i1, j1, k1] * sign_n
|
||||
|
||||
# make sure these are the correct grid
|
||||
# Make sure these are the correct grid
|
||||
field[i0, j0, k0] += updatecoeffsH[material_e_l, co] * inc_n
|
||||
|
||||
# Far face
|
||||
@@ -223,7 +222,7 @@ cpdef void cython_update_magnetic_os(
|
||||
field[i2, j2, k2] += updatecoeffsH[material_e_r, co] * inc_f
|
||||
|
||||
|
||||
cpdef void cython_update_is(
|
||||
cpdef void update_is(
|
||||
int nwx,
|
||||
int nwy,
|
||||
int nwz,
|
||||
@@ -249,7 +248,8 @@ cpdef void cython_update_is(
|
||||
Args:
|
||||
"""
|
||||
|
||||
cdef Py_ssize_t l, m, i1, j1, k1, i2, j2, k2, field_material_l, field_material_u, inc_i, inc_j
|
||||
cdef Py_ssize_t l, m, i1, j1, k1, i2, j2, k2
|
||||
cdef Py_ssize_t field_material_l, field_material_u, inc_i, inc_j
|
||||
cdef double inc_l, inc_u, f_l, f_u
|
||||
# For inner faces H nodes are 1 cell before n boundary cells
|
||||
cdef int n_o = n + offset
|
||||
@@ -257,15 +257,15 @@ cpdef void cython_update_is(
|
||||
for l in prange(n, nwl + n, nogil=True, schedule='static', num_threads=nthreads):
|
||||
for m in range(n, nwm + n):
|
||||
|
||||
# bottom and top
|
||||
# Bottom and top
|
||||
if face == 1:
|
||||
i1, j1, k1 = l, m, n_o
|
||||
i2, j2, k2 = l, m, n + nwz
|
||||
# left and right
|
||||
# Left and right
|
||||
if face == 2:
|
||||
i1, j1, k1 = n_o, l, m
|
||||
i2, j2, k2 = n + nwx, l, m
|
||||
# front and back
|
||||
# Front and back
|
||||
if face == 3:
|
||||
i1, j1, k1 = l, n_o, m
|
||||
i2, j2, k2 = l, n + nwy, m
|
||||
|
@@ -357,7 +357,7 @@ class PrecursorNodes(PrecursorNodesBase):
|
||||
#j1 = self.j1 + 1
|
||||
#k1 = self.k1 + 1
|
||||
|
||||
# not extended
|
||||
# Not extended
|
||||
i0 = self.i0
|
||||
j0 = self.j0
|
||||
k0 = self.k0
|
||||
@@ -367,20 +367,30 @@ class PrecursorNodes(PrecursorNodesBase):
|
||||
|
||||
# Spatially interpolate nodes
|
||||
slices = [
|
||||
['ex_front_1', True, (slice(i0, i1, 1), self.j0, slice(k0, k1 + 1, 1)), self.Ex],
|
||||
['ex_back_1', True, (slice(i0, i1, 1), self.j1, slice(k0, k1 + 1, 1)), self.Ex],
|
||||
['ez_front_1', False, (slice(i0, i1 + 1, 1), self.j0, slice(k0, k1, 1)), self.Ez],
|
||||
['ez_back_1', False, (slice(i0, i1 + 1, 1), self.j1, slice(k0, k1, 1)), self.Ez],
|
||||
|
||||
['ey_left_1', True, (self.i0, slice(j0, j1, 1), slice(k0, k1 + 1, 1)), self.Ey],
|
||||
['ey_right_1', True, (self.i1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)), self.Ey],
|
||||
['ez_left_1', False, (self.i0, slice(j0, j1 + 1, 1), slice(k0, k1, 1)), self.Ez],
|
||||
['ez_right_1', False, (self.i1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)), self.Ez],
|
||||
|
||||
['ex_bottom_1', True, (slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k0), self.Ex],
|
||||
['ex_top_1', True, (slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k1), self.Ex],
|
||||
['ey_bottom_1', False, (slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0), self.Ey],
|
||||
['ey_top_1', False, (slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k1), self.Ey]
|
||||
['ex_front_1', True,
|
||||
(slice(i0, i1, 1), self.j0, slice(k0, k1 + 1, 1)), self.Ex],
|
||||
['ex_back_1', True,
|
||||
(slice(i0, i1, 1), self.j1, slice(k0, k1 + 1, 1)), self.Ex],
|
||||
['ez_front_1', False,
|
||||
(slice(i0, i1 + 1, 1), self.j0, slice(k0, k1, 1)), self.Ez],
|
||||
['ez_back_1', False,
|
||||
(slice(i0, i1 + 1, 1), self.j1, slice(k0, k1, 1)), self.Ez],
|
||||
['ey_left_1', True,
|
||||
(self.i0, slice(j0, j1, 1), slice(k0, k1 + 1, 1)), self.Ey],
|
||||
['ey_right_1', True,
|
||||
(self.i1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)), self.Ey],
|
||||
['ez_left_1', False,
|
||||
(self.i0, slice(j0, j1 + 1, 1), slice(k0, k1, 1)), self.Ez],
|
||||
['ez_right_1', False,
|
||||
(self.i1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)), self.Ez],
|
||||
['ex_bottom_1', True,
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k0), self.Ex],
|
||||
['ex_top_1', True,
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k1), self.Ex],
|
||||
['ey_bottom_1', False,
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0), self.Ey],
|
||||
['ey_top_1', False,
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k1), self.Ey]
|
||||
]
|
||||
|
||||
for obj in slices:
|
||||
@@ -419,7 +429,7 @@ class PrecursorNodesFiltered(PrecursorNodesBase):
|
||||
#j1 = self.j1 + 1
|
||||
#k1 = self.k1 + 1
|
||||
|
||||
# not extended
|
||||
# Not extended
|
||||
i0 = self.i0
|
||||
j0 = self.j0
|
||||
k0 = self.k0
|
||||
@@ -469,7 +479,7 @@ class PrecursorNodesFiltered(PrecursorNodesBase):
|
||||
(slice(i0, i1, 1), self.j1, slice(k0, k1 + 1, 1)),
|
||||
(slice(i0, i1, 1), self.j1 + 1, slice(k0, k1 + 1, 1)), self.Hz],
|
||||
['hx_bottom_1', False,
|
||||
# check these indexes
|
||||
# Check these indexes
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0 - 2),
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0 - 1),
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0),
|
||||
@@ -507,7 +517,7 @@ class PrecursorNodesFiltered(PrecursorNodesBase):
|
||||
#j1 = self.j1 + 1
|
||||
#k1 = self.k1 + 1
|
||||
|
||||
# not extended
|
||||
# Not extended
|
||||
i0 = self.i0
|
||||
j0 = self.j0
|
||||
k0 = self.k0
|
||||
@@ -520,64 +530,51 @@ class PrecursorNodesFiltered(PrecursorNodesBase):
|
||||
['ex_front_1', True,
|
||||
(slice(i0, i1, 1), self.j0 - 1, slice(k0, k1 + 1, 1)),
|
||||
(slice(i0, i1, 1), self.j0, slice(k0, k1 + 1, 1)),
|
||||
(slice(i0, i1, 1), self.j0 + 1, slice(k0, k1 + 1, 1)),
|
||||
self.Ex],
|
||||
(slice(i0, i1, 1), self.j0 + 1, slice(k0, k1 + 1, 1)), self.Ex],
|
||||
['ex_back_1', True,
|
||||
(slice(i0, i1, 1), self.j1 - 1, slice(k0, k1 + 1, 1)),
|
||||
(slice(i0, i1, 1), self.j1, slice(k0, k1 + 1, 1)),
|
||||
(slice(i0, i1, 1), self.j1 + 1, slice(k0, k1 + 1, 1)),
|
||||
self.Ex],
|
||||
(slice(i0, i1, 1), self.j1 + 1, slice(k0, k1 + 1, 1)), self.Ex],
|
||||
['ez_front_1', False,
|
||||
(slice(i0, i1 + 1, 1), self.j0 - 1, slice(k0, k1, 1)),
|
||||
(slice(i0, i1 + 1, 1), self.j0, slice(k0, k1, 1)),
|
||||
(slice(i0, i1 + 1, 1), self.j0 + 1, slice(k0, k1, 1)),
|
||||
self.Ez],
|
||||
(slice(i0, i1 + 1, 1), self.j0 + 1, slice(k0, k1, 1)), self.Ez],
|
||||
['ez_back_1', False,
|
||||
(slice(i0, i1 + 1, 1), self.j1 - 1, slice(k0, k1, 1)),
|
||||
(slice(i0, i1 + 1, 1), self.j1, slice(k0, k1, 1)),
|
||||
(slice(i0, i1 + 1, 1), self.j1 + 1, slice(k0, k1, 1)),
|
||||
self.Ez],
|
||||
(slice(i0, i1 + 1, 1), self.j1 + 1, slice(k0, k1, 1)), self.Ez],
|
||||
['ey_left_1', True,
|
||||
(self.i0 - 1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)),
|
||||
(self.i0, slice(j0, j1, 1), slice(k0, k1 + 1, 1)),
|
||||
(self.i0 + 1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)),
|
||||
self.Ey],
|
||||
(self.i0 + 1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)), self.Ey],
|
||||
['ey_right_1', True,
|
||||
(self.i1 - 1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)),
|
||||
(self.i1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)),
|
||||
(self.i1 + 1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)),
|
||||
self.Ey],
|
||||
(self.i1 + 1, slice(j0, j1, 1), slice(k0, k1 + 1, 1)), self.Ey],
|
||||
['ez_left_1', False,
|
||||
(self.i0 - 1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)),
|
||||
(self.i0, slice(j0, j1 + 1, 1), slice(k0, k1, 1)),
|
||||
(self.i0 + 1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)),
|
||||
self.Ez],
|
||||
(self.i0 + 1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)), self.Ez],
|
||||
['ez_right_1', False,
|
||||
(self.i1 - 1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)),
|
||||
(self.i1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)),
|
||||
(self.i1 + 1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)),
|
||||
self.Ez],
|
||||
|
||||
(self.i1 + 1, slice(j0, j1 + 1, 1), slice(k0, k1, 1)), self.Ez],
|
||||
['ex_bottom_1', True,
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k0 - 1),
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k0),
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k0 + 1),
|
||||
self.Ex],
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k0 + 1), self.Ex],
|
||||
['ex_top_1', True,
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k1 - 1),
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k1),
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k1 + 1),
|
||||
self.Ex],
|
||||
(slice(i0, i1, 1), slice(j0, j1 + 1, 1), self.k1 + 1), self.Ex],
|
||||
['ey_bottom_1', False,
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0 - 1),
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0),
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0 + 1),
|
||||
self.Ey],
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k0 + 1), self.Ey],
|
||||
['ey_top_1', False,
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k1 - 1),
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k1),
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k1 + 1),
|
||||
self.Ey]
|
||||
(slice(i0, i1 + 1, 1), slice(j0, j1, 1), self.k1 + 1), self.Ey]
|
||||
]
|
||||
|
||||
for obj in slices:
|
||||
|
@@ -20,9 +20,8 @@ import logging
|
||||
|
||||
import gprMax.config as config
|
||||
|
||||
from ..cython.fields_updates_hsg import (cython_update_electric_os,
|
||||
cython_update_is,
|
||||
cython_update_magnetic_os)
|
||||
from ..cython.fields_updates_hsg import (update_electric_os, update_is,
|
||||
update_magnetic_os)
|
||||
from .grid import SubGridBaseGrid
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -30,61 +29,119 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class SubGridHSG(SubGridBaseGrid):
|
||||
|
||||
gridtype = '3DSUBGRID'
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.gridtype = SubGridHSG.gridtype
|
||||
|
||||
def update_magnetic_is(self, precursors):
|
||||
"""Updates the subgrid nodes at the IS with the currents derived
|
||||
from the main grid.
|
||||
|
||||
Args:
|
||||
nwl, nwm, nwn, face, field, inc_field, lookup_id, sign, mod, co
|
||||
precursors:
|
||||
"""
|
||||
|
||||
# Form of FDTD update equations for H
|
||||
# Hz = c0Hz - c1Ey + c2Ex
|
||||
# Hy = c0Hy - c3Ex + c1Ez
|
||||
# Hx = c0Hx - c2Ez + c3Ey
|
||||
# Bottom and Top
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx, self.nwy + 1, self.nwz, 1, self.Hy, precursors.ex_bottom, precursors.ex_top, self.IDlookup['Hy'], 1, -1, 3, config.get_model_config().ompthreads)
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx + 1, self.nwy, self.nwz, 1, self.Hx, precursors.ey_bottom, precursors.ey_top, self.IDlookup['Hx'], -1, 1, 3, config.get_model_config().ompthreads)
|
||||
|
||||
# Left and Right
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwy, self.nwz + 1, self.nwx, 2, self.Hz, precursors.ey_left, precursors.ey_right, self.IDlookup['Hz'], 1, -1, 1, config.get_model_config().ompthreads)
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwy + 1, self.nwz, self.nwx, 2, self.Hy, precursors.ez_left, precursors.ez_right, self.IDlookup['Hy'], -1, 1, 1, config.get_model_config().ompthreads)
|
||||
# Bottom and top
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID,
|
||||
self.n_boundary_cells, -1, self.nwx, self.nwy + 1, self.nwz, 1,
|
||||
self.Hy, precursors.ex_bottom, precursors.ex_top,
|
||||
self.IDlookup['Hy'], 1, -1, 3,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Front and Back
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx, self.nwz + 1, self.nwy, 3, self.Hz, precursors.ex_front, precursors.ex_back, self.IDlookup['Hz'], -1, 1, 2, config.get_model_config().ompthreads)
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID, self.n_boundary_cells, -1, self.nwx + 1, self.nwz, self.nwy, 3, self.Hx, precursors.ez_front, precursors.ez_back, self.IDlookup['Hx'], 1, -1, 2, config.get_model_config().ompthreads)
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID,
|
||||
self.n_boundary_cells, -1, self.nwx + 1, self.nwy, self.nwz, 1,
|
||||
self.Hx, precursors.ey_bottom, precursors.ey_top,
|
||||
self.IDlookup['Hx'], -1, 1, 3,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Left and right
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID,
|
||||
self.n_boundary_cells, -1, self.nwy, self.nwz + 1, self.nwx, 2,
|
||||
self.Hz, precursors.ey_left, precursors.ey_right,
|
||||
self.IDlookup['Hz'], 1, -1, 1,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID,
|
||||
self.n_boundary_cells, -1, self.nwy + 1, self.nwz, self.nwx, 2,
|
||||
self.Hy, precursors.ez_left, precursors.ez_right,
|
||||
self.IDlookup['Hy'], -1, 1, 1,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Front and back
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID,
|
||||
self.n_boundary_cells, -1, self.nwx, self.nwz + 1, self.nwy, 3,
|
||||
self.Hz, precursors.ex_front, precursors.ex_back,
|
||||
self.IDlookup['Hz'], -1, 1, 2,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsH, self.ID,
|
||||
self.n_boundary_cells, -1, self.nwx + 1, self.nwz, self.nwy, 3,
|
||||
self.Hx, precursors.ez_front, precursors.ez_back,
|
||||
self.IDlookup['Hx'], 1, -1, 2,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
def update_electric_is(self, precursors):
|
||||
"""Updates the subgrid nodes at the IS with the currents derived
|
||||
from the main grid.
|
||||
|
||||
Args:
|
||||
nwl, nwm, nwn, face, field, inc_field, lookup_id, sign, mod, co
|
||||
precursors
|
||||
"""
|
||||
|
||||
# Form of FDTD update equations for E
|
||||
# Ex = c0(Ex) + c2(dHz) - c3(dHy)
|
||||
# Ey = c0(Ey) + c3(dHx) - c1(dHz)
|
||||
# Ez = c0(Ez) + c1(dHy) - c2(dHx)
|
||||
|
||||
# Bottom and Top
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx, self.nwy + 1, self.nwz, 1, self.Ex, precursors.hy_bottom, precursors.hy_top, self.IDlookup['Ex'], 1, -1, 3, config.get_model_config().ompthreads)
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx + 1, self.nwy, self.nwz, 1, self.Ey, precursors.hx_bottom, precursors.hx_top, self.IDlookup['Ey'], -1, 1, 3, config.get_model_config().ompthreads)
|
||||
# Bottom and top
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID,
|
||||
self.n_boundary_cells, 0, self.nwx, self.nwy + 1, self.nwz, 1,
|
||||
self.Ex, precursors.hy_bottom, precursors.hy_top,
|
||||
self.IDlookup['Ex'], 1, -1, 3,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Left and Right
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwy, self.nwz + 1, self.nwx, 2, self.Ey, precursors.hz_left, precursors.hz_right, self.IDlookup['Ey'], 1, -1, 1, config.get_model_config().ompthreads)
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwy + 1, self.nwz, self.nwx, 2, self.Ez, precursors.hy_left, precursors.hy_right, self.IDlookup['Ez'], -1, 1, 1, config.get_model_config().ompthreads)
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID,
|
||||
self.n_boundary_cells, 0, self.nwx + 1, self.nwy, self.nwz, 1,
|
||||
self.Ey, precursors.hx_bottom, precursors.hx_top,
|
||||
self.IDlookup['Ey'], -1, 1, 3,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Front and Back
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx, self.nwz + 1, self.nwy, 3, self.Ex, precursors.hz_front, precursors.hz_back, self.IDlookup['Ex'], -1, 1, 2, config.get_model_config().ompthreads)
|
||||
cython_update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID, self.n_boundary_cells, 0, self.nwx + 1, self.nwz, self.nwy, 3, self.Ez, precursors.hx_front, precursors.hx_back, self.IDlookup['Ez'], 1, -1, 2, config.get_model_config().ompthreads)
|
||||
# Left and right
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID,
|
||||
self.n_boundary_cells, 0, self.nwy, self.nwz + 1, self.nwx, 2,
|
||||
self.Ey, precursors.hz_left, precursors.hz_right,
|
||||
self.IDlookup['Ey'], 1, -1, 1,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID,
|
||||
self.n_boundary_cells, 0, self.nwy + 1, self.nwz, self.nwx, 2,
|
||||
self.Ez, precursors.hy_left, precursors.hy_right,
|
||||
self.IDlookup['Ez'], -1, 1, 1,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Front and back
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID,
|
||||
self.n_boundary_cells, 0, self.nwx, self.nwz + 1, self.nwy, 3,
|
||||
self.Ex, precursors.hz_front, precursors.hz_back,
|
||||
self.IDlookup['Ex'], -1, 1, 2,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_is(self.nwx, self.nwy, self.nwz, self.updatecoeffsE, self.ID,
|
||||
self.n_boundary_cells, 0, self.nwx + 1, self.nwz, self.nwy, 3,
|
||||
self.Ez, precursors.hx_front, precursors.hx_back,
|
||||
self.IDlookup['Ez'], 1, -1, 2,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
def update_electric_os(self, main_grid):
|
||||
""""""
|
||||
"""
|
||||
Args:
|
||||
main_grid: FDTDGrid class describing a grid in a model.
|
||||
"""
|
||||
|
||||
i_l = self.i0 - self.is_os_sep
|
||||
i_u = self.i1 + self.is_os_sep
|
||||
j_l = self.j0 - self.is_os_sep
|
||||
@@ -92,26 +149,62 @@ class SubGridHSG(SubGridBaseGrid):
|
||||
k_l = self.k0 - self.is_os_sep
|
||||
k_u = self.k1 + self.is_os_sep
|
||||
|
||||
# Args: sub_grid, normal, l_l, l_u, m_l, m_u, n_l, n_u, nwn, lookup_id, field, inc_field, co, sign_n, sign_f
|
||||
|
||||
# Form of FDTD update equations for E
|
||||
# Ex = c0(Ex) + c2(dHz) - c3(dHy)
|
||||
# Ey = c0(Ey) + c3(dHx) - c1(dHz)
|
||||
# Ez = c0(Ez) + c1(dHy) - c2(dHx)
|
||||
|
||||
cython_update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 3, i_l, i_u, k_l, k_u + 1, j_l, j_u, self.nwy, main_grid.IDlookup['Ex'], main_grid.Ex, self.Hz, 2, 1, -1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
cython_update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 3, i_l, i_u + 1, k_l, k_u, j_l, j_u, self.nwy, main_grid.IDlookup['Ez'], main_grid.Ez, self.Hx, 2, -1, 1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
# Front and back
|
||||
update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 3,
|
||||
i_l, i_u, k_l, k_u + 1, j_l, j_u, self.nwy,
|
||||
main_grid.IDlookup['Ex'], main_grid.Ex, self.Hz,
|
||||
2, 1, -1, 1, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Left and Right
|
||||
cython_update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 2, j_l, j_u, k_l, k_u + 1, i_l, i_u, self.nwx, main_grid.IDlookup['Ey'], main_grid.Ey, self.Hz, 1, -1, 1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
cython_update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 2, j_l, j_u + 1, k_l, k_u, i_l, i_u, self.nwx, main_grid.IDlookup['Ez'], main_grid.Ez, self.Hy, 1, 1, -1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 3,
|
||||
i_l, i_u + 1, k_l, k_u, j_l, j_u, self.nwy,
|
||||
main_grid.IDlookup['Ez'], main_grid.Ez, self.Hx,
|
||||
2, -1, 1, 0, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Bottom and Top
|
||||
cython_update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 1, i_l, i_u, j_l, j_u + 1, k_l, k_u, self.nwz, main_grid.IDlookup['Ex'], main_grid.Ex, self.Hy, 3, -1, 1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
cython_update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 1, i_l, i_u + 1, j_l, j_u, k_l, k_u, self.nwz, main_grid.IDlookup['Ey'], main_grid.Ey, self.Hx, 3, 1, -1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
# Left and right
|
||||
update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 2,
|
||||
j_l, j_u, k_l, k_u + 1, i_l, i_u, self.nwx,
|
||||
main_grid.IDlookup['Ey'], main_grid.Ey, self.Hz,
|
||||
1, -1, 1, 1, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 2,
|
||||
j_l, j_u + 1, k_l, k_u, i_l, i_u, self.nwx,
|
||||
main_grid.IDlookup['Ez'], main_grid.Ez, self.Hy,
|
||||
1, 1, -1, 0, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Bottom and top
|
||||
update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 1,
|
||||
i_l, i_u, j_l, j_u + 1, k_l, k_u, self.nwz,
|
||||
main_grid.IDlookup['Ex'], main_grid.Ex, self.Hy,
|
||||
3, -1, 1, 1, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_electric_os(main_grid.updatecoeffsE, main_grid.ID, 1,
|
||||
i_l, i_u + 1, j_l, j_u, k_l, k_u, self.nwz,
|
||||
main_grid.IDlookup['Ey'], main_grid.Ey, self.Hx,
|
||||
3, 1, -1, 0, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
def update_magnetic_os(self, main_grid):
|
||||
""""""
|
||||
"""
|
||||
Args:
|
||||
main_grid: FDTDGrid class describing a grid in a model.
|
||||
"""
|
||||
|
||||
i_l = self.i0 - self.is_os_sep
|
||||
i_u = self.i1 + self.is_os_sep
|
||||
j_l = self.j0 - self.is_os_sep
|
||||
@@ -124,23 +217,55 @@ class SubGridHSG(SubGridBaseGrid):
|
||||
# Hy = c0Hy - c3Ex + c1Ez
|
||||
# Hx = c0Hx - c2Ez + c3Ey
|
||||
|
||||
# Args: sub_grid, normal, l_l, l_u, m_l, m_u, n_l, n_u, nwn, lookup_id, field, inc_field, co, sign_n, sign_f):
|
||||
|
||||
# Front and back
|
||||
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 3, i_l, i_u, k_l, k_u + 1, j_l - 1, j_u, self.nwy, main_grid.IDlookup['Hz'], main_grid.Hz, self.Ex, 2, 1, -1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 3, i_l, i_u + 1, k_l, k_u, j_l - 1, j_u, self.nwy, main_grid.IDlookup['Hx'], main_grid.Hx, self.Ez, 2, -1, 1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 3,
|
||||
i_l, i_u, k_l, k_u + 1, j_l - 1, j_u, self.nwy,
|
||||
main_grid.IDlookup['Hz'], main_grid.Hz, self.Ex,
|
||||
2, 1, -1, 1, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Left and Right
|
||||
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 2, j_l, j_u, k_l, k_u + 1, i_l - 1, i_u, self.nwx, main_grid.IDlookup['Hz'], main_grid.Hz, self.Ey, 1, -1, 1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 2, j_l, j_u + 1, k_l, k_u, i_l - 1, i_u, self.nwx, main_grid.IDlookup['Hy'], main_grid.Hy, self.Ez, 1, 1, -1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 3,
|
||||
i_l, i_u + 1, k_l, k_u, j_l - 1, j_u, self.nwy,
|
||||
main_grid.IDlookup['Hx'], main_grid.Hx, self.Ez,
|
||||
2, -1, 1, 0, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Bottom and Top
|
||||
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 1, i_l, i_u, j_l, j_u + 1, k_l - 1, k_u, self.nwz, main_grid.IDlookup['Hy'], main_grid.Hy, self.Ex, 3, -1, 1, 1, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
cython_update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 1, i_l, i_u + 1, j_l, j_u, k_l - 1, k_u, self.nwz, main_grid.IDlookup['Hx'], main_grid.Hx, self.Ey, 3, 1, -1, 0, self.ratio, self.is_os_sep, self.n_boundary_cells, config.get_model_config().ompthreads)
|
||||
# Left and right
|
||||
update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 2,
|
||||
j_l, j_u, k_l, k_u + 1, i_l - 1, i_u, self.nwx,
|
||||
main_grid.IDlookup['Hz'], main_grid.Hz, self.Ey,
|
||||
1, -1, 1, 1, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 2,
|
||||
j_l, j_u + 1, k_l, k_u, i_l - 1, i_u, self.nwx,
|
||||
main_grid.IDlookup['Hy'], main_grid.Hy, self.Ez,
|
||||
1, 1, -1, 0, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
# Bottom and top
|
||||
update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 1,
|
||||
i_l, i_u, j_l, j_u + 1, k_l - 1, k_u, self.nwz,
|
||||
main_grid.IDlookup['Hy'], main_grid.Hy, self.Ex,
|
||||
3, -1, 1, 1, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
update_magnetic_os(main_grid.updatecoeffsH, main_grid.ID, 1,
|
||||
i_l, i_u + 1, j_l, j_u, k_l - 1, k_u, self.nwz,
|
||||
main_grid.IDlookup['Hx'], main_grid.Hx, self.Ey,
|
||||
3, 1, -1, 0, self.ratio, self.is_os_sep,
|
||||
self.n_boundary_cells,
|
||||
config.get_model_config().ompthreads)
|
||||
|
||||
def print_info(self):
|
||||
"""Prints information about the subgrid.
|
||||
|
||||
Useful info:
|
||||
Total region = working region +
|
||||
2 * (is_os_sep * pml_separation * pml_thickness)
|
||||
is_os_sep: number of main grid cells between the Inner Surface and
|
||||
@@ -161,7 +286,7 @@ class SubGridHSG(SubGridBaseGrid):
|
||||
self.k1 * self.dz * self.ratio))
|
||||
|
||||
logger.info('')
|
||||
logger.debug(f'[{self.name}] Type: {self.gridtype}')
|
||||
logger.debug(f'[{self.name}] Type: {self.__class__.__name__}')
|
||||
logger.info(f'[{self.name}] Ratio: 1:{self.ratio}')
|
||||
logger.info(f'[{self.name}] Spatial discretisation: {self.dx:g} x ' +
|
||||
f'{self.dy:g} x {self.dz:g}m')
|
||||
|
在新工单中引用
屏蔽一个用户