你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 15:10:13 +08:00
Updated cmds_multiuse.py file made several small changes that make code simpler and cleaner.
这个提交包含在:
@@ -243,18 +243,15 @@ class VoltageSource(UserObjectMulti):
|
|||||||
logger.exception(self.params_str() + (' polarisation must be '
|
logger.exception(self.params_str() + (' polarisation must be '
|
||||||
'x, y, or z.'))
|
'x, y, or z.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ('2D TMx' in config.get_model_config().mode and
|
if '2D TMx' in config.get_model_config().mode and polarisation in ['y','z',]:
|
||||||
(polarisation == 'y' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be x in '
|
logger.exception(self.params_str() + (' polarisation must be x in '
|
||||||
'2D TMx mode.'))
|
'2D TMx mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMy' in config.get_model_config().mode and
|
elif '2D TMy' in config.get_model_config().mode and polarisation in ['x','z',]:
|
||||||
(polarisation == 'x' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be y in '
|
logger.exception(self.params_str() + (' polarisation must be y in '
|
||||||
'2D TMy mode.'))
|
'2D TMy mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMz' in config.get_model_config().mode and
|
elif '2D TMz' in config.get_model_config().mode and polarisation in ['x','y',]:
|
||||||
(polarisation == 'x' or polarisation == 'y')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be z in '
|
logger.exception(self.params_str() + (' polarisation must be z in '
|
||||||
'2D TMz mode.'))
|
'2D TMz mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -305,10 +302,7 @@ class VoltageSource(UserObjectMulti):
|
|||||||
'less.'))
|
'less.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
v.start = start
|
v.start = start
|
||||||
if stop > grid.timewindow:
|
v.stop = min(stop, grid.timewindow)
|
||||||
v.stop = grid.timewindow
|
|
||||||
else:
|
|
||||||
v.stop = stop
|
|
||||||
startstop = (f' start time {v.start:g} secs, finish time '
|
startstop = (f' start time {v.start:g} secs, finish time '
|
||||||
f'{v.stop:g} secs ')
|
f'{v.stop:g} secs ')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -318,7 +312,7 @@ class VoltageSource(UserObjectMulti):
|
|||||||
|
|
||||||
v.calculate_waveform_values(grid)
|
v.calculate_waveform_values(grid)
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + f'Voltage source with polarity '
|
logger.info(f'{self.grid_name(grid)}Voltage source with polarity '
|
||||||
f'{v.polarisation} at {p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m, '
|
f'{v.polarisation} at {p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m, '
|
||||||
f'resistance {v.resistance:.1f} Ohms,' + startstop +
|
f'resistance {v.resistance:.1f} Ohms,' + startstop +
|
||||||
f'using waveform {v.waveformID} created.')
|
f'using waveform {v.waveformID} created.')
|
||||||
@@ -367,8 +361,7 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
p1 = self.kwargs['p1']
|
p1 = self.kwargs['p1']
|
||||||
waveform_id = self.kwargs['waveform_id']
|
waveform_id = self.kwargs['waveform_id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at least 3 ' +
|
logger.exception(f'{self.params_str()} requires at least 3 parameters.')
|
||||||
'parameters.')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if self.do_rotate:
|
if self.do_rotate:
|
||||||
@@ -379,18 +372,15 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
logger.exception(self.params_str() + (' polarisation must be '
|
logger.exception(self.params_str() + (' polarisation must be '
|
||||||
'x, y, or z.'))
|
'x, y, or z.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ('2D TMx' in config.get_model_config().mode and
|
if '2D TMx' in config.get_model_config().mode and polarisation in ['y','z',]:
|
||||||
(polarisation == 'y' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be x in '
|
logger.exception(self.params_str() + (' polarisation must be x in '
|
||||||
'2D TMx mode.'))
|
'2D TMx mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMy' in config.get_model_config().mode and
|
elif '2D TMy' in config.get_model_config().mode and polarisation in ['x','z',]:
|
||||||
(polarisation == 'x' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be y in '
|
logger.exception(self.params_str() + (' polarisation must be y in '
|
||||||
'2D TMy mode.'))
|
'2D TMy mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMz' in config.get_model_config().mode and
|
elif '2D TMz' in config.get_model_config().mode and polarisation in ['x','y',]:
|
||||||
(polarisation == 'x' or polarisation == 'y')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be z in '
|
logger.exception(self.params_str() + (' polarisation must be z in '
|
||||||
'2D TMz mode.'))
|
'2D TMz mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -401,7 +391,7 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
|
|
||||||
# Check if there is a waveformID in the waveforms list
|
# Check if there is a waveformID in the waveforms list
|
||||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||||
logger.exception(self.params_str() + ' there is no waveform ' +
|
logger.exception(f'{self.params_str()} there is no waveform ' +
|
||||||
f'with the identifier {waveform_id}.')
|
f'with the identifier {waveform_id}.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -422,8 +412,7 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
h.xcoordorigin = xcoord
|
h.xcoordorigin = xcoord
|
||||||
h.ycoordorigin = ycoord
|
h.ycoordorigin = ycoord
|
||||||
h.zcoordorigin = zcoord
|
h.zcoordorigin = zcoord
|
||||||
h.ID = (h.__class__.__name__ + '(' + str(h.xcoord) + ',' +
|
h.ID = f'{h.__class__.__name__}({str(h.xcoord)},{str(h.ycoord)},{str(h.zcoord)})'
|
||||||
str(h.ycoord) + ',' + str(h.zcoord) + ')')
|
|
||||||
h.waveformID = waveform_id
|
h.waveformID = waveform_id
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -431,25 +420,19 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
start = self.kwargs['start']
|
start = self.kwargs['start']
|
||||||
stop = self.kwargs['stop']
|
stop = self.kwargs['stop']
|
||||||
if start < 0:
|
if start < 0:
|
||||||
logger.exception(self.params_str() + (' delay of the initiation '
|
logger.exception(f'{self.params_str()} delay of the initiation of the ' +
|
||||||
'of the source should not '
|
f'source should not be less than zero.')
|
||||||
'be less than zero.'))
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if stop < 0:
|
if stop < 0:
|
||||||
logger.exception(self.params_str() + (' time to remove the '
|
logger.exception(f'{self.params_str()} time to remove the source ' +
|
||||||
'source should not be '
|
f'should not be less than zero.')
|
||||||
'less than zero.'))
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if stop - start <= 0:
|
if stop - start <= 0:
|
||||||
logger.exception(self.params_str() + (' duration of the source '
|
logger.exception(
|
||||||
'should not be zero or '
|
f'{self.params_str()} duration of the source should not be zero or less.')
|
||||||
'less.'))
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
h.start = start
|
h.start = start
|
||||||
if stop > grid.timewindow:
|
h.stop = min(stop, grid.timewindow)
|
||||||
h.stop = grid.timewindow
|
|
||||||
else:
|
|
||||||
h.stop = stop
|
|
||||||
startstop = (f' start time {h.start:g} secs, finish time '
|
startstop = (f' start time {h.start:g} secs, finish time '
|
||||||
f'{h.stop:g} secs ')
|
f'{h.stop:g} secs ')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -460,12 +443,12 @@ class HertzianDipole(UserObjectMulti):
|
|||||||
h.calculate_waveform_values(grid)
|
h.calculate_waveform_values(grid)
|
||||||
|
|
||||||
if config.get_model_config().mode == '2D':
|
if config.get_model_config().mode == '2D':
|
||||||
logger.info(self.grid_name(grid) + f'Hertzian dipole is a line ' +
|
logger.info(f'{self.grid_name(grid)}Hertzian dipole is a line ' +
|
||||||
f'source in 2D with polarity {h.polarisation} at ' +
|
f'source in 2D with polarity {h.polarisation} at ' +
|
||||||
f'{p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m,' + startstop +
|
f'{p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m,' + startstop +
|
||||||
f'using waveform {h.waveformID} created.')
|
f'using waveform {h.waveformID} created.')
|
||||||
else:
|
else:
|
||||||
logger.info(self.grid_name(grid) + f'Hertzian dipole with ' +
|
logger.info(f'{self.grid_name(grid)}Hertzian dipole with ' +
|
||||||
f'polarity {h.polarisation} at {p2[0]:g}m, ' +
|
f'polarity {h.polarisation} at {p2[0]:g}m, ' +
|
||||||
f'{p2[1]:g}m, {p2[2]:g}m,' + startstop +
|
f'{p2[1]:g}m, {p2[2]:g}m,' + startstop +
|
||||||
f'using waveform {h.waveformID} created.')
|
f'using waveform {h.waveformID} created.')
|
||||||
@@ -514,8 +497,7 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
p1 = self.kwargs['p1']
|
p1 = self.kwargs['p1']
|
||||||
waveform_id = self.kwargs['waveform_id']
|
waveform_id = self.kwargs['waveform_id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at least five '
|
logger.exception(f'{self.params_str()} requires at least five parameters.')
|
||||||
'parameters.')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if self.do_rotate:
|
if self.do_rotate:
|
||||||
@@ -526,18 +508,15 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
logger.exception(self.params_str() + (' polarisation must be '
|
logger.exception(self.params_str() + (' polarisation must be '
|
||||||
'x, y, or z.'))
|
'x, y, or z.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ('2D TMx' in config.get_model_config().mode and
|
if '2D TMx' in config.get_model_config().mode and polarisation in ['y','z',]:
|
||||||
(polarisation == 'y' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be x in '
|
logger.exception(self.params_str() + (' polarisation must be x in '
|
||||||
'2D TMx mode.'))
|
'2D TMx mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMy' in config.get_model_config().mode and
|
elif '2D TMy' in config.get_model_config().mode and polarisation in ['x','z',]:
|
||||||
(polarisation == 'x' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be y in '
|
logger.exception(self.params_str() + (' polarisation must be y in '
|
||||||
'2D TMy mode.'))
|
'2D TMy mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMz' in config.get_model_config().mode and
|
elif '2D TMz' in config.get_model_config().mode and polarisation in ['x','y',]:
|
||||||
(polarisation == 'x' or polarisation == 'y')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be z in '
|
logger.exception(self.params_str() + (' polarisation must be z in '
|
||||||
'2D TMz mode.'))
|
'2D TMz mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -548,7 +527,7 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
|
|
||||||
# Check if there is a waveformID in the waveforms list
|
# Check if there is a waveformID in the waveforms list
|
||||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||||
logger.exception(self.params_str() + ' there is no waveform ' +
|
logger.exception(f'{self.params_str()} there is no waveform ' +
|
||||||
f'with the identifier {waveform_id}.')
|
f'with the identifier {waveform_id}.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -584,10 +563,7 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
'less.'))
|
'less.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
m.start = start
|
m.start = start
|
||||||
if stop > grid.timewindow:
|
m.stop = min(stop, grid.timewindow)
|
||||||
m.stop = grid.timewindow
|
|
||||||
else:
|
|
||||||
m.stop = stop
|
|
||||||
startstop = (f' start time {m.start:g} secs, '
|
startstop = (f' start time {m.start:g} secs, '
|
||||||
f'finish time {m.stop:g} secs ')
|
f'finish time {m.stop:g} secs ')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -597,7 +573,7 @@ class MagneticDipole(UserObjectMulti):
|
|||||||
|
|
||||||
m.calculate_waveform_values(grid)
|
m.calculate_waveform_values(grid)
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + f'Magnetic dipole with polarity ' +
|
logger.info(f'{self.grid_name(grid)}Magnetic dipole with polarity ' +
|
||||||
f'{m.polarisation} at {p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m,' +
|
f'{m.polarisation} at {p2[0]:g}m, {p2[1]:g}m, {p2[2]:g}m,' +
|
||||||
startstop + f'using waveform {m.waveformID} created.')
|
startstop + f'using waveform {m.waveformID} created.')
|
||||||
|
|
||||||
@@ -647,17 +623,15 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
waveform_id = self.kwargs['waveform_id']
|
waveform_id = self.kwargs['waveform_id']
|
||||||
resistance = self.kwargs['resistance']
|
resistance = self.kwargs['resistance']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at least six '
|
logger.exception(f'{self.params_str()} requires at least six parameters.')
|
||||||
'parameters.')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if self.do_rotate:
|
if self.do_rotate:
|
||||||
self._do_rotate(grid)
|
self._do_rotate(grid)
|
||||||
|
|
||||||
# Warn about using a transmission line on GPU
|
# Warn about using a transmission line on GPU
|
||||||
if (config.sim_config.general['solver'] == 'cuda' or
|
if (config.sim_config.general['solver'] in ['cuda', 'opencl']):
|
||||||
config.sim_config.general['solver'] == 'opencl'):
|
logger.exception(f'{self.params_str()} cannot currently be used ' +
|
||||||
logger.exception(self.params_str() + ' cannot currently be used ' +
|
|
||||||
'with the CUDA or OpenCL-based solver. Consider ' +
|
'with the CUDA or OpenCL-based solver. Consider ' +
|
||||||
'using a #voltage_source instead.')
|
'using a #voltage_source instead.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -667,18 +641,15 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
logger.exception(self.params_str() + (' polarisation must be '
|
logger.exception(self.params_str() + (' polarisation must be '
|
||||||
'x, y, or z.'))
|
'x, y, or z.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ('2D TMx' in config.get_model_config().mode and
|
if '2D TMx' in config.get_model_config().mode and polarisation in ['y','z',]:
|
||||||
(polarisation == 'y' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be x in '
|
logger.exception(self.params_str() + (' polarisation must be x in '
|
||||||
'2D TMx mode.'))
|
'2D TMx mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMy' in config.get_model_config().mode and
|
elif '2D TMy' in config.get_model_config().mode and polarisation in ['x','z',]:
|
||||||
(polarisation == 'x' or polarisation == 'z')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be y in '
|
logger.exception(self.params_str() + (' polarisation must be y in '
|
||||||
'2D TMy mode.'))
|
'2D TMy mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
elif ('2D TMz' in config.get_model_config().mode and
|
elif '2D TMz' in config.get_model_config().mode and polarisation in ['x','y',]:
|
||||||
(polarisation == 'x' or polarisation == 'y')):
|
|
||||||
logger.exception(self.params_str() + (' polarisation must be z in '
|
logger.exception(self.params_str() + (' polarisation must be z in '
|
||||||
'2D TMz mode.'))
|
'2D TMz mode.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -688,14 +659,14 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
|
|
||||||
|
|
||||||
if resistance <= 0 or resistance >= config.sim_config.em_consts['z0']:
|
if resistance <= 0 or resistance >= config.sim_config.em_consts['z0']:
|
||||||
logger.exception(self.params_str() + ' requires a resistance ' +
|
logger.exception(f'{self.params_str()} requires a resistance ' +
|
||||||
'greater than zero and less than the impedance ' +
|
'greater than zero and less than the impedance ' +
|
||||||
'of free space, i.e. 376.73 Ohms.')
|
'of free space, i.e. 376.73 Ohms.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Check if there is a waveformID in the waveforms list
|
# Check if there is a waveformID in the waveforms list
|
||||||
if not any(x.ID == waveform_id for x in grid.waveforms):
|
if not any(x.ID == waveform_id for x in grid.waveforms):
|
||||||
logger.exception(self.params_str() + ' there is no waveform ' +
|
logger.exception(f'{self.params_str()} there is no waveform ' +
|
||||||
f'with the identifier {waveform_id}.')
|
f'with the identifier {waveform_id}.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -729,11 +700,8 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
'less.'))
|
'less.'))
|
||||||
raise ValueError
|
raise ValueError
|
||||||
t.start = start
|
t.start = start
|
||||||
if stop > grid.timewindow:
|
t.stop = min(stop, grid.timewindow)
|
||||||
t.stop = grid.timewindow
|
startstop = (f' start time {t.start:g} secs, finish time ' +
|
||||||
else:
|
|
||||||
t.stop = stop
|
|
||||||
startstop = (f' start time {t.start:g} secs, finish time '
|
|
||||||
f'{t.stop:g} secs ')
|
f'{t.stop:g} secs ')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
t.start = 0
|
t.start = 0
|
||||||
@@ -743,7 +711,7 @@ class TransmissionLine(UserObjectMulti):
|
|||||||
t.calculate_waveform_values(grid)
|
t.calculate_waveform_values(grid)
|
||||||
t.calculate_incident_V_I(grid)
|
t.calculate_incident_V_I(grid)
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + f'Transmission line with polarity ' +
|
logger.info(f'{self.grid_name(grid)}Transmission line with polarity ' +
|
||||||
f'{t.polarisation} at {p2[0]:g}m, {p2[1]:g}m, ' +
|
f'{t.polarisation} at {p2[0]:g}m, {p2[1]:g}m, ' +
|
||||||
f'{p2[2]:g}m, resistance {t.resistance:.1f} Ohms,' +
|
f'{p2[2]:g}m, resistance {t.resistance:.1f} Ohms,' +
|
||||||
startstop + f'using waveform {t.waveformID} created.')
|
startstop + f'using waveform {t.waveformID} created.')
|
||||||
@@ -869,8 +837,7 @@ class RxArray(UserObjectMulti):
|
|||||||
p2 = self.kwargs['p2']
|
p2 = self.kwargs['p2']
|
||||||
dl = self.kwargs['dl']
|
dl = self.kwargs['dl']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires exactly 9 '
|
logger.exception(f'{self.params_str()} requires exactly 9 parameters')
|
||||||
'parameters')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
xs, ys, zs = uip.check_src_rx_point(p1, self.params_str(), 'lower')
|
xs, ys, zs = uip.check_src_rx_point(p1, self.params_str(), 'lower')
|
||||||
@@ -880,32 +847,32 @@ class RxArray(UserObjectMulti):
|
|||||||
dx, dy, dz = uip.discretise_point(dl)
|
dx, dy, dz = uip.discretise_point(dl)
|
||||||
|
|
||||||
if xs > xf or ys > yf or zs > zf:
|
if xs > xf or ys > yf or zs > zf:
|
||||||
logger.exception(self.params_str() + ' the lower coordinates '
|
logger.exception(f'{self.params_str()} the lower coordinates ' +
|
||||||
'should be less than the upper coordinates.')
|
'should be less than the upper coordinates.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 0 or dy < 0 or dz < 0:
|
if dx < 0 or dy < 0 or dz < 0:
|
||||||
logger.exception(self.params_str() + ' the step size should not '
|
logger.exception(f'{self.params_str()} the step size should not ' +
|
||||||
'be less than zero.')
|
'be less than zero.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 1:
|
if dx < 1:
|
||||||
if dx == 0:
|
if dx == 0:
|
||||||
dx = 1
|
dx = 1
|
||||||
else:
|
else:
|
||||||
logger.exception(self.params_str() + ' the step size should '
|
logger.exception(f'{self.params_str()} the step size should ' +
|
||||||
'not be less than the spatial discretisation.')
|
'not be less than the spatial discretisation.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dy < 1:
|
if dy < 1:
|
||||||
if dy == 0:
|
if dy == 0:
|
||||||
dy = 1
|
dy = 1
|
||||||
else:
|
else:
|
||||||
logger.exception(self.params_str() + ' the step size should '
|
logger.exception(f'{self.params_str()} the step size should ' +
|
||||||
'not be less than the spatial discretisation.')
|
'not be less than the spatial discretisation.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dz < 1:
|
if dz < 1:
|
||||||
if dz == 0:
|
if dz == 0:
|
||||||
dz = 1
|
dz = 1
|
||||||
else:
|
else:
|
||||||
logger.exception(self.params_str() + ' the step size should '
|
logger.exception(f'{self.params_str()} the step size should ' +
|
||||||
'not be less than the spatial discretisation.')
|
'not be less than the spatial discretisation.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -965,8 +932,7 @@ class Snapshot(UserObjectMulti):
|
|||||||
|
|
||||||
def create(self, grid, uip):
|
def create(self, grid, uip):
|
||||||
if isinstance(grid, SubGridBaseGrid):
|
if isinstance(grid, SubGridBaseGrid):
|
||||||
logger.exception(self.params_str() + ' do not add snapshots to '
|
logger.exception(f'{self.params_str()} do not add snapshots to subgrids.')
|
||||||
'subgrids.')
|
|
||||||
raise ValueError
|
raise ValueError
|
||||||
try:
|
try:
|
||||||
p1 = self.kwargs['p1']
|
p1 = self.kwargs['p1']
|
||||||
@@ -974,8 +940,7 @@ class Snapshot(UserObjectMulti):
|
|||||||
dl = self.kwargs['dl']
|
dl = self.kwargs['dl']
|
||||||
filename = self.kwargs['filename']
|
filename = self.kwargs['filename']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires exactly 11 '
|
logger.exception(f'{self.params_str()} requires exactly 11 parameters.')
|
||||||
'parameters.')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -998,13 +963,12 @@ class Snapshot(UserObjectMulti):
|
|||||||
try:
|
try:
|
||||||
time = self.kwargs['time']
|
time = self.kwargs['time']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires exactly 5 '
|
logger.exception(f'{self.params_str()} requires exactly 5 parameters.')
|
||||||
'parameters.')
|
|
||||||
raise
|
raise
|
||||||
if time > 0:
|
if time > 0:
|
||||||
iterations = round_value((time / grid.dt)) + 1
|
iterations = round_value((time / grid.dt)) + 1
|
||||||
else:
|
else:
|
||||||
logger.exception(self.params_str() + ' time value must be '
|
logger.exception(f'{self.params_str()} time value must be ' +
|
||||||
'greater than zero.')
|
'greater than zero.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -1036,11 +1000,11 @@ class Snapshot(UserObjectMulti):
|
|||||||
outputs = dict.fromkeys(SnapshotUser.allowableoutputs, True)
|
outputs = dict.fromkeys(SnapshotUser.allowableoutputs, True)
|
||||||
|
|
||||||
if dx < 0 or dy < 0 or dz < 0:
|
if dx < 0 or dy < 0 or dz < 0:
|
||||||
logger.exception(self.params_str() + ' the step size should not '
|
logger.exception(f'{self.params_str()} the step size should not ' +
|
||||||
'be less than zero.')
|
'be less than zero.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 1 or dy < 1 or dz < 1:
|
if dx < 1 or dy < 1 or dz < 1:
|
||||||
logger.exception(self.params_str() + ' the step size should not '
|
logger.exception(f'{self.params_str()} the step size should not ' +
|
||||||
'be less than the spatial discretisation.')
|
'be less than the spatial discretisation.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if iterations <= 0 or iterations > grid.iterations:
|
if iterations <= 0 or iterations > grid.iterations:
|
||||||
@@ -1085,32 +1049,31 @@ class Material(UserObjectMulti):
|
|||||||
sm = self.kwargs['sm']
|
sm = self.kwargs['sm']
|
||||||
material_id = self.kwargs['id']
|
material_id = self.kwargs['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(f'{self.params_str()} requires exactly five '
|
logger.exception(f'{self.params_str()} requires exactly five parameters.')
|
||||||
f'parameters.')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if er < 1:
|
if er < 1:
|
||||||
logger.exception(f'{self.params_str()} requires a positive value of '
|
logger.exception(f'{self.params_str()} requires a positive value of ' +
|
||||||
f'one or greater for static (DC) permittivity.')
|
f'one or greater for static (DC) permittivity.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if se != 'inf':
|
if se != 'inf':
|
||||||
se = float(se)
|
se = float(se)
|
||||||
if se < 0:
|
if se < 0:
|
||||||
logger.exception(f'{self.params_str()} requires a positive '
|
logger.exception(f'{self.params_str()} requires a positive ' +
|
||||||
f'value for electric conductivity.')
|
f'value for electric conductivity.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
else:
|
else:
|
||||||
se = float('inf')
|
se = float('inf')
|
||||||
if mr < 1:
|
if mr < 1:
|
||||||
logger.exception(f'{self.params_str()} requires a positive value of '
|
logger.exception(f'{self.params_str()} requires a positive value of ' +
|
||||||
f'one or greater for magnetic permeability.')
|
f'one or greater for magnetic permeability.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sm < 0:
|
if sm < 0:
|
||||||
logger.exception(f'{self.params_str()} requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
f'for magnetic loss.')
|
f'for magnetic loss.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if any(x.ID == material_id for x in grid.materials):
|
if any(x.ID == material_id for x in grid.materials):
|
||||||
logger.exception(f'{self.params_str()} with ID {material_id} '
|
logger.exception(f'{self.params_str()} with ID {material_id} ' +
|
||||||
f'already exists')
|
f'already exists')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -1159,12 +1122,11 @@ class AddDebyeDispersion(UserObjectMulti):
|
|||||||
tau = self.kwargs['tau']
|
tau = self.kwargs['tau']
|
||||||
material_ids = self.kwargs['material_ids']
|
material_ids = self.kwargs['material_ids']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at least four '
|
logger.exception(f'{self.params_str()} requires at least four parameters.')
|
||||||
'parameters.')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if poles < 0:
|
if poles < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for number of poles.')
|
'for number of poles.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -1192,7 +1154,7 @@ class AddDebyeDispersion(UserObjectMulti):
|
|||||||
disp_material.deltaer.append(er_delta[i])
|
disp_material.deltaer.append(er_delta[i])
|
||||||
disp_material.tau.append(tau[i])
|
disp_material.tau.append(tau[i])
|
||||||
else:
|
else:
|
||||||
logger.exception(self.params_str() + ' requires positive '
|
logger.exception(f'{self.params_str()} requires positive ' +
|
||||||
'values for the permittivity difference.')
|
'values for the permittivity difference.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if disp_material.poles > config.get_model_config().materials['maxpoles']:
|
if disp_material.poles > config.get_model_config().materials['maxpoles']:
|
||||||
@@ -1234,12 +1196,11 @@ class AddLorentzDispersion(UserObjectMulti):
|
|||||||
delta = self.kwargs['delta']
|
delta = self.kwargs['delta']
|
||||||
material_ids = self.kwargs['material_ids']
|
material_ids = self.kwargs['material_ids']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at least five '
|
logger.exception(f'{self.params_str()} requires at least five parameters.')
|
||||||
'parameters.')
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if poles < 0:
|
if poles < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for number of poles.')
|
'for number of poles.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -1266,7 +1227,7 @@ class AddLorentzDispersion(UserObjectMulti):
|
|||||||
disp_material.tau.append(omega[i])
|
disp_material.tau.append(omega[i])
|
||||||
disp_material.alpha.append(delta[i])
|
disp_material.alpha.append(delta[i])
|
||||||
else:
|
else:
|
||||||
logger.exception(self.params_str() + ' requires positive '
|
logger.exception(f'{self.params_str()} requires positive '
|
||||||
'values for the permittivity difference '
|
'values for the permittivity difference '
|
||||||
'and frequencies, and associated times '
|
'and frequencies, and associated times '
|
||||||
'that are greater than the time step for '
|
'that are greater than the time step for '
|
||||||
@@ -1279,9 +1240,9 @@ class AddLorentzDispersion(UserObjectMulti):
|
|||||||
grid.materials = [disp_material if mat.numID==material.numID else mat for mat in grid.materials]
|
grid.materials = [disp_material if mat.numID==material.numID else mat for mat in grid.materials]
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"{self.grid_name(grid)}Lorentz disperion added to {disp_material.ID} "
|
f"{self.grid_name(grid)}Lorentz disperion added to {disp_material.ID} " +
|
||||||
f"with delta_eps_r={', '.join('%4.2f' % deltaer for deltaer in disp_material.deltaer)}, "
|
f"with delta_eps_r={', '.join('%4.2f' % deltaer for deltaer in disp_material.deltaer)}, " +
|
||||||
f"omega={', '.join('%4.3e' % omega for omega in disp_material.tau)} secs, "
|
f"omega={', '.join('%4.3e' % omega for omega in disp_material.tau)} secs, " +
|
||||||
f"and gamma={', '.join('%4.3e' % delta for delta in disp_material.alpha)} created.")
|
f"and gamma={', '.join('%4.3e' % delta for delta in disp_material.alpha)} created.")
|
||||||
|
|
||||||
|
|
||||||
@@ -1309,12 +1270,12 @@ class AddDrudeDispersion(UserObjectMulti):
|
|||||||
alpha = self.kwargs['alpha']
|
alpha = self.kwargs['alpha']
|
||||||
material_ids = self.kwargs['material_ids']
|
material_ids = self.kwargs['material_ids']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at least four '
|
logger.exception(f'{self.params_str()} requires at least four ' +
|
||||||
'parameters.')
|
'parameters.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if poles < 0:
|
if poles < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for number of poles.')
|
'for number of poles.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
@@ -1340,9 +1301,9 @@ class AddDrudeDispersion(UserObjectMulti):
|
|||||||
disp_material.tau.append(omega[i])
|
disp_material.tau.append(omega[i])
|
||||||
disp_material.alpha.append(alpha[i])
|
disp_material.alpha.append(alpha[i])
|
||||||
else:
|
else:
|
||||||
logger.exception(self.params_str() + ' requires positive '
|
logger.exception(f'{self.params_str()} requires positive ' +
|
||||||
'values for the frequencies, and '
|
'values for the frequencies, and ' +
|
||||||
'associated times that are greater than '
|
'associated times that are greater than ' +
|
||||||
'the time step for the model.')
|
'the time step for the model.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if disp_material.poles > config.get_model_config().materials['maxpoles']:
|
if disp_material.poles > config.get_model_config().materials['maxpoles']:
|
||||||
@@ -1388,33 +1349,33 @@ class SoilPeplinski(UserObjectMulti):
|
|||||||
water_fraction_upper = self.kwargs['water_fraction_upper']
|
water_fraction_upper = self.kwargs['water_fraction_upper']
|
||||||
ID = self.kwargs['id']
|
ID = self.kwargs['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at exactly seven '
|
logger.exception(f'{self.params_str()} requires at exactly seven ' +
|
||||||
'parameters.')
|
'parameters.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if sand_fraction < 0:
|
if sand_fraction < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the sand fraction.')
|
'for the sand fraction.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if clay_fraction < 0:
|
if clay_fraction < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the clay fraction.')
|
'for the clay fraction.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if bulk_density < 0:
|
if bulk_density < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the bulk density.')
|
'for the bulk density.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sand_density < 0:
|
if sand_density < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the sand particle density.')
|
'for the sand particle density.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if water_fraction_lower < 0:
|
if water_fraction_lower < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the lower limit of the water volumetric '
|
'for the lower limit of the water volumetric '
|
||||||
'fraction.')
|
'fraction.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if water_fraction_upper < 0:
|
if water_fraction_upper < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the upper limit of the water volumetric '
|
'for the upper limit of the water volumetric '
|
||||||
'fraction.')
|
'fraction.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -1427,10 +1388,10 @@ class SoilPeplinski(UserObjectMulti):
|
|||||||
s = PeplinskiSoilUser(ID, sand_fraction, clay_fraction, bulk_density,
|
s = PeplinskiSoilUser(ID, sand_fraction, clay_fraction, bulk_density,
|
||||||
sand_density, (water_fraction_lower, water_fraction_upper))
|
sand_density, (water_fraction_lower, water_fraction_upper))
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + 'Mixing model (Peplinski) used to '
|
logger.info(f'{self.grid_name(grid)}Mixing model (Peplinski) used to ' +
|
||||||
f'create {s.ID} with sand fraction {s.S:g}, clay fraction '
|
f'create {s.ID} with sand fraction {s.S:g}, clay fraction ' +
|
||||||
f'{s.C:g}, bulk density {s.rb:g}g/cm3, sand particle '
|
f'{s.C:g}, bulk density {s.rb:g}g/cm3, sand particle ' +
|
||||||
f'density {s.rs:g}g/cm3, and water volumetric fraction '
|
f'density {s.rs:g}g/cm3, and water volumetric fraction ' +
|
||||||
f'{s.mu[0]:g} to {s.mu[1]:g} created.')
|
f'{s.mu[0]:g} to {s.mu[1]:g} created.')
|
||||||
|
|
||||||
grid.mixingmodels.append(s)
|
grid.mixingmodels.append(s)
|
||||||
@@ -1470,47 +1431,47 @@ class MaterialRange(UserObjectMulti):
|
|||||||
ro_upper = self.kwargs['ro_upper']
|
ro_upper = self.kwargs['ro_upper']
|
||||||
ID = self.kwargs['id']
|
ID = self.kwargs['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at exactly nine '
|
logger.exception(f'{self.params_str()} requires at exactly nine ' +
|
||||||
'parameters.')
|
'parameters.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if er_lower < 1:
|
if er_lower < 1:
|
||||||
logger.exception(self.params_str() + ' requires a value greater or equal to 1 '
|
logger.exception(f'{self.params_str()} requires a value greater or equal to 1 ' +
|
||||||
'for the lower range of relative permittivity.')
|
'for the lower range of relative permittivity.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if mr_lower < 1:
|
if mr_lower < 1:
|
||||||
logger.exception(self.params_str() + ' requires a value greater or equal to 1 '
|
logger.exception(f'{self.params_str()} requires a value greater or equal to 1 ' +
|
||||||
'for the lower range of relative magnetic permeability.')
|
'for the lower range of relative magnetic permeability.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if sigma_lower < 0:
|
if sigma_lower < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the lower limit of conductivity.')
|
'for the lower limit of conductivity.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ro_lower < 0:
|
if ro_lower < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the lower range magnetic loss.')
|
'for the lower range magnetic loss.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if er_upper < 1:
|
if er_upper < 1:
|
||||||
logger.exception(self.params_str() + ' requires a value greater or equal to 1'
|
logger.exception(f'{self.params_str()} requires a value greater or equal to 1' +
|
||||||
'for the upper range of relative permittivity.')
|
'for the upper range of relative permittivity.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
if mr_upper < 1:
|
if mr_upper < 1:
|
||||||
logger.exception(self.params_str() + ' requires a value greater or equal to 1'
|
logger.exception(f'{self.params_str()} requires a value greater or equal to 1' +
|
||||||
'for the upper range of relative magnetic permeability')
|
'for the upper range of relative magnetic permeability')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
if sigma_upper < 0:
|
if sigma_upper < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the upper range of conductivity.')
|
'for the upper range of conductivity.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ro_upper < 0:
|
if ro_upper < 0:
|
||||||
logger.exception(self.params_str() + ' requires a positive value '
|
logger.exception(f'{self.params_str()} requires a positive value ' +
|
||||||
'for the upper range of magnetic loss.')
|
'for the upper range of magnetic loss.')
|
||||||
|
|
||||||
|
|
||||||
if any(x.ID == ID for x in grid.mixingmodels):
|
if any(x.ID == ID for x in grid.mixingmodels):
|
||||||
logger.exception(self.params_str() + f' with ID {ID} already exists')
|
logger.exception(f'{self.params_str()} with ID {ID} already exists')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Create a new instance of the Material class material
|
# Create a new instance of the Material class material
|
||||||
@@ -1518,11 +1479,11 @@ class MaterialRange(UserObjectMulti):
|
|||||||
s = RangeMaterialUser(ID, (er_lower, er_upper), (sigma_lower, sigma_upper),
|
s = RangeMaterialUser(ID, (er_lower, er_upper), (sigma_lower, sigma_upper),
|
||||||
(mr_lower, mr_upper), (ro_lower, ro_upper))
|
(mr_lower, mr_upper), (ro_lower, ro_upper))
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + 'Material properties used to '
|
logger.info(f'{self.grid_name(grid)}Material properties used to ' +
|
||||||
f'create {s.ID} with range(s) {s.er[0]:g} to {s.er[1]:g}, relative permittivity '
|
f'create {s.ID} with range(s) {s.er[0]:g} to {s.er[1]:g}, relative permittivity ' +
|
||||||
f'{s.sig[0]:g} to {s.sig[1]:g}, S/m conductivity, {s.mu[0]:g} to {s.mu[1]:g} relative magnetic permeability '
|
f'{s.sig[0]:g} to {s.sig[1]:g}, S/m conductivity, {s.mu[0]:g} to {s.mu[1]:g} relative magnetic permeability ' +
|
||||||
f'{s.ro[0]:g} to {s.ro[1]:g} Ohm/m magnetic loss, created')
|
f'{s.ro[0]:g} to {s.ro[1]:g} Ohm/m magnetic loss, created')
|
||||||
|
|
||||||
|
|
||||||
grid.mixingmodels.append(s)
|
grid.mixingmodels.append(s)
|
||||||
|
|
||||||
@@ -1547,21 +1508,21 @@ class MaterialList(UserObjectMulti):
|
|||||||
list_of_materials = self.kwargs['list_of_materials']
|
list_of_materials = self.kwargs['list_of_materials']
|
||||||
ID = self.kwargs['id']
|
ID = self.kwargs['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires at at least 2 '
|
logger.exception(f'{self.params_str()} requires at at least 2 ' +
|
||||||
'parameters.')
|
'parameters.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if any(x.ID == ID for x in grid.mixingmodels):
|
if any(x.ID == ID for x in grid.mixingmodels):
|
||||||
logger.exception(self.params_str() + f' with ID {ID} already exists')
|
logger.exception(f'{self.params_str()} with ID {ID} already exists')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
# Create a new instance of the Material class material
|
# Create a new instance of the Material class material
|
||||||
# (start index after pec & free_space)
|
# (start index after pec & free_space)
|
||||||
s = ListMaterialUser(ID, list_of_materials)
|
s = ListMaterialUser(ID, list_of_materials)
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + 'A list of materials used to '
|
logger.info(f'{self.grid_name(grid)}A list of materials used to ' +
|
||||||
f'create {s.ID} that includes {s.mat}, created')
|
f'create {s.ID} that includes {s.mat}, created')
|
||||||
|
|
||||||
|
|
||||||
grid.mixingmodels.append(s)
|
grid.mixingmodels.append(s)
|
||||||
|
|
||||||
@@ -1608,7 +1569,7 @@ class GeometryView(UserObjectMulti):
|
|||||||
output_type = self.kwargs['output_type'].lower()
|
output_type = self.kwargs['output_type'].lower()
|
||||||
filename = self.kwargs['filename']
|
filename = self.kwargs['filename']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires exactly eleven '
|
logger.exception(f'{self.params_str()} requires exactly eleven ' +
|
||||||
'parameters.')
|
'parameters.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@@ -1627,36 +1588,36 @@ class GeometryView(UserObjectMulti):
|
|||||||
dx, dy, dz = uip.discretise_static_point(dl)
|
dx, dy, dz = uip.discretise_static_point(dl)
|
||||||
|
|
||||||
if dx < 0 or dy < 0 or dz < 0:
|
if dx < 0 or dy < 0 or dz < 0:
|
||||||
logger.exception(self.params_str() + ' the step size should not be '
|
logger.exception(f'{self.params_str()} the step size should not be ' +
|
||||||
'less than zero.')
|
'less than zero.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx > grid.nx or dy > grid.ny or dz > grid.nz:
|
if dx > grid.nx or dy > grid.ny or dz > grid.nz:
|
||||||
logger.exception(self.params_str() + ' the step size should be '
|
logger.exception(f'{self.params_str()} the step size should be ' +
|
||||||
'less than the domain size.')
|
'less than the domain size.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if dx < 1 or dy < 1 or dz < 1:
|
if dx < 1 or dy < 1 or dz < 1:
|
||||||
logger.exception(self.params_str() + ' the step size should not '
|
logger.exception(f'{self.params_str()} the step size should not ' +
|
||||||
'be less than the spatial discretisation.')
|
'be less than the spatial discretisation.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if output_type not in ['n', 'f']:
|
if output_type not in ['n', 'f']:
|
||||||
logger.exception(self.params_str() + ' requires type to be either '
|
logger.exception(f'{self.params_str()} requires type to be either ' +
|
||||||
'n (normal) or f (fine).')
|
'n (normal) or f (fine).')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if output_type == 'f' and (dx * grid.dx != grid.dx or
|
if output_type == 'f' and (dx * grid.dx != grid.dx or
|
||||||
dy * grid.dy != grid.dy or
|
dy * grid.dy != grid.dy or
|
||||||
dz * grid.dz != grid.dz):
|
dz * grid.dz != grid.dz):
|
||||||
logger.exception(self.params_str() + ' requires the spatial '
|
logger.exception(f'{self.params_str()} requires the spatial ' +
|
||||||
'discretisation for the geometry view to be the '
|
'discretisation for the geometry view to be the ' +
|
||||||
'same as the model for geometry view of '
|
'same as the model for geometry view of ' +
|
||||||
'type f (fine)')
|
'type f (fine)')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
g = GeometryViewUser(xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, grid)
|
g = GeometryViewUser(xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, grid)
|
||||||
|
|
||||||
logger.info(self.grid_name(grid) + f'Geometry view from {p3[0]:g}m, '
|
logger.info(f'{self.grid_name(grid)}Geometry view from {p3[0]:g}m, ' +
|
||||||
f'{p3[1]:g}m, {p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, '
|
f'{p3[1]:g}m, {p3[2]:g}m, to {p4[0]:g}m, {p4[1]:g}m, ' +
|
||||||
f'{p4[2]:g}m, discretisation {dx * grid.dx:g}m, '
|
f'{p4[2]:g}m, discretisation {dx * grid.dx:g}m, ' +
|
||||||
f'{dy * grid.dy:g}m, {dz * grid.dz:g}m, with filename '
|
f'{dy * grid.dy:g}m, {dz * grid.dz:g}m, with filename ' +
|
||||||
f'base {g.filename} created.')
|
f'base {g.filename} created.')
|
||||||
|
|
||||||
grid.geometryviews.append(g)
|
grid.geometryviews.append(g)
|
||||||
@@ -1686,7 +1647,7 @@ class GeometryObjectsWrite(UserObjectMulti):
|
|||||||
p2 = self.kwargs['p2']
|
p2 = self.kwargs['p2']
|
||||||
basefilename = self.kwargs['filename']
|
basefilename = self.kwargs['filename']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires exactly seven '
|
logger.exception(f'{self.params_str()} requires exactly seven ' +
|
||||||
'parameters.')
|
'parameters.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@@ -1750,30 +1711,30 @@ class PMLCFS(UserObjectMulti):
|
|||||||
sigmamin = self.kwargs['sigmamin']
|
sigmamin = self.kwargs['sigmamin']
|
||||||
sigmamax = self.kwargs['sigmamax']
|
sigmamax = self.kwargs['sigmamax']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.exception(self.params_str() + ' requires exactly twelve '
|
logger.exception(f'{self.params_str()} requires exactly twelve ' +
|
||||||
'parameters.')
|
'parameters.')
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if (alphascalingprofile not in CFSParameter.scalingprofiles.keys() or
|
if (alphascalingprofile not in CFSParameter.scalingprofiles.keys() or
|
||||||
kappascalingprofile not in CFSParameter.scalingprofiles.keys() or
|
kappascalingprofile not in CFSParameter.scalingprofiles.keys() or
|
||||||
sigmascalingprofile not in CFSParameter.scalingprofiles.keys()):
|
sigmascalingprofile not in CFSParameter.scalingprofiles.keys()):
|
||||||
logger.exception(self.params_str() + ' must have scaling type '
|
logger.exception(f'{self.params_str()} must have scaling type ' +
|
||||||
f"{','.join(CFSParameter.scalingprofiles.keys())}")
|
f"{','.join(CFSParameter.scalingprofiles.keys())}")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if (alphascalingdirection not in CFSParameter.scalingdirections or
|
if (alphascalingdirection not in CFSParameter.scalingdirections or
|
||||||
kappascalingdirection not in CFSParameter.scalingdirections or
|
kappascalingdirection not in CFSParameter.scalingdirections or
|
||||||
sigmascalingdirection not in CFSParameter.scalingdirections):
|
sigmascalingdirection not in CFSParameter.scalingdirections):
|
||||||
logger.exception(self.params_str() + ' must have scaling type '
|
logger.exception(f'{self.params_str()} must have scaling type ' +
|
||||||
f"{','.join(CFSParameter.scalingdirections)}")
|
f"{','.join(CFSParameter.scalingdirections)}")
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if (float(alphamin) < 0 or float(alphamax) < 0 or
|
if (float(alphamin) < 0 or float(alphamax) < 0 or
|
||||||
float(kappamin) < 0 or float(kappamax) < 0 or float(sigmamin) < 0):
|
float(kappamin) < 0 or float(kappamax) < 0 or float(sigmamin) < 0):
|
||||||
logger.exception(self.params_str() + ' minimum and maximum scaling '
|
logger.exception(f'{self.params_str()} minimum and maximum scaling ' +
|
||||||
'values must be greater than zero.')
|
'values must be greater than zero.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
# TODO: Fix handling of kappa for 2nd order PMLs
|
# TODO: Fix handling of kappa for 2nd order PMLs
|
||||||
# if float(kappamin) < 1:
|
# if float(kappamin) < 1:
|
||||||
# logger.exception(self.params_str() + ' minimum scaling value for '
|
# logger.exception(f'{self.params_str()} minimum scaling value for '
|
||||||
# 'kappa must be greater than or equal to one.')
|
# 'kappa must be greater than or equal to one.')
|
||||||
# raise ValueError
|
# raise ValueError
|
||||||
|
|
||||||
@@ -1813,7 +1774,7 @@ class PMLCFS(UserObjectMulti):
|
|||||||
grid.pmls['cfs'].append(cfs)
|
grid.pmls['cfs'].append(cfs)
|
||||||
|
|
||||||
if len(grid.pmls['cfs']) > 2:
|
if len(grid.pmls['cfs']) > 2:
|
||||||
logger.exception(self.params_str() + ' can only be used up to two '
|
logger.exception(f'{self.params_str()} can only be used up to two ' +
|
||||||
'times, for up to a 2nd order PML.')
|
'times, for up to a 2nd order PML.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
在新工单中引用
屏蔽一个用户