Skip to content

Add macro-particle weight to Coords struct#232

Open
ndwang wants to merge 1 commit intobmad-sim:mainfrom
ndwang:weight
Open

Add macro-particle weight to Coords struct#232
ndwang wants to merge 1 commit intobmad-sim:mainfrom
ndwang:weight

Conversation

@ndwang
Copy link
Contributor

@ndwang ndwang commented Jan 25, 2026

weight is a weighting factor typically used when macro-particles are being simulated. It is optional and defaults to nothing.

@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/types.jl 60.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@mattsignorelli
Copy link
Member

In what cases do particles of a bunch (one species) each have different weights?

@ndwang
Copy link
Contributor Author

ndwang commented Jan 26, 2026

In what cases do particles of a bunch (one species) each have different weights?

  1. Instead of using macro-particle density to represent a distribution, you can have macro-particles on a fixed grid and use weights. This avoids counting noise.
  2. When you have a weak halo, you don't want to track 1 billion particles in the core just so you can have a reasonable number of particles on the edge.

@DavidSagan
Copy link
Member

Weights can also be used, for example, when simulating space charge, where the weight is used to calculate how large a wake is left by a macroparticle. A typical situation is to have a leading particle with a large weight which generates a reasonable wake followed by "test" particles with zero weights to not perturbe the wake.

@mattsignorelli
Copy link
Member

sounds good.

we should probably just use Base.@kwdef at this point for coords (requiring only v), and then let the Bunch ctor also be all keywords in the same way. This will make initializing a bunch less awkward, e.g. Bunch(v, nothing, weights) instead would be Bunch(v=v, weights=weights). However if we also remove the old ctors, we would have to make sure to bump breaking change version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants