Revert "multi cmds to functions"

This reverts commit 92bf59bc36.
这个提交包含在:
craig-warren
2016-06-12 14:06:56 +08:00
父节点 92bf59bc36
当前提交 c9c627720a
共有 5 个文件被更改,包括 822 次插入926 次删除

查看文件

@@ -150,7 +150,7 @@ def check_cmd_names(processedlines, checkessential=True):
singlecmds = dict.fromkeys(['#domain', '#dx_dy_dz', '#time_window', '#title', '#messages', '#num_threads', '#time_step_stability_factor', '#pml_cells', '#excitation_file', '#src_steps', '#rx_steps', '#taguchi', '#end_taguchi'], 'None')
# Commands that there can be multiple instances of in a model - these will be lists within the dictionary
multiplecmds = {key: [] for key in ['#geometry_view', '#material', '#soil_peplinski', '#add_dispersion_debye', '#add_dispersion_lorentz', '#add_dispersion_drude', '#waveform', '#voltage_source', '#hertzian_dipole', '#magnetic_dipole', '#transmission_line', '#tem_transmission_line', '#rx', '#rx_box', '#snapshot', '#pml_cfs']}
multiplecmds = {key: [] for key in ['#geometry_view', '#material', '#soil_peplinski', '#add_dispersion_debye', '#add_dispersion_lorentz', '#add_dispersion_drude', '#waveform', '#voltage_source', '#hertzian_dipole', '#magnetic_dipole', '#transmission_line', '#rx', '#rx_box', '#snapshot', '#pml_cfs']}
# Geometry object building commands that there can be multiple instances of in a model - these will be lists within the dictionary
geometrycmds = ['#geometry_objects_file', '#edge', '#plate', '#triangle', '#box', '#sphere', '#cylinder', '#cylindrical_sector', '#fractal_box', '#add_surface_roughness', '#add_surface_water', '#add_grass']

文件差异内容过多而无法显示 加载差异

查看文件

@@ -20,12 +20,6 @@ import numpy as np
from gprMax.constants import e0, m0, floattype, complextype
# Look up for material ids
material_ids = {
'pec': 0,
'freespace': 1
}
class Material(object):
"""Materials, their properties and update coefficients."""

查看文件

