Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close #1688 : Transform the moving window velocity to its boosted-frame value. #1700

Merged
merged 2 commits into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Examples/Tests/moving_window_boost/inputs_3d
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#################################
####### GENERAL PARAMETERS ######
#################################
max_step = 1000
amr.n_cell = 16 16 128
amr.max_grid_size = 32
amr.blocking_factor = 16
amr.max_level = 0
geometry.coord_sys = 0 # 0: Cartesian
geometry.is_periodic = 0 0 0 # Is periodic?
geometry.prob_lo = -1.e-5 -1.e-5 -1.e-6
geometry.prob_hi = 1.e-5 1.e-5 0

#################################
############ NUMERICS ###########
#################################
algo.maxwell_solver = ckc
warpx.verbose = 1
warpx.do_dive_cleaning = 0
warpx.use_filter = 1
warpx.do_pml = 1
warpx.cfl = 0.99
warpx.do_moving_window = 1
warpx.moving_window_dir = z
warpx.moving_window_v = 0.95 # in units of the speed of light
my_constants.lramp = 8.e-3
my_constants.pi = 3.141592653589793
interpolation.nox = 3
interpolation.noy = 3
interpolation.noz = 3

#################################
######### BOOSTED FRAME #########
#################################
warpx.gamma_boost = 10.0
warpx.boost_direction = z
warpx.do_back_transformed_diagnostics = 0
#warpx.num_snapshots_lab = 10
#warpx.dt_snapshots_lab = 1.e-10

# Diagnostics
diagnostics.diags_names = diag
diag.intervals = 1000
diag.diag_type = Full
diag.fields_to_plot = Ex


22 changes: 22 additions & 0 deletions Examples/Tests/moving_window_boost/moving_window_v_boost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import yt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add a few lines of comments here, in order to explain what the tests does, and what it is checking at the end of the simulation?


dlist0 = os.listdir('./diags')
dlist = sorted(dlist0)

kk = 0
fn = './diags/'+dlist[kk]
print(fn)
ds=yt.load(fn)
t1=ds.current_time.v[()]
z1max=ds.domain_right_edge.v[2]

kk = 1
fn = './diags/'+dlist[kk]
print(fn)
ds=yt.load(fn)
t2=ds.current_time.v[()]
z2max=ds.domain_right_edge.v[2]

vv=(z2max-z1max)/(t2-t1)/299792458.
print('moving_window_v in boosted frame =', vv)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could write an additional line here, comparing the value in vv with an expected value (within an epsilon range) and returning a non-zero exit code with sys.exit(1) in case the value does not match.

That way, we can verify the test without manual intervention.

2 changes: 1 addition & 1 deletion Source/Utils/WarpXMovingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ WarpX::MoveWindow (bool move_j)

// Update the continuous position of the moving window,
// and of the plasma injection
moving_window_x += moving_window_v * dt[0];
moving_window_x += (moving_window_v - WarpX::beta_boost * PhysConst::c)/(1 - moving_window_v * WarpX::beta_boost / PhysConst::c) * dt[0];
int dir = moving_window_dir;

// Update warpx.current_injection_position
Expand Down