你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
Cleanup of imports and checking using pylint
这个提交包含在:
@@ -1,7 +1,6 @@
|
||||
import numpy as np
|
||||
|
||||
from gprMax.config import c
|
||||
from gprMax.config import e0
|
||||
import gprMax.config as config
|
||||
from gprMax.waveforms import Waveform
|
||||
|
||||
|
||||
@@ -52,52 +51,41 @@ def hertzian_dipole_fs(iterations, dt, dxdydz, rx):
|
||||
x = rx[0]
|
||||
y = rx[1]
|
||||
z = rx[2]
|
||||
if z == 0:
|
||||
sign_z = 1
|
||||
else:
|
||||
sign_z = np.sign(z)
|
||||
|
||||
# Coordinates of Rx for Ex FDTD component
|
||||
Ex_x = x + 0.5 * dx
|
||||
Ex_y = y
|
||||
Ex_z = z - 0.5 * dz
|
||||
Er_x = np.sqrt((Ex_x**2 + Ex_y**2 + Ex_z**2))
|
||||
tau_Ex = Er_x / c
|
||||
tau_Ex = Er_x / config.sim_config.em_consts['c']
|
||||
|
||||
# Coordinates of Rx for Ey FDTD component
|
||||
Ey_x = x
|
||||
Ey_y = y + 0.5 * dy
|
||||
Ey_z = z - 0.5 * dz
|
||||
Er_y = np.sqrt((Ey_x**2 + Ey_y**2 + Ey_z**2))
|
||||
tau_Ey = Er_y / c
|
||||
tau_Ey = Er_y / config.sim_config.em_consts['c']
|
||||
|
||||
# Coordinates of Rx for Ez FDTD component
|
||||
Ez_x = x
|
||||
Ez_y = y
|
||||
Ez_z = z
|
||||
Er_z = np.sqrt((Ez_x**2 + Ez_y**2 + Ez_z**2))
|
||||
tau_Ez = Er_z / c
|
||||
tau_Ez = Er_z / config.sim_config.em_consts['c']
|
||||
|
||||
# Coordinates of Rx for Hx FDTD component
|
||||
Hx_x = x
|
||||
Hx_y = y + 0.5 * dy
|
||||
Hx_z = z
|
||||
Hr_x = np.sqrt((Hx_x**2 + Hx_y**2 + Hx_z**2))
|
||||
tau_Hx = Hr_x / c
|
||||
tau_Hx = Hr_x / config.sim_config.em_consts['c']
|
||||
|
||||
# Coordinates of Rx for Hy FDTD component
|
||||
Hy_x = x + 0.5 * dx
|
||||
Hy_y = y
|
||||
Hy_z = z
|
||||
Hr_y = np.sqrt((Hy_x**2 + Hy_y**2 + Hy_z**2))
|
||||
tau_Hy = Hr_y / c
|
||||
|
||||
# Coordinates of Rx for Hz FDTD component
|
||||
Hz_x = x + 0.5 * dx
|
||||
Hz_y = y + 0.5 * dy
|
||||
Hz_z = z - 0.5 * dz
|
||||
Hr_z = np.sqrt((Hz_x**2 + Hz_y**2 + Hz_z**2))
|
||||
tau_Hz = Hr_z / c
|
||||
tau_Hy = Hr_y / config.sim_config.em_consts['c']
|
||||
|
||||
# Initialise fields
|
||||
fields = np.zeros((iterations, 6))
|
||||
@@ -118,30 +106,24 @@ def hertzian_dipole_fs(iterations, dt, dxdydz, rx):
|
||||
f_Ez = w.calculate_value((timestep * dt) - tau_Ez, dt) * dl
|
||||
fdot_Ez = wdot.calculate_value((timestep * dt) - tau_Ez, dt) * dl
|
||||
|
||||
fint_Hx = wint.calculate_value((timestep * dt) - tau_Hx, dt) * dl
|
||||
f_Hx = w.calculate_value((timestep * dt) - tau_Hx, dt) * dl
|
||||
fdot_Hx = wdot.calculate_value((timestep * dt) - tau_Hx, dt) * dl
|
||||
|
||||
fint_Hy = wint.calculate_value((timestep * dt) - tau_Hy, dt) * dl
|
||||
f_Hy = w.calculate_value((timestep * dt) - tau_Hy, dt) * dl
|
||||
fdot_Hy = wdot.calculate_value((timestep * dt) - tau_Hy, dt) * dl
|
||||
|
||||
fint_Hz = wint.calculate_value((timestep * dt) - tau_Hz, dt) * dl
|
||||
f_Hz = w.calculate_value((timestep * dt) - tau_Hz, dt) * dl
|
||||
fdot_Hz = wdot.calculate_value((timestep * dt) - tau_Hz, dt) * dl
|
||||
|
||||
# Ex
|
||||
fields[timestep, 0] = ((Ex_x * Ex_z) / (4 * np.pi * e0 * Er_x**5)) * (3 * (fint_Ex + (tau_Ex * f_Ex)) + (tau_Ex**2 * fdot_Ex))
|
||||
fields[timestep, 0] = ((Ex_x * Ex_z) / (4 * np.pi * config.sim_config.em_consts['e0'] * Er_x**5)) * (3 * (fint_Ex + (tau_Ex * f_Ex)) + (tau_Ex**2 * fdot_Ex))
|
||||
|
||||
# Ey
|
||||
try:
|
||||
tmp = Ey_y / Ey_x
|
||||
except ZeroDivisionError:
|
||||
tmp = 0
|
||||
fields[timestep, 1] = tmp * ((Ey_x * Ey_z) / (4 * np.pi * e0 * Er_y**5)) * (3 * (fint_Ey + (tau_Ey * f_Ey)) + (tau_Ey**2 * fdot_Ey))
|
||||
fields[timestep, 1] = tmp * ((Ey_x * Ey_z) / (4 * np.pi * config.sim_config.em_consts['e0'] * Er_y**5)) * (3 * (fint_Ey + (tau_Ey * f_Ey)) + (tau_Ey**2 * fdot_Ey))
|
||||
|
||||
# Ez
|
||||
fields[timestep, 2] = (1 / (4 * np.pi * e0 * Er_z**5)) * ((2 * Ez_z**2 - (Ez_x**2 + Ez_y**2)) * (fint_Ez + (tau_Ez * f_Ez)) - (Ez_x**2 + Ez_y**2) * tau_Ez**2 * fdot_Ez)
|
||||
fields[timestep, 2] = (1 / (4 * np.pi * config.sim_config.em_consts['e0'] * Er_z**5)) * ((2 * Ez_z**2 - (Ez_x**2 + Ez_y**2)) * (fint_Ez + (tau_Ez * f_Ez)) - (Ez_x**2 + Ez_y**2) * tau_Ez**2 * fdot_Ez)
|
||||
|
||||
# Hx
|
||||
fields[timestep, 3] = - (Hx_y / (4 * np.pi * Hr_x**3)) * (f_Hx + (tau_Hx * fdot_Hx))
|
||||
|
@@ -17,13 +17,12 @@
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import h5py
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
import numpy as np
|
||||
from gprMax.exceptions import CmdInputError
|
||||
|
||||
"""Plots a comparison of fields between given simulation output and experimental data files."""
|
||||
|
@@ -16,21 +16,21 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from colorama import init, Fore, Style
|
||||
init()
|
||||
import gprMax
|
||||
import h5py
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from colorama import Fore, Style, init
|
||||
init()
|
||||
from gprMax.exceptions import GeneralError
|
||||
from tests.analytical_solutions import hertzian_dipole_fs
|
||||
|
||||
if sys.platform == 'linux':
|
||||
plt.switch_backend('agg')
|
||||
|
||||
import gprMax
|
||||
from gprMax.exceptions import GeneralError
|
||||
from tests.analytical_solutions import hertzian_dipole_fs
|
||||
|
||||
"""Compare field outputs
|
||||
|
||||
|
在新工单中引用
屏蔽一个用户