Warwick-Plasma/epoch

To visualise the distribution of macro-particles in momentum space

Closed this issue · 2 comments

Hello,
Could you please provide the matlab script to visualise the distribution of macro-particles in position and momentum space (located in the basic example/particle loading : (https://epochpic.github.io/quickstart/basic_examples/particle_load.html), because I am getting an error "array exceeds the maximum possible variable size", to create plot ([x_plot, y_plot] = meshgrid(x_centres, y_centres)).
Screenshot 2024-02-22 at 5 45 46 PM

Thank you

Hey @MKR100,

Sure thing, the script is:

data = GetDataSDF('0000.sdf');
dist_fn = 'y_px';
species = 'Electron';

x_centres = data.dist_fn.(dist_fn).(species).grid.x;
y_centres = data.dist_fn.(dist_fn).(species).grid.y;
[x_plot, y_plot] = meshgrid(x_centres, y_centres);

vals = data.dist_fn.(dist_fn).(species).data;
surf(x_plot, y_plot, vals', 'EdgeColor','none');
cbar = colorbar;
view(2);
ax = gca;
ax.FontSize = 16;
xlabel('y [m]');
ylabel('p_x [kgm/s]');
cbar.Label.String = 'Weight sum in bin';

Make sure SDF/Matlab is on your path for this to work, as you'll need GetDataSDF and all the other functions which it calls.

Hope this helps,
Stuart

P.S. I must have added the title manually after running this script.

@Status-Mirror Thanks a lot.