Added kwargs to allow for optimisation of parameters.

这个提交包含在:
craig-warren
2020-05-18 15:56:21 +01:00
父节点 6ebbe8a730
当前提交 6bad6d65de
共有 2 个文件被更改,包括 117 次插入58 次删除

查看文件

@@ -12,7 +12,7 @@ import gprMax
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def antenna_like_GSSI_1500(x, y, z, resolution=0.001): def antenna_like_GSSI_1500(x, y, z, resolution=0.001, **kwargs):
"""Inserts a description of an antenna similar to the GSSI 1.5GHz antenna. """Inserts a description of an antenna similar to the GSSI 1.5GHz antenna.
Can be used with 1mm (default) or 2mm spatial resolution. The external Can be used with 1mm (default) or 2mm spatial resolution. The external
dimensions of the antenna are 170x108x45mm. One output point is defined dimensions of the antenna are 170x108x45mm. One output point is defined
@@ -25,6 +25,8 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001):
centre of the antenna in the x-y plane and the centre of the antenna in the x-y plane and the
bottom of the antenna skid in the z direction. bottom of the antenna skid in the z direction.
resolution (float): Spatial resolution for the antenna model. resolution (float): Spatial resolution for the antenna model.
kwargs (dict): Optional variables, e.g. can be fed from an optimisation
process.
Returns: Returns:
scene_objects (list): All model objects that will be part of a scene. scene_objects (list): All model objects that will be part of a scene.
@@ -65,7 +67,28 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001):
logger.exception('This antenna module can only be used with a spatial discretisation of 1mm or 2mm') logger.exception('This antenna module can only be used with a spatial discretisation of 1mm or 2mm')
raise ValueError raise ValueError
# Specify optimisation state of antenna model # If using parameters from an optimisation
try:
kwargs
absorber1Er = kwargs['absorber1Er']
absorber1sig = kwargs['absorber1sig']
absorber2Er = kwargs['absorber2Er']
absorber2sig = kwargs['absorber2sig']
pcbEr = kwargs['pcbEr']
pcbsig = kwargs['pcbsig']
hdpeEr = kwargs['hdpeEr']
hdpesig = kwargs['hdpesig']
sourceresistance = 195
rxres = 50
absorber1 = gprMax.Material(er=absorber1Er, se=absorber1sig, mr=1, sm=0, id='absorber1')
absorber2 = gprMax.Material(er=absorber2Er, se=absorber2sig, mr=1, sm=0, id='absorber2')
pcb = gprMax.Material(er=pcbEr, se=pcbsig, mr=1, sm=0, id='pcb')
hdpe = gprMax.Material(er=hdpeEr, se=hdpesig, mr=1, sm=0, id='hdpe')
scene_objects.extend((absorber1, absorber2, pcb, hdpe))
# Otherwise choose parameters for different optimisation models
except:
# Specify optimisation model
optstate = ['WarrenThesis', 'DebyeAbsorber', 'GiannakisPaper'] optstate = ['WarrenThesis', 'DebyeAbsorber', 'GiannakisPaper']
optstate = optstate[0] optstate = optstate[0]
@@ -272,14 +295,18 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001):
# Excitation # Excitation
if optstate == 'WarrenThesis' or optstate == 'DebyeAbsorber': if optstate == 'WarrenThesis' or optstate == 'DebyeAbsorber':
# Gaussian pulse # Gaussian pulse
w1 = gprMax.Waveform(wave_type='gaussian', amp=1, freq=excitationfreq, id='my_gaussian') w1 = gprMax.Waveform(wave_type='gaussian', amp=1,
vs1 = gprMax.VoltageSource(polarisation='y', p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id='my_gaussian') freq=excitationfreq, id='my_gaussian')
vs1 = gprMax.VoltageSource(polarisation='y', p1=(tx[0], tx[1], tx[2]),
resistance=sourceresistance, waveform_id='my_gaussian')
scene_objects.extend((w1, vs1)) scene_objects.extend((w1, vs1))
elif optstate == 'GiannakisPaper': elif optstate == 'GiannakisPaper':
# Optimised custom pulse # Optimised custom pulse
exc1 = gprMax.ExcitationFile(filepath='../user_libs/antennas/GSSI1p5optpulse.txt', kind='linear', fill_value='extrapolate') exc1 = gprMax.ExcitationFile(filepath='../user_libs/antennas/GSSI1p5optpulse.txt',
vs1 = gprMax.VoltageSource(polarisation='y', p1=(tx[0], tx[1], tx[2]), resistance=sourceresistance, waveform_id='GSSI1p5optpulse') kind='linear', fill_value='extrapolate')
vs1 = gprMax.VoltageSource(polarisation='y', p1=(tx[0], tx[1], tx[2]),
resistance=sourceresistance, waveform_id='GSSI1p5optpulse')
scene_objects.extend((exc1, vs1)) scene_objects.extend((exc1, vs1))
# Output point - receiver bowtie # Output point - receiver bowtie
@@ -306,7 +333,7 @@ def antenna_like_GSSI_1500(x, y, z, resolution=0.001):
return scene_objects return scene_objects
def antenna_like_GSSI_400(x, y, z, resolution=0.001): def antenna_like_GSSI_400(x, y, z, resolution=0.001, **kwargs):
"""Inserts a description of an antenna similar to the GSSI 400MHz antenna. """Inserts a description of an antenna similar to the GSSI 400MHz antenna.
Can be used with 0.5mm, 1mm (default) or 2mm spatial resolution. Can be used with 0.5mm, 1mm (default) or 2mm spatial resolution.
The external dimensions of the antenna are 300x300x178mm. The external dimensions of the antenna are 300x300x178mm.
@@ -315,8 +342,13 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.001):
of the electric field. of the electric field.
Args: Args:
x, y, z (float): Coordinates of a location in the model to insert the antenna. Coordinates are relative to the geometric centre of the antenna in the x-y plane and the bottom of the antenna skid in the z direction. x, y, z (float): Coordinates of a location in the model to insert the
antenna. Coordinates are relative to the geometric
centre of the antenna in the x-y plane and the
bottom of the antenna skid in the z direction.
resolution (float): Spatial resolution for the antenna model. resolution (float): Spatial resolution for the antenna model.
kwargs (dict): Optional variables, e.g. can be fed from an optimisation
process.
Returns: Returns:
scene_objects (list): All model objects that will be part of a scene. scene_objects (list): All model objects that will be part of a scene.
@@ -338,15 +370,27 @@ def antenna_like_GSSI_400(x, y, z, resolution=0.001):
metalmiddleplateheight = 0.11 metalmiddleplateheight = 0.11
smooth_dec = 'yes' # choose to use dielectric smoothing or not smooth_dec = 'yes' # choose to use dielectric smoothing or not
src_type = 'voltage_source' # # source type. "voltage_source" or "transmission_line" src_type = 'voltage_source' # source type. "voltage_source" or "transmission_line"
pcber = 2.35
hdper = 2.35
skidthickness = 0.01
# If using parameters from an optimisation
try:
kwargs
excitationfreq = kwargs['excitationfreq']
sourceresistance = kwargs['sourceresistance']
receiverresistance = sourceresistance
absorberEr = kwargs['absorberEr']
absorbersig = kwargs['absorbersig']
# Otherwise choose pre-set optimised parameters
except:
excitationfreq = 0.39239891e9 # GHz excitationfreq = 0.39239891e9 # GHz
sourceresistance = 111.59927 # Ohms sourceresistance = 111.59927 # Ohms
receiverresistance = sourceresistance # Ohms receiverresistance = sourceresistance # Ohms
absorberEr = 1.1 absorberEr = 1.1
absorbersig = 0.062034689 absorbersig = 0.062034689 # S/m
pcber = 2.35
hdper = 2.35
skidthickness = 0.01
x = x - (casesize[0] / 2) x = x - (casesize[0] / 2)
y = y - (casesize[1] / 2) y = y - (casesize[1] / 2)

