1import matplotlib.pyplot
as plt
19sparsity_threshold = 1e-15
21v_th = math.sqrt(3. * kB * temperature / particle_mass)
26dv = (vmax-vmin)/(n_blocks * block_width)
27v = np.arange(vmin, vmax, dv)
29vdf = np.ma.array(density * (particle_mass / (2.*math.pi*kB*temperature))**(3./2.) * np.exp(-particle_mass*(v-vmean)**2 / (2.*kB*temperature)))
30vdf = np.ma.masked_where(vdf < 0.005*sparsity_threshold, vdf)
33print(f
"mass: {particle_mass:.3e} kg or {particle_mass/mp:.1f} proton masses")
34print(f
"temperature: {temperature:.3e} K or {temperature * kB / q:.3e} eV")
35print(f
"density: {density:.3e} m^-3")
36print(f
"thermal speed: {v_th:.3e} m/s")
37print(f
"dv: {dv:.3e} m/s")
38print(f
"VDF max, sparsity threshold {np.max(vdf):.2e}, {sparsity_threshold:.1e}")
41ax.scatter(v, vdf, s=10, label=f
"v-space cell resolution dv = {dv:.3e} m/s")
43ax.scatter(v[::block_width], vdf[::block_width], marker=
"|", s=300, label=
"v-space blocks WID = "+str(block_width)+
" cells")
45ax.axvline(vmean, label=f
"mean velocity {vmean:.1e} m/s")
47ax.hlines(sparsity_threshold, vmin, vmax, label=f
"sparsity threshold {sparsity_threshold:.1e} s^3/m^6", color=
"C3", lw=3, alpha=0.5)
48ax.axvspan(vmean - v_th, vmean + v_th, alpha=0.3, label=f
"thermal velocity = {v_th:.3e} m/s")
49ax.axhspan(np.ma.min(vdf)*0.1, sparsity_threshold, xmin=vmin, xmax=vmax, color=
"C3", hatch=
"/", alpha=0.5)
50ax.set_xlim((vmin, vmax))
52ax.set_xlabel(
"Velocity space extent (m/s)")
53ax.set_ylabel(
"Phase-space density of VDF (s^3/m^6)")
54ax.set_title(f
"VDF parameters for mass {particle_mass:.3e} kg or {particle_mass/mp:.1f} proton masses, n = {density:.3e} m^-3 and T = {temperature:.3e} K or {temperature * kB / q:.3e} eV")