-
Notifications
You must be signed in to change notification settings - Fork 29
2D Space Charge in Particle Tracking #909
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
base: development
Are you sure you want to change the base?
2D Space Charge in Particle Tracking #909
Conversation
| // push momentum | ||
| px += field_interp[0] * push_consts; | ||
| py += field_interp[1] * push_consts; | ||
| pz += field_interp[2] * push_consts; // TODO: is this always += 0.0? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-zero, because we will model a variation of the current density along t.
Might in practice often be neglected. We can start without long. kick and add it later.
de299e6 to
7b53d47
Compare
7b53d47 to
79b5d1c
Compare
|
The test here currently fails with the simple error: We should make this error conditional on the space charge solver. This solver requires a grid size of 1 in z. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to touch base on the scale/normalization of the fields returned by the 2D solve, in order to correctly set the value of push_constants in GatherAndPush.cpp.
Enable interpolating fields to particles in 1D or 2D even when running a 3D simulation. Needed for 2D and 2.5D space charge in ImpactX: BLAST-ImpactX/impactx#909
|
Here is a more interesting observation. I ran with an axisymmetric KV beam, expanding in free space, with 2D space charge for an identical number of grid points in x and y, but the envelopes show significantly different evolution. This is evidence of x/y asymmetry in the underlying 2D Poisson solve. The push constants need to be updated, but they are identical in x and y. # Particle Beam(s)
beam.npart = 100000 # outside tests, use 1e5 or more
beam.units = static
beam.kin_energy = 250.0
beam.current = 1.0e-3
beam.particle = proton
beam.distribution = kvdist
beam.lambdaX = 4.472135955e-4
beam.lambdaY = beam.lambdaX
beam.lambdaT = 9.12241869e-7
beam.lambdaPx = 0.0
beam.lambdaPy = 0.0
beam.lambdaPt = 0.0
# Beamline: lattice elements and segments
lattice.elements = monitor drift1 monitor
lattice.nslice = 40
drift1.type = drift
drift1.ds = 6.0
monitor.type = beam_monitor
monitor.backend = h5
# Algorithms
algo.particle_shape = 2
algo.space_charge = 2D
algo.poisson_solver = "fft"
amr.n_cell = 16 16 1
amr.blocking_factor_x = 8
amr.blocking_factor_y = 8
amr.blocking_factor_z = 1
geometry.prob_relative = 1.01 |
| px += field_interp[0] * push_consts * beta_gamma * dr[2] / (c0_SI); | ||
| py += field_interp[1] * push_consts * beta_gamma * dr[2] / (c0_SI); //this should be field_interp[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constants appearing in px and py are currently in draft form only, and will continue to be updated.
Keep simple for now.
Phi is then blown up again to 3D with indentical values in z. Co-authored-by: Weiqun Zhang <[email protected]>
| ) | ||
| add_impactx_test(expanding-fft-2d.py | ||
| examples/expanding_beam/run_expanding_fft_2D.py | ||
| OFF # ImpactX MPI-parallel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want 100% the same AMReX blocks ("grids output"):
| OFF # ImpactX MPI-parallel | |
| ON # ImpactX MPI-parallel |
|
FYI: I had to relax the tolerance a great deal for the Python tests, especially the FODO test, while the C++/app tests passed with no problem. I'm still concerned that there may be something else going on specific to the Python test implementation or bindings. |
* [pre-commit.ci] pre-commit autoupdate (BLAST-ImpactX#1161) updates: - [github.com/astral-sh/ruff-pre-commit: v0.13.1 → v0.13.2](astral-sh/ruff-pre-commit@v0.13.1...v0.13.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * [pre-commit.ci] pre-commit autoupdate (BLAST-ImpactX#1165) updates: - [github.com/astral-sh/ruff-pre-commit: v0.13.2 → v0.13.3](astral-sh/ruff-pre-commit@v0.13.2...v0.13.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Gauss 3D: Fix Push Constants (BLAST-ImpactX#1168) This fixes the push constants for non-equal x,y,z and adds an end-point correction for the integration. It also changes the number of integration points by default to 101 instead of 401. Co-authored-by: Ji Qiang <[email protected]> * [pre-commit.ci] pre-commit autoupdate (BLAST-ImpactX#1174) updates: - [github.com/astral-sh/ruff-pre-commit: v0.13.3 → v0.14.0](astral-sh/ruff-pre-commit@v0.13.3...v0.14.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> * Bump stefanzweifel/git-auto-commit-action from 6 to 7 (BLAST-ImpactX#1175) Bumps [stefanzweifel/git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) from 6 to 7. - [Release notes](https://github.com/stefanzweifel/git-auto-commit-action/releases) - [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md) - [Commits](stefanzweifel/git-auto-commit-action@v6...v7) --- updated-dependencies: - dependency-name: stefanzweifel/git-auto-commit-action dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github/codeql-action from 3 to 4 (BLAST-ImpactX#1176) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@v3...v4) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix `BeamMonitor`: Delay Open (BLAST-ImpactX#1178) `BeamMonitor` opens the openPMD series now on first output. This simplifies usage dramatically, now allowing to: * create the lattice (monitor elements) before the `sim` is even initialized * creating a monitor element and not using it in a lattice * CMake `pip_install`: Package Examples (BLAST-ImpactX#1179) Ensure the `examples/` directory is part of the `pip` wheels we build, e.g., on `cmake --build build -j 6 --target pip_install` * Envelope: Silence Warning w/o Space-Charge (BLAST-ImpactX#1173) Consistent with the other two tracking modes, we only print options upfront and do not warn every simulation step if space charge is not used. * Release 25.10 (BLAST-ImpactX#1180) * Update Stub Files * AMReX/ABLASTR/WarpX: development (BLAST-ImpactX#1177) * ABLASTR/WarpX: development Update the ABLASTR dependency to the latest development branch. * pyAMReX: `development` * Python: Improve `KnownElementsList` (BLAST-ImpactX#1181) Add per-element by-reference access for manipulation. * Update Stub Files * Element Selection Syntax (BLAST-ImpactX#1182) * Implementation 5hr vibe pair coded in Cursor. Maybe should have just done it xD * Doc * Fix Type Hints * `select`: Fix All-Selected Path Avoid implicit return of `None` * Cleanup * Update Stub Files * Fix Python import errors (BLAST-ImpactX#1186) * Update Stub Files * Fix RFCavity edge case (BLAST-ImpactX#1185) * Fix RFCavity edge case. * Remove extra semicolon. * Fix el typing (BLAST-ImpactX#1190) * Fix `KnownElementsList` Stubs Avoid importing `typing` for type hints, because pybind11-stubgen forgets the import when generating `pyi` files... * Update Stubs * Update PALS to 0.2.0 (BLAST-ImpactX#1184) * Update PALS version * Fix missing imports in KnownElementsList.pyi * Fix FODO example script * Revert changes to stub file * fix some math issues in examle documentation (BLAST-ImpactX#1191) * "Starting step" Print: Spaces (BLAST-ImpactX#1187) - newline before new step - no space before `++++ Starting step` * Element Names: All, `None` (BLAST-ImpactX#1189) It is easier for user-facing workflows if `.name` exists for all elements, even `Empty`. In Python, instead of throwing an exception we return the `None` value for elements without a user-provided name, which simplifies user-logic. In this case `.has_name` is `False`. * Update Stub Files --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Axel Huebl <[email protected]> Co-authored-by: Ji Qiang <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: ax3l <[email protected]> Co-authored-by: Edoardo Zoni <[email protected]> Co-authored-by: Richard Pausch <[email protected]>
|
@WeiqunZhang and @ax3l The test mentioned earlier today for this PR is located in: C++ input file: I have added a script for plotting the x-y beam size evolution called If the test works, the beam size at the end (at the maximum value of To see the convergence issue, I suggest running the Python test with npart = 1M for a few values of |
|
@WeiqunZhang and @ax3l Note: I tried the same test using 3D space charge (using |
|
@WeiqunZhang and @ax3l Here is the latest update: If I run the app example "input_expanding_fft_2D.in", then I always see that 1 grid is used, independently of the choice of blocking factor ("1 grids 1024 cells"), and the results are consistent: This issue has now been fixed. Thanks @WeiqunZhang ! |
Co-authored-by: Axel Huebl <[email protected]>
|
For this PR, we need to resolve the following error resulting in failing tests:
|



Add 2D Space Charge in Particle Tracking. First part of #401
To Do
ReduceToPlaneMFAMReX-Codes/amrex#4566For this to compile, you need to set:
cmake --fresh -S . -B build -DImpactX_FFT=ON -DImpactX_ablastr_branch=a76eecf1553f5d0e72ec948c9a67db4111a1544f(WarpX commit of the merged PR BLAST-WarpX/warpx#6201 )Follow-up