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

General moving-window transformations in boosted-frame simulations #5226

Merged
merged 6 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ max_step = 50
amr.n_cell = 16 16 8
amr.max_level = 0
geometry.dims = 3
geometry.prob_lo = -0.2 -0.2 -0.1
geometry.prob_hi = +0.2 +0.2 +0.1
geometry.prob_lo = -0.2 -0.2 -0.1866
geometry.prob_hi = +0.2 +0.2 +0.1866

# Boundary condition
boundary.field_lo = pec pec pec
Expand Down
4 changes: 2 additions & 2 deletions Examples/Tests/plasma_lens/inputs_test_3d_plasma_lens_boosted
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ amr.max_level = 0

# Geometry
geometry.dims = 3
geometry.prob_lo = -1.0 -1.0 -1.0 # physical domain
geometry.prob_hi = 1.0 1.0 2.0
geometry.prob_lo = -1.0 -1.0 -1.866 # physical domain
geometry.prob_hi = 1.0 1.0 3.732

boundary.field_lo = pec pec pec
boundary.field_hi = pec pec pec
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"lev=0": {
"Bx": 3.254604354043409e-14,
"By": 3.2768679907552955e-14,
"Bz": 1.0615351421410278e-16,
"Ex": 2.3084916770539354e-05,
"Ey": 2.2657235922655432e-05,
"Ez": 1.9978004351148e-05,
"jx": 1.781971994166362e-10,
"jy": 4.2163624424546344e-20,
"jz": 1.0378980680353126e-07
},
"electron": {
"particle_momentum_x": 5.955475926588059e-26,
"particle_momentum_y": 1.4612764777454504e-35,
"particle_momentum_z": 3.4687284535374423e-23,
"particle_position_x": 0.049960237123814574,
"particle_position_y": 8.397636119991403e-15,
"particle_position_z": 0.10931687737912647,
"particle_momentum_x": 5.955475927655105e-26,
"particle_momentum_y": 1.4613271542201658e-35,
"particle_momentum_z": 3.468728453537439e-23,
"particle_position_x": 0.04996023704063194,
"particle_position_y": 8.398113230295983e-15,
"particle_position_z": 0.10931682580470406,
"particle_weight": 1.0
},
"lev=0": {
"Bx": 3.254531465641299e-14,
"By": 3.2768092409497234e-14,
"Bz": 1.0615286316115558e-16,
"Ex": 2.30845657253269e-05,
"Ey": 2.2656898931877975e-05,
"Ez": 1.997747654112569e-05,
"jx": 1.7819477343635878e-10,
"jy": 4.2163030523377745e-20,
"jz": 1.0378839382497739e-07
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"lev=0": {
"Bx": 1.3073041371012706e-14,
"By": 1.3033038210840872e-14,
"Bz": 5.595105968291083e-17,
"Ex": 2.801134785671445e-06,
"Ey": 2.8088613469887243e-06,
"Ez": 3.343430731047825e-06,
"jx": 2.5155716299904363e-11,
"jy": 2.013718424043256e-11,
"jz": 6.00631499206418e-09
"Bx": 1.307357220398482e-14,
"By": 1.3033571630685163e-14,
"Bz": 5.594998319468307e-17,
"Ex": 2.8010832905044288e-06,
"Ey": 2.8088096742407935e-06,
"Ez": 3.3433681277560495e-06,
"jx": 2.5151718871714067e-11,
"jy": 2.013398608921663e-11,
"jz": 6.0063967622563335e-09
},
"electrons": {
"particle_momentum_x": 7.437088723328491e-24,
"particle_momentum_y": 5.9495056615288754e-24,
"particle_momentum_z": 5.117548636687908e-22,
"particle_position_x": 0.036489969262013186,
"particle_position_y": 0.029201200231260247,
"particle_position_z": 6.9681085285694095
"particle_momentum_x": 7.43708887164806e-24,
"particle_momentum_y": 5.949505779760011e-24,
"particle_momentum_z": 5.117548636790359e-22,
"particle_position_x": 0.03648994812700447,
"particle_position_y": 0.029201183320618985,
"particle_position_z": 6.968107021318396
}
}
}
5 changes: 3 additions & 2 deletions Source/Diagnostics/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ Diagnostics::BaseReadParameters ()
if (WarpX::boost_direction[ dim_map[WarpX::moving_window_dir] ] == 1) {
// Convert user-defined lo and hi for diagnostics to account for boosted-frame
// simulations with moving window
const amrex::Real convert_factor = 1._rt/(WarpX::gamma_boost * (1._rt - WarpX::beta_boost) );
// Assuming that the window travels with speed c
const amrex::Real beta_window = WarpX::moving_window_v / PhysConst::c;
const amrex::Real convert_factor = 1._rt/(
WarpX::gamma_boost * (1._rt - WarpX::beta_boost * beta_window) );
m_lo[WarpX::moving_window_dir] *= convert_factor;
m_hi[WarpX::moving_window_dir] *= convert_factor;
}
Expand Down
4 changes: 4 additions & 0 deletions Source/Utils/WarpXUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ void ParseGeometryInput();
void ReadBoostedFrameParameters(amrex::Real& gamma_boost, amrex::Real& beta_boost,
amrex::Vector<int>& boost_direction);

