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