diff --git a/src/base/model/algebra.py b/src/base/model/algebra.py index 792d24a..bfed2f9 100644 --- a/src/base/model/algebra.py +++ b/src/base/model/algebra.py @@ -81,8 +81,8 @@ def load(path: Path) -> Real: if path.exists(): value = path.read_text(encoding='utf-8').strip() return Real(float(value)) - else: - logging.error(f'{path} does not exist') + logging.error(f'{path} does not exist') + raise FileNotFoundError class Integer: @@ -103,5 +103,5 @@ def load(path: Path) -> Integer: if path.exists(): value = path.read_text(encoding='utf-8').strip() return Integer(int(value)) - else: - logging.error(f'{path} does not exist') + logging.error(f'{path} does not exist') + raise FileNotFoundError diff --git a/src/base/model/mesh.py b/src/base/model/mesh.py index 9df70a1..31936a4 100644 --- a/src/base/model/mesh.py +++ b/src/base/model/mesh.py @@ -25,7 +25,7 @@ def arrange(start: float, stop: float, step: float, center=False) -> list[float] start = start + step / 2 stop = stop - step / 2 - if not step > 0: + if step <= 0: return [] r = [] @@ -50,6 +50,7 @@ def __init__(self, x: float | Real, y: float | Real) -> None: self.__y = Real(float(y)) def __eq__(self, coordinate: tuple[float, float] | Coordinate) -> bool: + # pylint: disable=protected-access c = Coordinate(*coordinate) return self.__x == c.__x and self.__y == c.__y @@ -66,6 +67,7 @@ def __str__(self) -> str: return self.__repr__() def __add__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate: + # pylint: disable=protected-access c = Coordinate(*coordinate) return Coordinate(self.__x + c.__x, self.__y + c.__y) @@ -73,10 +75,12 @@ def __radd__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate: return self.__add__(coordinate) def __sub__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate: + # pylint: disable=protected-access c = Coordinate(*coordinate) return Coordinate(self.__x - c.__x, self.__y - c.__y) def __rsub__(self, coordinate: tuple[float, float] | Coordinate) -> Coordinate: + # pylint: disable=protected-access c = Coordinate(*coordinate) return Coordinate(c.__x - self.__x, c.__y - self.__y) @@ -92,6 +96,7 @@ def __truediv__(self, factor: float) -> Coordinate: return Coordinate(self.__x / factor, self.__y / factor) def distance(self, coordinate: tuple[float, float] | Coordinate) -> float: + # pylint: disable=protected-access c = Coordinate(*coordinate) return np.sqrt(float(self.__x - c.__x)**2 + float(self.__y - c.__y)**2) diff --git a/src/nse/__main__.py b/src/nse/__main__.py index 6545459..8c07473 100644 --- a/src/nse/__main__.py +++ b/src/nse/__main__.py @@ -67,9 +67,8 @@ def main( logging.info(model) logging.info(f'PARAMETERS: {len(model)}') - if grade: - logging.info('PLOT: Setup') - plot_setup(experiment, identifier) + logging.info('PLOT: Setup') + plot_setup(experiment, identifier) timer = Stopwatch() if n > 0: diff --git a/src/nse/model/experiments/block.py b/src/nse/model/experiments/block.py index 5e561e4..65ef54f 100644 --- a/src/nse/model/experiments/block.py +++ b/src/nse/model/experiments/block.py @@ -43,7 +43,6 @@ def __init__( foam, ) - step = .1 stride = step / 2 # inlet diff --git a/src/nse/model/experiments/empty.py b/src/nse/model/experiments/empty.py index a353f35..6235c50 100644 --- a/src/nse/model/experiments/empty.py +++ b/src/nse/model/experiments/empty.py @@ -43,7 +43,6 @@ def __init__( foam, ) - step = step stride = step / 2 # inlet diff --git a/src/nse/model/experiments/foam.py b/src/nse/model/experiments/foam.py index e00b097..f3249e9 100644 --- a/src/nse/model/experiments/foam.py +++ b/src/nse/model/experiments/foam.py @@ -135,24 +135,25 @@ def __dir(path: Path) -> int | None: def main(): step = .1 nu = 0.01 - inlet = 1 - - name = f'step-{step:.3f}-{nu:.3f}-{inlet:.3f}'.replace('.', '_') + flow = 1 m = Grid(Axis('x', 0, 10).arrange(step, True), Axis('y', 0, 2).arrange(step, True)) f = Foam( - name, - m, + m.x, + m.y, step, Figure(Line((0, 0), (10, 0)), Line((0, 2), (10, 2))), Figure(Rectangle((0, 0), (1, 1))), + nu, + 1, + flow, ) d = m.transform(f.knowledge) f.knowledge.save(OUTPUT_DIR / 'foam' / 'foam_uvp.csv') plot_seismic( - name, + f.name, m.x, m.y, [ @@ -166,7 +167,7 @@ def main(): ) plot_stream( - 'OpenFOAM Streamlines', + f.name, m.x, m.y, d.u, @@ -177,7 +178,7 @@ def main(): ) plot_arrows( - 'OpenFOAM Arrows', + f.name, m.x, m.y, d.u, diff --git a/src/nse/model/experiments/slalom.py b/src/nse/model/experiments/slalom.py index 44587f6..6fcf031 100644 --- a/src/nse/model/experiments/slalom.py +++ b/src/nse/model/experiments/slalom.py @@ -43,7 +43,6 @@ def __init__( foam, ) - step = .1 stride = step / 2 # inlet diff --git a/src/nse/model/experiments/slit.py b/src/nse/model/experiments/slit.py index d103e27..7e53bb9 100644 --- a/src/nse/model/experiments/slit.py +++ b/src/nse/model/experiments/slit.py @@ -43,7 +43,6 @@ def __init__( foam, ) - step = .1 stride = step / 2 # inlet diff --git a/src/nse/model/experiments/step.py b/src/nse/model/experiments/step.py index 2dcceae..5c3c24f 100644 --- a/src/nse/model/experiments/step.py +++ b/src/nse/model/experiments/step.py @@ -44,7 +44,6 @@ def __init__( supervised, ) - step = .1 stride = step / 2 # inlet diff --git a/src/nse/model/loss.py b/src/nse/model/loss.py index 7403e36..5efcd66 100644 --- a/src/nse/model/loss.py +++ b/src/nse/model/loss.py @@ -71,11 +71,12 @@ def __iter__(self) -> tp.Iterator[Loss]: @staticmethod def load(path: Path) -> Losses: + # pylint: disable=protected-access if path.exists(): loss = Losses() lines = path.read_text(encoding='utf-8').strip().splitlines() for line in lines: loss.__losses.append(Loss(*line.strip().split(','))) return loss - else: - logging.error(f'{path} does not exist') + logging.error(f'{path} does not exist') + raise FileNotFoundError diff --git a/src/nse/model/record.py b/src/nse/model/record.py index 6c09395..d66fa15 100644 --- a/src/nse/model/record.py +++ b/src/nse/model/record.py @@ -55,5 +55,5 @@ def load(path: Path) -> Record: if path.exists(): u, v, p = path.read_text(encoding='utf-8').strip().split(',') return Record(float(u), float(v), float(p)) - else: - logging.error(f'{path} does not exist') + logging.error(f'{path} does not exist') + raise FileNotFoundError