@@ -20,11 +20,9 @@ from copy import deepcopy
import numpy as np
from .constants import c, floattype
from .grid import Ix, Iy, Iz
from .utilities import round_value
from .materials import material_ids
from .exceptions import GeneralError
from gprMax.constants import c, floattype
from gprMax.grid import Ix, Iy, Iz
from gprMax.utilities import round_value
class Source(object):
@@ -45,13 +43,10 @@ class Source(object):
class VoltageSource(Source):
"""The voltage source can be a hard source if it's resistance is zero,
i.e. the time variation of the specified electric field component is
prescribed. If it's resistance is non-zero it behaves as a resistive
voltage source."""
"""The voltage source can be a hard source if it's resistance is zero, i.e. the time variation of the specified electric field component is prescribed. If it's resistance is non-zero it behaves as a resistive voltage source."""
def __init__(self):
super().__init__()
super(Source, self).__init__()
self.resistance = None
def update_electric(self, abstime, updatecoeffsE, ID, Ex, Ey, Ez, G):
@@ -130,7 +125,7 @@ class HertzianDipole(Source):
"""The Hertzian dipole is an additive source (electric current density)."""
def __init__(self):
super().__init__()
super(Source, self).__init__()
def update_electric(self, abstime, updatecoeffsE, ID, Ex, Ey, Ez, G):
"""Updates electric field values for a Hertzian dipole.
@@ -168,7 +163,7 @@ class MagneticDipole(Source):
"""The magnetic dipole is an additive source (magnetic current density)."""
def __init__(self):
super().__init__()
super(Source, self).__init__()
def update_magnetic(self, abstime, updatecoeffsH, ID, Hx, Hy, Hz, G):
"""Updates magnetic field values for a magnetic dipole.
@@ -200,35 +195,28 @@ class MagneticDipole(Source):
class TransmissionLine(Source):
"""The transmission line source is a one-dimensional transmission
line which is attached virtually to a grid cell.
"""
"""The transmission line source is a one-dimensional transmission line which is attached virtually to a grid cell."""
def __init__(self, G):
"""
Args:
G (class): Grid class instance - holds essential parameters
describing the model.
G (class): Grid class instance - holds essential parameters describing the model.
"""
super().__init__()
super(Source, self).__init__()
self.resistance = None
# Coefficients for ABC termination of end of the transmission line
self.abcv0 = 0
self.abcv1 = 0
# Spatial step of transmission line (based on magic time step for
# dispersionless behaviour)
# Spatial step of transmission line (based on magic time step for dispersionless behaviour)
self.dl = c * G.dt
# Number of nodes in the transmission line (initially a long line
# to calculate incident voltage and current);
# consider putting ABCs/PML at end
# Number of nodes in the transmission line (initially a long line to calculate incident voltage and current); consider putting ABCs/PML at end
self.nl = round_value(0.667 * G.iterations)
# Nodal position of the one-way injector excitation in the
# transmission line
# Nodal position of the one-way injector excitation in the transmission line
self.srcpos = 5
# Nodal position of where line connects to antenna/main grid
@@ -239,19 +227,11 @@ class TransmissionLine(Source):
self.Vinc = np.zeros(G.iterations, dtype=floattype)
self.Iinc = np.zeros(G.iterations, dtype=floattype)
self.type_str = 'TransmissionLine'
def setID(self):
self.ID = self.type_str + '(' + str(self.xcoord) + ',' + str(self.ycoord) + ',' + str(self.zcoord) + ')'
def calculate_incident_V_I(self, G):
"""Calculates the incident voltage and current with a long length
transmission line not connected to the main grid from:
http://dx.doi.org/10.1002/mop.10415
"""Calculates the incident voltage and current with a long length transmission line not connected to the main grid from: http://dx.doi.org/10.1002/mop.10415
Args:
G (class): Grid class instance - holds essential parameters
describing the model.
G (class): Grid class instance - holds essential parameters describing the model.
"""
abstime = 0
@@ -263,16 +243,14 @@ class TransmissionLine(Source):
self.update_current(abstime, G)
abstime += 0.5 * G.dt
# Shorten number of nodes in the transmission line before use
# with main grid
# Shorten number of nodes in the transmission line before use with main grid
self.nl = self.antpos + 1
def update_abc(self, G):
"""Updates absorbing boundary condition at end of the transmission line.
Args:
G (class): Grid class instance - holds essential parameters
describing the model.
G (class): Grid class instance - holds essential parameters describing the model.
"""
h = (c * G.dt - self.dl) / (c * G.dt + self.dl)
@@ -286,8 +264,7 @@ class TransmissionLine(Source):
Args:
time (float): Absolute time.
G (class): Grid class instance - holds essential parameters
describing the model.
G (class): Grid class instance - holds essential parameters describing the model.
"""
# Update all the voltage values along the line
@@ -305,8 +282,7 @@ class TransmissionLine(Source):
Args:
time (float): Absolute time.
G (class): Grid class instance - holds essential parameters
describing the model.
G (class): Grid class instance - holds essential parameters describing the model.
"""
# Update all the current values along the line
@@ -317,18 +293,16 @@ class TransmissionLine(Source):
self.current[self.srcpos - 1] += (c * G.dt / self.dl) * waveform.amp * waveform.calculate_value(time - 0.5 * G.dt, G.dt) * (1 / self.resistance)
def update_electric(self, abstime, Ex, Ey, Ez, G):
"""Updates electric field value in the main grid from voltage value
in the transmission line.
"""Updates electric field value in the main grid from voltage value in the transmission line.
Args:
abstime (float): Absolute time.
Ex, Ey, Ez (memory view): numpy array of electric field values.
G (class): Grid class instance - holds essential parameters
describing the model.
G (class): Grid class instance - holds essential parameters describing the model.
"""
if abstime >= self.start and abstime <= self.stop:
# Set the time of the waveform evaluation to account
# for any delay in the start
# Set the time of the waveform evaluation to account for any delay in the start
time = abstime - self.start
i = self.xcoord
j = self.ycoord
@@ -346,19 +320,16 @@ class TransmissionLine(Source):
Ez[i, j, k] = - self.voltage[self.antpos] / G.dz
def update_magnetic(self, abstime, Hx, Hy, Hz, G):
"""Updates current value in transmission line from magnetic field
values in the main grid.
"""Updates current value in transmission line from magnetic field values in the main grid.
Args:
abstime (float): Absolute time.
Hx, Hy, Hz (memory view): numpy array of magnetic field values.
G (class): Grid class instance - holds essential parameters
describing the model.
G (class): Grid class instance - holds essential parameters describing the model.
"""
if abstime >= self.start and abstime <= self.stop:
# Set the time of the waveform evaluation to account
# for any delay in the start
# Set the time of the waveform evaluation to account for any delay in the start
time = abstime - self.start
i = self.xcoord
j = self.ycoord
@@ -375,15 +346,3 @@ class TransmissionLine(Source):
self.update_current(time, G)
class TEMTransmissionLine(TransmissionLine):
def __init__(self, G):
super().__init__(G)
self.type_str = 'TEMTransmissionLine'
def update_magnetic(self, abstime, Hx, Hy, Hz, G):
pass
def update_electric(self, abstime, Ex, Ey, Ez, G):
pass