查看文件

@@ -12,7 +12,7 @@ import gprMax
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def antenna_like_MALA_1200(x, y, z, resolution=0.001): def antenna_like_MALA_1200(x, y, z, resolution=0.001, **kwargs):
"""Inserts a description of an antenna similar to the MALA 1.2GHz antenna. """Inserts a description of an antenna similar to the MALA 1.2GHz antenna.
Can be used with 1mm (default) or 2mm spatial resolution. Can be used with 1mm (default) or 2mm spatial resolution.
The external dimensions of the antenna are 184x109x46mm. The external dimensions of the antenna are 184x109x46mm.
@@ -21,8 +21,13 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001):
of the electric field (x component if the antenna is rotated 90 degrees). of the electric field (x component if the antenna is rotated 90 degrees).
Args: Args:
x, y, z (float): Coordinates of a location in the model to insert the antenna. Coordinates are relative to the geometric centre of the antenna in the x-y plane and the bottom of the antenna skid in the z direction. x, y, z (float): Coordinates of a location in the model to insert the
antenna. Coordinates are relative to the geometric
centre of the antenna in the x-y plane and the
bottom of the antenna skid in the z direction.
resolution (float): Spatial resolution for the antenna model. resolution (float): Spatial resolution for the antenna model.
kwargs (dict): Optional variables, e.g. can be fed from an optimisation
process.
Returns: Returns:
scene_objects (list): All model objects that will be part of a scene. scene_objects (list): All model objects that will be part of a scene.
@@ -42,6 +47,16 @@ def antenna_like_MALA_1200(x, y, z, resolution=0.001):
skidthickness = 0.006 skidthickness = 0.006
bowtieheight = 0.025 bowtieheight = 0.025
# If using parameters from an optimisation
try:
kwargs
excitationfreq = kwargs['excitationfreq']
sourceresistance = kwargs['sourceresistance']
absorberEr = kwargs['absorberEr']
absorbersig = kwargs['absorbersig']
# Otherwise choose pre-set optimised parameters
except:
# Original optimised values from http://hdl.handle.net/1842/4074 # Original optimised values from http://hdl.handle.net/1842/4074
excitationfreq = 0.978e9 excitationfreq = 0.978e9
sourceresistance = 1000 sourceresistance = 1000