Removed unnecessary if conditions at some places, and used itertools.product to make code more readable/cleaner.

这个提交包含在:
Sai-Suraj-27
2023-06-23 19:35:54 +05:30
父节点 e9416e34c8
当前提交 c0762cc112
共有 4 个文件被更改,包括 41 次插入48 次删除

查看文件

@@ -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,8 +140,7 @@ 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):
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.')

查看文件

@@ -3,9 +3,11 @@
receiver at the centre.
"""
from pathlib import Path
import gprMax
import itertools
# File path for output
fn = Path(__file__)
@@ -17,12 +19,10 @@ 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