Refactor grid discretisation initialisation

这个提交包含在:
nmannall
2024-05-13 14:57:40 +01:00
父节点 94a089a870
当前提交 c750fc1109
共有 3 个文件被更改,包括 9 次插入3 次删除

查看文件

@@ -90,14 +90,14 @@ class Discretisation(UserObjectSingle):
super().__init__(**kwargs) super().__init__(**kwargs)
self.order = 2 self.order = 2
def build(self, G, uip): def build(self, model, uip):
try: try:
G.dl = np.array(self.kwargs["p1"]) model.set_grid_discretisation(self.kwargs["p1"])
G.dx, G.dy, G.dz = self.kwargs["p1"]
except KeyError: except KeyError:
logger.exception(f"{self.__str__()} discretisation requires a point") logger.exception(f"{self.__str__()} discretisation requires a point")
raise raise
G = model.G
if G.dl[0] <= 0: if G.dl[0] <= 0:
logger.exception( logger.exception(
f"{self.__str__()} discretisation requires the " f"{self.__str__()} discretisation requires the "

查看文件

@@ -59,6 +59,7 @@ class FDTDGrid:
self.dx = 0.0 self.dx = 0.0
self.dy = 0.0 self.dy = 0.0
self.dz = 0.0 self.dz = 0.0
self.dl: np.ndarray
self.dt = 0.0 self.dt = 0.0
self.dt_mod = None # Time step stability factor self.dt_mod = None # Time step stability factor
self.iteration = 0 # Current iteration number self.iteration = 0 # Current iteration number

查看文件

@@ -20,6 +20,7 @@ import datetime
import itertools import itertools
import logging import logging
import sys import sys
from typing import Tuple
import humanize import humanize
import numpy as np import numpy as np
@@ -160,6 +161,10 @@ class Model:
if grid.snapshots: if grid.snapshots:
save_snapshots(grid) save_snapshots(grid)
def set_grid_discretisation(self, point: Tuple[float, float, float]):
self.G.dl = np.array(point)
self.G.dx, self.G.dy, self.G.dz = point
def solve(self, solver): def solve(self, solver):
"""Solve using FDTD method. """Solve using FDTD method.