Merge remote-tracking branch 'drake/feature/estimate-cfl-timestep'
This commit is contained in:
commit
c651cce61f
@ -10,6 +10,7 @@ import numpy as np
|
|||||||
|
|
||||||
from CSXCAD import CSPrimitives
|
from CSXCAD import CSPrimitives
|
||||||
from CSXCAD.Utilities import CheckNyDir, GetMultiDirs
|
from CSXCAD.Utilities import CheckNyDir, GetMultiDirs
|
||||||
|
from openEMS.physical_constants import C0
|
||||||
|
|
||||||
def mesh_combine(mesh1, mesh2, sort=True):
|
def mesh_combine(mesh1, mesh2, sort=True):
|
||||||
mesh = [None, None, None]
|
mesh = [None, None, None]
|
||||||
@ -96,3 +97,19 @@ def mesh_hint_from_box(box, dirs, **kw):
|
|||||||
return mesh_combine(hint, kw['mesh'])
|
return mesh_combine(hint, kw['mesh'])
|
||||||
return hint
|
return hint
|
||||||
|
|
||||||
|
def mesh_estimate_cfl_timestep(mesh):
|
||||||
|
""" mesh_estimate_cfl_timestep(mesh)
|
||||||
|
|
||||||
|
Estimate the maximum CFL time step of the given mesh needed to ensure numerical stability,
|
||||||
|
assuming propagation in pure vacuum.
|
||||||
|
|
||||||
|
:returns: the maximum CFL time step, in seconds
|
||||||
|
"""
|
||||||
|
invMinDiff = [None, None, None]
|
||||||
|
for ny in range(3):
|
||||||
|
invMinDiff[ny] = np.min(np.diff(mesh.GetLines(ny))) ** -2
|
||||||
|
|
||||||
|
delta_t = mesh.GetDeltaUnit() / (C0 * np.sqrt(np.sum(invMinDiff)))
|
||||||
|
|
||||||
|
return delta_t
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user