Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
3d9ac42
Esirkepov Eq. 24, 31, 38 (wip)
LudwigBoess May 3, 2025
c984fe0
added THIRD
LudwigBoess May 3, 2025
1be5185
bugfix
LudwigBoess May 3, 2025
180358e
formatting
LudwigBoess May 3, 2025
b81f433
redefine vectors to variables + explicit loop unrolling for 2D
LudwigBoess May 11, 2025
dfc7165
moved interpolation order from variable to compiler directive
LudwigBoess May 11, 2025
f1b8cd7
first attempt at 2D current deposit with Esirkepov
LudwigBoess May 13, 2025
cb56279
more local calculation of weight functions
LudwigBoess May 13, 2025
9f50dea
switch to row-major order
LudwigBoess May 13, 2025
6b32791
first attempt at current deposit jx1 in 3D
LudwigBoess May 13, 2025
9ab4c0f
Merge branch 'dev/fieldsolver_stencil' into dev/esirkepov
LudwigBoess May 14, 2025
bf788a9
more efficient memory access (this time for real)
LudwigBoess May 14, 2025
b6a2811
first attempt at y/z deposit in 3D
LudwigBoess May 14, 2025
bbd2b3c
memory reorder
LudwigBoess May 15, 2025
4f344eb
esirkepov WIP
haykh May 15, 2025
1e437ba
added missing recursive J update
LudwigBoess May 15, 2025
51a4f69
fix comment
LudwigBoess May 14, 2025
cae1eef
fix accidental deletion of commented lines
LudwigBoess May 16, 2025
b87500e
fix in y current deposit
LudwigBoess May 16, 2025
f56afef
bugfix in parameter access
LudwigBoess May 16, 2025
63dc8a9
updates to J update indexing
LudwigBoess May 21, 2025
822cb96
fixed shift calculation
LudwigBoess May 21, 2025
4ebb994
bugfixes
LudwigBoess May 21, 2025
246b3e9
simplification and bugfix in Wy
LudwigBoess May 22, 2025
2301179
bugfix in case comparison
LudwigBoess May 22, 2025
98822bf
Merge branch 'dev/fieldsolver_stencil' into dev/esirkepov
LudwigBoess May 22, 2025
eb8c58e
switch off formatting for large B updates
LudwigBoess May 22, 2025
03aebb5
optimizations and prep for 3rd order deposit
LudwigBoess May 22, 2025
bd2f333
update 3D 2nd order deposit
LudwigBoess May 23, 2025
7e52c03
removed redundant terms
LudwigBoess May 23, 2025
f168426
2nd order particle pusher
LudwigBoess May 23, 2025
6eabea9
bugfix in Jz
LudwigBoess May 24, 2025
6a9ff16
update to deposit test
LudwigBoess May 26, 2025
56763b8
kernel error
haykh May 26, 2025
9542af1
Merge branch 'dev/esirkepov' of github.com:entity-toolkit/entity into…
haykh May 26, 2025
84fcb6c
deposit test fixed
haykh May 26, 2025
9b8985d
fixes to pusher
LudwigBoess May 27, 2025
c6b9cc8
bugfixes
LudwigBoess May 27, 2025
1d4b074
bugfixes for variable names
LudwigBoess May 27, 2025
b551c10
bugfix
LudwigBoess Jun 7, 2025
a8aa8bb
bugfix
LudwigBoess Jun 9, 2025
77cdd68
fix 2nd order shape function in pusher
LudwigBoess Jul 14, 2025
8c60b01
fix second order weight functions in 1D and 3D
LudwigBoess Jul 17, 2025
2732659
introduced `THREE_FOURTHS` to shorten expression in pusher and deposi…
LudwigBoess Jul 17, 2025
82ddfad
first step for esirkepov with arbitrary order (wip)
LudwigBoess Jul 28, 2025
90f5019
new esirkepov (WIP, not yet working properly)
haykh Aug 3, 2025
5aa4814
shape func fix
haykh Aug 5, 2025
7099a88
generalized shape function to 5th order, cleanup and removal of stagg…
LudwigBoess Aug 6, 2025
9f6f318
improved comments and cleanup
LudwigBoess Aug 6, 2025
1221068
cleanup and updates to generalized version (wip)
LudwigBoess Aug 6, 2025
6185783
bugfix
LudwigBoess Aug 6, 2025
d55240d
fixed old zigzag
haykh Aug 6, 2025
0f145b4
merged with master
haykh Aug 6, 2025
18d29d2
merged with 1.3.0rc
haykh Aug 6, 2025
87a80c2
esirkepov ranges fixed
haykh Aug 7, 2025
877e9f5
generalized field interpolation to arbitrary order (wip)
LudwigBoess Aug 12, 2025
e1274d5
bugfixes for indexing
LudwigBoess Aug 13, 2025
eae6a13
add remaining shape_order cases
LudwigBoess Aug 14, 2025
acfd136
bugfix for 3D deposit
LudwigBoess Aug 14, 2025
20ce482
Merge branch '1.3.0rc' into dev/esirkepov
LudwigBoess Aug 26, 2025
bd72a7e
bugfix in first order shape function
LudwigBoess Aug 29, 2025
6568008
cleanup
LudwigBoess Aug 29, 2025
ffde338
bugfix in static_cast
LudwigBoess Sep 9, 2025
dbb6b42
bugfix in 3rd order shape function
LudwigBoess Sep 10, 2025
ba44374
shape function up-to 8th order
LudwigBoess Sep 11, 2025
13a8522
bugfix, loop unroll pragma and error handling fix
LudwigBoess Sep 11, 2025
af001b7
remove print
LudwigBoess Sep 11, 2025
9b3bcd5
bugfixes
LudwigBoess Sep 11, 2025
7741cc5
9th order shape function
LudwigBoess Sep 11, 2025
e0d39ee
applied formatting, improved comments and error handling
LudwigBoess Sep 11, 2025
aa500e3
first attempt to give shape function order at compile time
LudwigBoess Sep 11, 2025
578cec2
cmake for shape funcs
haykh Sep 11, 2025
a4f75de
fix cmake options for deposit and shape order
LudwigBoess Sep 11, 2025
7c19202
bugfix in 3rd order shape function i_min for not staggered case
LudwigBoess Sep 12, 2025
7f2a30b
Merge branch '1.3.0rc' into dev/esirkepov
LudwigBoess Sep 13, 2025
58950c5
simplifications for 3rd order shape functions
LudwigBoess Sep 17, 2025
5025936
bugfix and optimisation for S3
LudwigBoess Sep 19, 2025
f2778f7
Merge branch '1.3.0rc' into dev/esirkepov
LudwigBoess Sep 21, 2025
554fcc2
bugfix in 4th order shape function
LudwigBoess Sep 22, 2025
8faa0ee
bugfix in 3D indexing
LudwigBoess Sep 22, 2025
6c216b1
Merge branch '1.3.0rc' into dev/esirkepov
LudwigBoess Oct 6, 2025
f4faa87
10th order shape function
LudwigBoess Oct 8, 2025
2a23da1
updated cmake options for 10th order
LudwigBoess Oct 9, 2025
0e93203
entity now goes to 11!
LudwigBoess Oct 9, 2025
65cbba6
revert to unoptimized version for S3 for further testing
LudwigBoess Oct 9, 2025
4adee23
temporary bugfix
LudwigBoess Oct 22, 2025
3848cc3
Esirkepov 1D
LudwigBoess Oct 22, 2025
417f03c
reduced 1d from 2d deposit
haykh Oct 30, 2025
65450c3
11th order + printing fixed
haykh Nov 3, 2025
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
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ set(DEBUG
set(precision
${default_precision}
CACHE STRING "Precision")

set(deposit
${default_deposit}
CACHE STRING "Deposit")

set(shape_order
${default_shape_order}
CACHE STRING "Shape function")

set(pgen
${default_pgen}
CACHE STRING "Problem generator")
Expand Down Expand Up @@ -75,6 +84,20 @@ set(precisions
"single" "double"
CACHE STRING "Precisions")

set(deposits
"zigzag" "esirkepov"
CACHE STRING "Deposits")

if(${deposit} STREQUAL "zigzag")
set(shape_order
${default_shape_order}
CACHE STRING "Shape functions")
endif()

set(shape_orders
"1;2;3;4;5;6;7;8;9;10;11"
CACHE STRING "Shape orders")

include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake)

