Skip to content

Commit

Permalink
Use alternative way to define emittance
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Aug 1, 2024
1 parent 06ca5b2 commit 7bcfccb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions examples/multi_stage/analysis_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
def get_emittance(ts, t):
"""Calculate the beam emittance at the given time step."""
w, x, ux = ts.get_particle(["w", "x", "ux"], t=t)
x2 = np.average(x**2, weights=w)
u2 = np.average(ux**2, weights=w)
x2 = np.average( x**2, weights=w)
xu = np.average(x * ux, weights=w)
return np.sqrt(x2 * u2 - xu**2)
return np.sqrt( x2 * np.average( (ux - xu/x2 * x)**2, weights=w) )


def analyze_simulation(simulation_directory, output_params):
Expand Down

0 comments on commit 7bcfccb

Please sign in to comment.