你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Removed unnecessary if conditions at some places, and used itertools.product to make code more readable/cleaner.
这个提交包含在:
@@ -111,7 +111,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
if ys == yf or zs == zf:
|
if ys == yf or zs == zf:
|
||||||
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if xs != volume.xs and xs != volume.xf:
|
if xs not in [volume.xs and volume.xf]:
|
||||||
logger.exception(f'{self.__str__()} must specify external surfaces on a fractal box')
|
logger.exception(f'{self.__str__()} must specify external surfaces on a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
fractalrange = (round_value(limits[0] / grid.dx), round_value(limits[1] / grid.dx))
|
fractalrange = (round_value(limits[0] / grid.dx), round_value(limits[1] / grid.dx))
|
||||||
@@ -130,10 +130,10 @@ class AddGrass(UserObjectGeometry):
|
|||||||
requestedsurface = 'xplus'
|
requestedsurface = 'xplus'
|
||||||
|
|
||||||
elif ys == yf:
|
elif ys == yf:
|
||||||
if xs == xf or zs == zf:
|
if zs == zf:
|
||||||
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ys != volume.ys and ys != volume.yf:
|
if ys not in [volume.ys and volume.yf]:
|
||||||
logger.exception(f'{self.__str__()} must specify external surfaces on a fractal box')
|
logger.exception(f'{self.__str__()} must specify external surfaces on a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
fractalrange = (round_value(limits[0] / grid.dy), round_value(limits[1] / grid.dy))
|
fractalrange = (round_value(limits[0] / grid.dy), round_value(limits[1] / grid.dy))
|
||||||
@@ -152,10 +152,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
requestedsurface = 'yplus'
|
requestedsurface = 'yplus'
|
||||||
|
|
||||||
elif zs == zf:
|
elif zs == zf:
|
||||||
if xs == xf or ys == yf:
|
if zs not in [volume.zs and volume.zf]:
|
||||||
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
|
||||||
raise ValueError
|
|
||||||
if zs != volume.zs and zs != volume.zf:
|
|
||||||
logger.exception(f'{self.__str__()} must specify external surfaces on a fractal box')
|
logger.exception(f'{self.__str__()} must specify external surfaces on a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
fractalrange = (round_value(limits[0] / grid.dz), round_value(limits[1] / grid.dz))
|
fractalrange = (round_value(limits[0] / grid.dz), round_value(limits[1] / grid.dz))
|
||||||
@@ -227,7 +224,7 @@ class AddGrass(UserObjectGeometry):
|
|||||||
surface.grass.append(g)
|
surface.grass.append(g)
|
||||||
|
|
||||||
# Check to see if grass has been already defined as a material
|
# Check to see if grass has been already defined as a material
|
||||||
if not any(x.ID == 'grass' for x in grid.materials):
|
if all(x.ID == 'grass' for x in grid.materials):
|
||||||
create_grass(grid)
|
create_grass(grid)
|
||||||
|
|
||||||
# Check if time step for model is suitable for using grass
|
# Check if time step for model is suitable for using grass
|
||||||
|
@@ -118,7 +118,7 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
if ys == yf or zs == zf:
|
if ys == yf or zs == zf:
|
||||||
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if xs != volume.xs and xs != volume.xf:
|
if xs not in [volume.xs, volume.xf]:
|
||||||
logger.exception(f'{self.__str__()} can only be used on the external ' +
|
logger.exception(f'{self.__str__()} can only be used on the external ' +
|
||||||
'surfaces of a fractal box')
|
'surfaces of a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -144,10 +144,10 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
requestedsurface = 'xplus'
|
requestedsurface = 'xplus'
|
||||||
|
|
||||||
elif ys == yf:
|
elif ys == yf:
|
||||||
if xs == xf or zs == zf:
|
if zs == zf:
|
||||||
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if ys != volume.ys and ys != volume.yf:
|
if ys not in [volume.ys and volume.yf]:
|
||||||
logger.exception(f'{self.__str__()} can only be used on the external ' +
|
logger.exception(f'{self.__str__()} can only be used on the external ' +
|
||||||
'surfaces of a fractal box')
|
'surfaces of a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -173,10 +173,7 @@ class AddSurfaceRoughness(UserObjectGeometry):
|
|||||||
requestedsurface = 'yplus'
|
requestedsurface = 'yplus'
|
||||||
|
|
||||||
elif zs == zf:
|
elif zs == zf:
|
||||||
if xs == xf or ys == yf:
|
if zs not in [volume.zs and volume.zf]:
|
||||||
logger.exception(f'{self.__str__()} dimensions are not specified correctly')
|
|
||||||
raise ValueError
|
|
||||||
if zs != volume.zs and zs != volume.zf:
|
|
||||||
logger.exception(f'{self.__str__()} can only be used on the external ' +
|
logger.exception(f'{self.__str__()} can only be used on the external ' +
|
||||||
'surfaces of a fractal box')
|
'surfaces of a fractal box')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
@@ -140,12 +140,11 @@ class FractalBox(UserObjectGeometry):
|
|||||||
logger.exception(f'{self.__str__()} must be used with more than ' +
|
logger.exception(f'{self.__str__()} must be used with more than ' +
|
||||||
'one material from the mixing model.')
|
'one material from the mixing model.')
|
||||||
raise ValueError
|
raise ValueError
|
||||||
if isinstance(mixingmodel, ListMaterial):
|
if isinstance(mixingmodel, ListMaterial) and nbins > len(mixingmodel.mat):
|
||||||
if nbins > len(mixingmodel.mat):
|
logger.exception(f'{self.__str__()} too many materials/bins ' +
|
||||||
logger.exception(f'{self.__str__()} too many materials/bins ' +
|
'requested compared to materials in ' +
|
||||||
'requested compared to materials in ' +
|
'mixing model.')
|
||||||
'mixing model.')
|
raise ValueError
|
||||||
raise ValueError
|
|
||||||
# Create materials from mixing model as number of bins now known
|
# Create materials from mixing model as number of bins now known
|
||||||
# from fractal_box command.
|
# from fractal_box command.
|
||||||
mixingmodel.calculate_properties(nbins, grid)
|
mixingmodel.calculate_properties(nbins, grid)
|
||||||
|
@@ -3,9 +3,11 @@
|
|||||||
receiver at the centre.
|
receiver at the centre.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import gprMax
|
import gprMax
|
||||||
|
|
||||||
|
import itertools
|
||||||
# File path for output
|
# File path for output
|
||||||
fn = Path(__file__)
|
fn = Path(__file__)
|
||||||
|
|
||||||
@@ -17,38 +19,36 @@ ompthreads = [1, 2, 4, 8, 16, 32, 64, 128]
|
|||||||
|
|
||||||
scenes = []
|
scenes = []
|
||||||
|
|
||||||
for d in domains:
|
# Discretisation
|
||||||
for threads in ompthreads:
|
dl = 0.001
|
||||||
|
|
||||||
# Discretisation
|
for d, threads in itertools.product(domains, ompthreads):
|
||||||
dl = 0.001
|
# Domain
|
||||||
|
x = d
|
||||||
|
y = x
|
||||||
|
z = x
|
||||||
|
|
||||||
# Domain
|
scene = gprMax.Scene()
|
||||||
x = d
|
|
||||||
y = x
|
|
||||||
z = x
|
|
||||||
|
|
||||||
scene = gprMax.Scene()
|
title = gprMax.Title(name=fn.with_suffix('').name)
|
||||||
|
domain = gprMax.Domain(p1=(x, y, z))
|
||||||
|
dxdydz = gprMax.Discretisation(p1=(dl, dl, dl))
|
||||||
|
time_window = gprMax.TimeWindow(time=3e-9)
|
||||||
|
wv = gprMax.Waveform(wave_type='gaussiandotnorm', amp=1, freq=900e6,
|
||||||
|
id='MySource')
|
||||||
|
src = gprMax.HertzianDipole(p1=(x/2, y/2, z/2), polarisation='x',
|
||||||
|
waveform_id='MySource')
|
||||||
|
|
||||||
title = gprMax.Title(name=fn.with_suffix('').name)
|
omp = gprMax.OMPThreads(n=threads)
|
||||||
domain = gprMax.Domain(p1=(x, y, z))
|
|
||||||
dxdydz = gprMax.Discretisation(p1=(dl, dl, dl))
|
|
||||||
time_window = gprMax.TimeWindow(time=3e-9)
|
|
||||||
wv = gprMax.Waveform(wave_type='gaussiandotnorm', amp=1, freq=900e6,
|
|
||||||
id='MySource')
|
|
||||||
src = gprMax.HertzianDipole(p1=(x/2, y/2, z/2), polarisation='x',
|
|
||||||
waveform_id='MySource')
|
|
||||||
|
|
||||||
omp = gprMax.OMPThreads(n=threads)
|
scene.add(title)
|
||||||
|
scene.add(domain)
|
||||||
scene.add(title)
|
scene.add(dxdydz)
|
||||||
scene.add(domain)
|
scene.add(time_window)
|
||||||
scene.add(dxdydz)
|
scene.add(wv)
|
||||||
scene.add(time_window)
|
scene.add(src)
|
||||||
scene.add(wv)
|
scene.add(omp)
|
||||||
scene.add(src)
|
scenes.append(scene)
|
||||||
scene.add(omp)
|
|
||||||
scenes.append(scene)
|
|
||||||
|
|
||||||
# Run model
|
# Run model
|
||||||
gprMax.run(scenes=scenes, n=len(scenes), geometry_only=False, outputfile=fn, gpu=None)
|
gprMax.run(scenes=scenes, n=len(scenes), geometry_only=False, outputfile=fn, gpu=None)
|
在新工单中引用
屏蔽一个用户