Skip to content

Commit

Permalink
absorbing boundaries lpse (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
joglekara authored Nov 27, 2023
1 parent 02e112f commit 3972254
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 4 deletions.
1 change: 0 additions & 1 deletion adept/lpse2d/core/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def __init__(self, cfg):
def __call__(self, this_pulse: Dict, current_time: jnp.float64):
kk = this_pulse["k0"]
ww = this_pulse["w0"]
# dw = 0.this_pulse["dw0"]
t_L = this_pulse["t_c"] - this_pulse["t_w"] * 0.5
t_R = this_pulse["t_c"] + this_pulse["t_w"] * 0.5
t_wL = this_pulse["t_r"]
Expand Down
8 changes: 8 additions & 0 deletions adept/lpse2d/core/epw.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,12 @@ def __call__(self, t, y, args):
)
y["phi"] = self.get_phi_from_eh(eh)

if (
self.cfg["terms"]["epw"]["boundary"]["x"] == "absorbing"
or self.cfg["terms"]["epw"]["boundary"]["y"] == "absorbing"
):
y["phi"] = self.get_phi_from_eh(
self.get_eh_x(y["phi"]) * self.cfg["grid"]["absorbing_boundaries"][..., None]
)

return y
14 changes: 13 additions & 1 deletion adept/lpse2d/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from diffrax import ODETerm
import xarray as xr

from adept.lpse2d.core import integrator
from adept.lpse2d.core import integrator, driver


def get_derived_quantities(cfg_grid: Dict) -> Dict:
Expand Down Expand Up @@ -102,6 +102,18 @@ def get_solver_quantities(cfg: Dict) -> Dict:
one_over_ksq[0, 0] = 0.0
cfg_grid["one_over_ksq"] = jnp.array(one_over_ksq)

if cfg["terms"]["epw"]["boundary"]["x"] == "absorbing":
envelope_x = driver.get_envelope(50.0, 50.0, 300.0, cfg["grid"]["xmax"] - 300.0, cfg_grid["x"])[:, None]
else:
envelope_x = np.ones((cfg_grid["nx"], cfg_grid["ny"]))

if cfg["terms"]["epw"]["boundary"]["y"] == "absorbing":
envelope_y = driver.get_envelope(50.0, 50.0, 300.0, cfg["grid"]["ymax"] - 300.0, cfg_grid["y"])[None, :]
else:
envelope_y = np.ones((cfg_grid["nx"], cfg_grid["ny"]))

cfg_grid["absorbing_boundaries"] = np.exp(-cfg_grid["dt"] * (1.0 - envelope_x * envelope_y))

return cfg_grid


Expand Down
3 changes: 3 additions & 0 deletions configs/envelope-2d/damping.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ terms:
linear: True
density_gradient: False
kinetic real part: False
boundary:
x: absorbing
y: periodic
trapping:
active: True
kld: 0.3
Expand Down
3 changes: 3 additions & 0 deletions configs/envelope-2d/epw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ terms:
linear: True
density_gradient: False
kinetic real part: True
boundary:
x: absorbing
y: periodic
trapping:
active: False
kld: 0.1
Expand Down
7 changes: 5 additions & 2 deletions configs/envelope-2d/reflection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ drivers:
a0: 0.0
intensity: 4.0e14
E2:
w0: 0.0864
w0: 0.03375
t_c: 230.
t_w: 400.
t_r: 5.
Expand All @@ -26,7 +26,7 @@ drivers:
y_c: 0.
y_w: 2000000.
y_r: 5.
k0: 0.24
k0: 0.15
a0: 100.0
intensity: 4.0e14

Expand Down Expand Up @@ -81,6 +81,9 @@ terms:
linear: True
density_gradient: True
kinetic real part: False
boundary:
x: absorbing
y: periodic
trapping:
active: False
kld: 0.28
Expand Down
3 changes: 3 additions & 0 deletions configs/envelope-2d/tpd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,8 @@ terms:
epw:
linear: True
density_gradient: False
boundary:
x: absorbing
y: periodic
tpd:
source: False
3 changes: 3 additions & 0 deletions tests/test_lpse2d/configs/epw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ terms:
linear: True
density_gradient: False
kinetic real part: True
boundary:
x: periodic
y: periodic
trapping:
active: False
kld: 0.1
Expand Down
3 changes: 3 additions & 0 deletions tests/test_lpse2d/configs/resonance_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ terms:
linear: True
density_gradient: False
kinetic real part: True
boundary:
x: periodic
y: periodic
trapping:
kld: 0.3
active: False
Expand Down

0 comments on commit 3972254

Please sign in to comment.