fdfd_tools/meanas/fdtd/base.py

38 lines
871 B
Python
Raw Normal View History

2019-08-04 13:48:41 -07:00
"""
Basic FDTD field updates
"""
from typing import List, Callable, Tuple, Dict
import numpy
2019-11-27 22:59:52 -08:00
from ..fdmath import dx_lists_t, fdfield_t, fdfield_updater_t
from ..fdmath.functional import curl_forward, curl_back
2019-08-04 13:48:41 -07:00
__author__ = 'Jan Petykiewicz'
2019-08-04 13:48:41 -07:00
2019-11-27 22:59:52 -08:00
def maxwell_e(dt: float, dxes: dx_lists_t = None) -> fdfield_updater_t:
if dxes is not None:
curl_h_fun = curl_back(dxes[1])
else:
curl_h_fun = curl_back()
2019-08-04 13:48:41 -07:00
2019-11-27 22:59:52 -08:00
def me_fun(e: fdfield_t, h: fdfield_t, epsilon: fdfield_t):
2019-08-04 13:48:41 -07:00
e += dt * curl_h_fun(h) / epsilon
return e
return me_fun
2019-11-27 22:59:52 -08:00
def maxwell_h(dt: float, dxes: dx_lists_t = None) -> fdfield_updater_t:
if dxes is not None:
curl_e_fun = curl_forward(dxes[0])
else:
curl_e_fun = curl_forward()
2019-08-04 13:48:41 -07:00
2019-11-27 22:59:52 -08:00
def mh_fun(e: fdfield_t, h: fdfield_t):
2019-08-04 13:48:41 -07:00
h -= dt * curl_e_fun(e)
return h
return mh_fun