void ReadMovingWindowParameters(
int& do_moving_window, int& start_moving_window_step, int& end_moving_window_step,
int& moving_window_dir, amrex::Real& moving_window_v);

void ConvertLabParamsToBoost();

/**
Expand Down
44 changes: 42 additions & 2 deletions Source/Utils/WarpXUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,43 @@ void ReadBoostedFrameParameters(Real& gamma_boost, Real& beta_boost,
}
}

void ReadMovingWindowParameters(
int& do_moving_window, int& start_moving_window_step, int& end_moving_window_step,
int& moving_window_dir, amrex::Real& moving_window_v)
{
const ParmParse pp_warpx("warpx");
pp_warpx.query("do_moving_window", do_moving_window);
if (do_moving_window) {
utils::parser::queryWithParser(
pp_warpx, "start_moving_window_step", start_moving_window_step);
utils::parser::queryWithParser(
pp_warpx, "end_moving_window_step", end_moving_window_step);
std::string s;
pp_warpx.get("moving_window_dir", s);

if (s == "z" || s == "Z") {
moving_window_dir = WARPX_ZINDEX;
}
#if defined(WARPX_DIM_3D)
else if (s == "y" || s == "Y") {
moving_window_dir = 1;
}
#endif
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_3D)
else if (s == "x" || s == "X") {
moving_window_dir = 0;
}
#endif
else {
WARPX_ABORT_WITH_MESSAGE("Unknown moving_window_dir: "+s);
}

utils::parser::getWithParser(
pp_warpx, "moving_window_v", moving_window_v);
moving_window_v *= PhysConst::c;
}
}

void ConvertLabParamsToBoost()
{
Real gamma_boost = 1., beta_boost = 0.;
Expand Down Expand Up @@ -194,8 +231,11 @@ void ConvertLabParamsToBoost()
{
if (boost_direction[dim_map[idim]]) {
amrex::Real convert_factor;
// Assume that the window travels with speed +c
convert_factor = 1._rt/( gamma_boost * ( 1 - beta_boost ) );
amrex::Real beta_window = beta_boost;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be

amrex::Real beta_window = 0;

i.e. if do_moving_window is false, the velocity of the moving window is effectively 0?

Copy link
Member

Choose a reason for hiding this comment

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

Apologies, I got confused. After more thought, I agree that this should be amrex::Real beta_window = beta_boost; in the absence of an explicit moving window.

if (WarpX::do_moving_window && idim == WarpX::moving_window_dir) {
beta_window = WarpX::moving_window_v / PhysConst::c;
}
convert_factor = 1._rt/( gamma_boost * ( 1 - beta_boost * beta_window ) );
prob_lo[idim] *= convert_factor;
prob_hi[idim] *= convert_factor;
if (max_level > 0){
Expand Down
43 changes: 8 additions & 35 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ void WarpX::MakeWarpX ()
{
ParseGeometryInput();

ReadMovingWindowParameters(
do_moving_window, start_moving_window_step, end_moving_window_step,
moving_window_dir, moving_window_v);

ConvertLabParamsToBoost();
ReadBCParams();

Expand Down Expand Up @@ -700,42 +704,11 @@ WarpX::ReadParameters ()
pp_warpx.query("compute_max_step_from_btd",
compute_max_step_from_btd);

pp_warpx.query("do_moving_window", do_moving_window);
if (do_moving_window)
{
utils::parser::queryWithParser(
pp_warpx, "start_moving_window_step", start_moving_window_step);
utils::parser::queryWithParser(
pp_warpx, "end_moving_window_step", end_moving_window_step);
std::string s;
pp_warpx.get("moving_window_dir", s);

if (s == "z" || s == "Z") {
moving_window_dir = WARPX_ZINDEX;
}
#if defined(WARPX_DIM_3D)
else if (s == "y" || s == "Y") {
moving_window_dir = 1;
}
#endif
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_3D)
else if (s == "x" || s == "X") {
moving_window_dir = 0;
}
#endif

else {
WARPX_ABORT_WITH_MESSAGE("Unknown moving_window_dir: "+s);
}

WARPX_ALWAYS_ASSERT_WITH_MESSAGE(Geom(0).isPeriodic(moving_window_dir) == 0,
"The problem must be non-periodic in the moving window direction");

if (do_moving_window) {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
Geom(0).isPeriodic(moving_window_dir) == 0,
"The problem must be non-periodic in the moving window direction");
moving_window_x = geom[0].ProbLo(moving_window_dir);

utils::parser::getWithParser(
pp_warpx, "moving_window_v", moving_window_v);
moving_window_v *= PhysConst::c;
}

m_p_ext_field_params = std::make_unique<ExternalFieldParams>(pp_warpx);
Expand Down
Loading