Closed AlexanderSinn closed 5 months ago
This PR extends the beam in-situ diagnostic to include the first and second moment of spin in each direction if spin tracking is enabled. The following python script can read and plot the in-situ spin diagnostics:
import sys sys.path.insert(1, "../hipace/tools/") import read_insitu_diagnostics as diag import matplotlib.pyplot as plt import numpy as np path = "/scratch/project/alex/debug/diags/new/spin_track_19/insitu/reduced_beam*" all_data = diag.read_file(path) time = all_data["time"] sx_mean = all_data["average"]["[sx]"] sy_mean = all_data["average"]["[sy]"] sz_mean = all_data["average"]["[sz]"] sx_std = np.sqrt(np.maximum(all_data["average"]["[sx^2]"] - all_data["average"]["[sx]"]**2, 0)) sy_std = np.sqrt(np.maximum(all_data["average"]["[sy^2]"] - all_data["average"]["[sy]"]**2, 0)) sz_std = np.sqrt(np.maximum(all_data["average"]["[sz^2]"] - all_data["average"]["[sz]"]**2, 0)) pol = np.sqrt(sx_mean**2 + sy_mean**2 + sz_mean**2) fig, ax = plt.subplots(4, 1, dpi=150, figsize=(8, 11)) ax[0].plot(time, sx_std, label="HiPACE++ std sx") ax[0].plot(time, sy_std, label="HiPACE++ std sy") ax[0].plot(time, sz_std, label="HiPACE++ std sz") ax[0].legend() ax[0].axes.xaxis.set_ticklabels([]) ax[1].plot(time, 1-sx_mean, label="HiPACE++ 1-mean sx") ax[1].legend() ax[1].axes.xaxis.set_ticklabels([]) ax[2].plot(time, sy_mean, label="HiPACE++ mean sy") ax[2].plot(time, sz_mean, label="HiPACE++ mean sz") ax[2].legend() ax[2].axes.xaxis.set_ticklabels([]) ax[3].plot(time, 1-pol, label="HiPACE++ 1-spin polarisation") ax[3].legend() ax[3].set_xlabel("time in s") plt.tight_layout()
const
@pots007 Could you confirm that this covers most needs for spin polarisation studies?
This PR extends the beam in-situ diagnostic to include the first and second moment of spin in each direction if spin tracking is enabled. The following python script can read and plot the in-situ spin diagnostics:
const
isconst
)