# ------------------------- Third-Party Tests ------------------------------ #
Expand All @@ -92,6 +115,7 @@ include_directories(${plog_SRC}/include)

# -------------------------------- Main code ------------------------------- #
set_precision(${precision})
set_shape_order(${shape_order})
if("${Kokkos_DEVICES}" MATCHES "CUDA")
add_compile_options("-D CUDA_ENABLED")
set(DEVICE_ENABLED ON)
Expand Down
10 changes: 10 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ function(set_precision precision_name)
endif()
endfunction()

# ------------------------------- Shape function --------------------------- #
function(set_shape_order shape_order)
if(${deposit} STREQUAL "esirkepov")
if(${shape_order} GREATER 11)
message(FATAL_ERROR "Shape order must be between 1 and 11.")
endif()
add_compile_options("-DSHAPE_ORDER=${shape_order}")
endif()
endfunction()

# ---------------------------- Problem generator --------------------------- #
function(set_problem_generator pgen_name)
if(pgen_name STREQUAL ".")
Expand Down
6 changes: 6 additions & 0 deletions cmake/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ set(default_engine
set(default_precision
"single"
CACHE INTERNAL "Default precision")
set(default_deposit
"zigzag"
CACHE INTERNAL "Default deposit")
set(default_shape_order
1
CACHE INTERNAL "Default shape function order")
set(default_pgen
"."
CACHE INTERNAL "Default problem generator")
Expand Down
24 changes: 24 additions & 0 deletions cmake/report.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ printchoices(
"${Blue}"
PRECISION_REPORT
46)
printchoices(
"Deposit"
"deposit"
"${deposits}"
${deposit}
${default_deposit}
"${Blue}"
DEPOSIT_REPORT
46)
printchoices(
"Shape order"
"shape_order"
"${shape_orders}"
${shape_order}
${default_shape_order}
"${Blue}"
SHAPEFUNCTION_REPORT
46)
printchoices(
"Output"
"output"
Expand Down Expand Up @@ -113,6 +131,12 @@ string(
${PRECISION_REPORT}
"\n"
" "
${DEPOSIT_REPORT}
"\n"
" "
${SHAPEFUNCTION_REPORT}
"\n"
" "
${OUTPUT_REPORT}
"\n")

Expand Down
31 changes: 17 additions & 14 deletions cmake/styling.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -140,27 +140,30 @@ function(
else()
padto("${rstring}" " " ${Padding} rstring)

set(new_choices ${Choices})
foreach(ch IN LISTS new_choices)
string(REPLACE ${ch} "${Dim}${ch}${ColorReset}" new_choices
"${new_choices}")
endforeach()
set(Choices ${new_choices})
if(${Value} STREQUAL "ON")
set(col ${Green})
elseif(${Value} STREQUAL "OFF")
set(col ${Red})
else()
set(col ${Color})
endif()
if(NOT "${Value}" STREQUAL "")
string(REPLACE ${Value} "${col}${Value}${ColorReset}" Choices
"${Choices}")
endif()
if(NOT "${Default}" STREQUAL "")
string(REPLACE ${Default} "${Underline}${Default}${ColorReset}" Choices
"${Choices}")
endif()
set(new_choices "")
foreach(ch IN LISTS Choices)
set(elem "${ch}")
if((NOT "${Value}" STREQUAL "") AND (${ch} STREQUAL ${Value}))
set(elem "${col}${ch}${ColorReset}")
else()
set(elem "${Dim}${ch}${ColorReset}")
endif()
if((NOT "${Default}" STREQUAL "") AND (${ch} STREQUAL ${Default}))
set(elem "${Underline}${elem}${ColorReset}")
endif()
string(APPEND new_choices "${elem};")
endforeach()
string(LENGTH "${new_choices}" nlen)
math(EXPR nlen "${nlen} - 1")
string(SUBSTRING "${new_choices}" 0 ${nlen} new_choices)
set(Choices ${new_choices})
string(REPLACE ";" "/" Choices "${Choices}")
string(APPEND rstring "${Choices}")
endif()
Expand Down
30 changes: 25 additions & 5 deletions input.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,35 @@
# @default: 0
current_filters = ""

[algorithms.toggles]
# Toggle for the field solver
[algorithms.deposit]
# Enable the current deposition
# @type: bool
# @default: true
fieldsolver = ""
# Toggle for the current deposition
enable = ""
# Order of the particle shape function
# @type: int
# @default: 1
order = ""

# @TODO: fix fieldsolver params below
[algorithms.fieldsolver]
# Enable the EM fieldsolver
# @type: bool
# @default: true
deposit = ""
enable = ""
# Yee - all 0.0 - default
# 1D
deltax = -0.065
# 2D
deltay = -0.065
betaxy = -0.065
betayx = -0.065
# 3D - not yet tested
deltaz = 0.0
betaxz = 0.0
betazx = 0.0
betayz = 0.0
betazy = 0.0

[algorithms.timestep]
# Courant-Friedrichs-Lewy number
Expand Down
41 changes: 25 additions & 16 deletions src/engines/srpic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ namespace ntt {

void step_forward(timer::Timers& timers, domain_t& dom) override {
const auto fieldsolver_enabled = m_params.template get<bool>(
"algorithms.toggles.fieldsolver");
"algorithms.fieldsolver.enable");
const auto deposit_enabled = m_params.template get<bool>(
"algorithms.toggles.deposit");
"algorithms.deposit.enable");
const auto clear_interval = m_params.template get<std::size_t>(
"particles.clear_interval");

Expand Down Expand Up @@ -505,9 +505,30 @@ namespace ntt {
}
}

template <unsigned short O>
void deposit_with(const Particles<M::Dim, M::CoordType>& species,
const M& metric,
const scatter_ndfield_t<M::Dim, 3>& scatter_cur,
real_t dt) {
// clang-format off
Kokkos::parallel_for("CurrentsDeposit",
species.rangeActiveParticles(),
kernel::DepositCurrents_kernel<SimEngine::SRPIC, M, O>(
scatter_cur,
species.i1, species.i2, species.i3,
species.i1_prev, species.i2_prev, species.i3_prev,
species.dx1, species.dx2, species.dx3,
species.dx1_prev, species.dx2_prev, species.dx3_prev,
species.ux1, species.ux2, species.ux3,
species.phi, species.weight, species.tag,
metric, (real_t)(species.charge()), dt));
// clang-format on
}

void CurrentsDeposit(domain_t& domain) {
auto scatter_cur = Kokkos::Experimental::create_scatter_view(
domain.fields.cur);
auto shape_order = m_params.template get<int>("algorithms.deposit.order");
for (auto& species : domain.species) {
if ((species.pusher() == PrtlPusher::NONE) or (species.npart() == 0) or
cmp::AlmostZero_host(species.charge())) {
Expand All @@ -520,20 +541,8 @@ namespace ntt {
species.npart(),
(double)species.charge()),
HERE);
// clang-format off
Kokkos::parallel_for("CurrentsDeposit",
species.rangeActiveParticles(),
kernel::DepositCurrents_kernel<SimEngine::SRPIC, M>(
scatter_cur,
species.i1, species.i2, species.i3,
species.i1_prev, species.i2_prev, species.i3_prev,
species.dx1, species.dx2, species.dx3,
species.dx1_prev, species.dx2_prev, species.dx3_prev,
species.ux1, species.ux2, species.ux3,
species.phi, species.weight, species.tag,
domain.mesh.metric,
(real_t)(species.charge()), dt));
// clang-format on

deposit_with<SHAPE_ORDER>(species, domain.mesh.metric, scatter_cur, dt);
}
Kokkos::Experimental::contribute(domain.fields.cur, scatter_cur);
}
Expand Down
13 changes: 8 additions & 5 deletions src/framework/parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,16 @@ namespace ntt {
"current_filters",
defaults::current_filters));

/* [algorithms.toggles] ------------------------------------------------- */
set("algorithms.toggles.fieldsolver",
toml::find_or(toml_data, "algorithms", "toggles", "fieldsolver", true));
set("algorithms.toggles.deposit",
toml::find_or(toml_data, "algorithms", "toggles", "deposit", true));
/* [algorithms.deposit] ------------------------------------------------- */
set("algorithms.deposit.enable",
toml::find_or(toml_data, "algorithms", "deposit", "enable", true));
set("algorithms.deposit.order",
toml::find_or(toml_data, "algorithms", "deposit", "order", 1));

/* [algorithms.fieldsolver] --------------------------------------------- */
set("algorithms.fieldsolver.enable",
toml::find_or(toml_data, "algorithms", "fieldsolver", "enable", true));

set("algorithms.fieldsolver.delta_x",
toml::find_or(toml_data,
"algorithms",
Expand Down
8 changes: 8 additions & 0 deletions src/global/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ namespace files {

namespace ntt {

#if !defined(SHAPE_ORDER)
#define SHAPE_ORDER 0
inline constexpr std::size_t N_GHOSTS = 2;
#else // SHAPE_ORDER
inline constexpr std::size_t N_GHOSTS = static_cast<std::size_t>(
(SHAPE_ORDER + 1) / 2) +
1;
#endif // SHAPE_ORDER

// Coordinate shift to account for ghost cells
#define COORD(I) \
(static_cast<real_t>(static_cast<int>((I)) - static_cast<int>(N_GHOSTS)))
Expand Down
8 changes: 8 additions & 0 deletions src/global/utils/numeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ inline constexpr float TWO = 2.0f;
inline constexpr float THREE = 3.0f;
inline constexpr float FOUR = 4.0f;
inline constexpr float FIVE = 5.0f;
inline constexpr float SIX = 6.0f;
inline constexpr float TWELVE = 12.0f;
inline constexpr float ZERO = 0.0f;
inline constexpr float HALF = 0.5f;
inline constexpr float THIRD = 0.333333f;
inline constexpr float THREE_FOURTHS = 0.75f;
inline constexpr float THREE_HALFS = 1.5f;
inline constexpr float INV_2 = 0.5f;
inline constexpr float INV_4 = 0.25f;
inline constexpr float INV_8 = 0.125f;
Expand All @@ -51,9 +55,13 @@ inline constexpr double TWO = 2.0;
inline constexpr double THREE = 3.0;
inline constexpr double FOUR = 4.0;
inline constexpr double FIVE = 5.0;
inline constexpr double SIX = 6.0;
inline constexpr double TWELVE = 12.0;
inline constexpr double ZERO = 0.0;
inline constexpr double HALF = 0.5;
inline constexpr double THIRD = 0.3333333333333333;
inline constexpr double THREE_FOURTHS = 0.75;
inline constexpr float THREE_HALFS = 1.5;
inline constexpr double INV_2 = 0.5;
inline constexpr double INV_4 = 0.25;
inline constexpr double INV_8 = 0.125;
Expand Down
Loading