Skip to content

Commit

Permalink
Plot electric field post_process improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste LEGOUIX committed Sep 29, 2023
1 parent 1131a7f commit dc4ed37
Showing 1 changed file with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
date : 17/07/2023
Diagnostic for (X,Y,Vx,Vy) geometry
-----> Simple usage: python3 plot_electric_field.py ../../../build/simulations/geometryXYVxVy/landau/ --itime 10
'''

# pylint: disable=invalid-name
Expand Down Expand Up @@ -63,16 +66,34 @@
data_dict = {f't={time_init}': epot.sel(time=time_init),
f't={time_diag}': epot.sel(time=time_diag)}

def plot_electric_field():
def plot_electric_potential(itime):
'''
Plot electric potential
'''
output_filename_epot = os.path.join(Path.cwd(), 'electric_potential.png')
plot_field2d(epot[itime,:,:].T , '', output_filename_epot, cmap='jet', scale='linear')


def plot_electric_field(itime):
'''
Plot electric field
'''

output_filename_Ex = os.path.join(Path.cwd(), 'electric_field_x.png')
plot_field2d(Ex[Timer-1,:,:].T , '', output_filename_Ex, cmap='jet', scale='linear')
plot_field2d(Ex[itime-1,:,:].T , '', output_filename_Ex, cmap='jet', scale='linear')

output_filename_Ey = os.path.join(Path.cwd(), 'electric_field_y.png')
plot_field2d(Ey[Timer-1,:,:].T , '', output_filename_Ey, cmap='jet', scale='linear')
plot_field2d(Ey[itime-1,:,:].T , '', output_filename_Ey, cmap='jet', scale='linear')

def plot_electric_energy_density_field(itime):
'''
Plot electric energy density field
'''

z = np.power(Ex[itime-1,:,:],2)+np.power(Ey[itime-1,:,:],2)
output_filename_U = os.path.join(Path.cwd(), 'electric_energy_density_field.png')
plot_field2d(z, '', output_filename_U, cmap='jet', scale='linear')


def compute_electric_energy():
'''
Expand Down Expand Up @@ -117,19 +138,21 @@ def plot_electric_energy():
plt.title(f'growthrate: {res[0]:0.3f} (theory: {theo_rate:0.3f})', fontsize=16)
plt.savefig('Electric_energy.png')

def plot_fdist(Vx,Vy):
def plot_fdist(itime,Vx,Vy):
'''
Plot the initial distribution function in (X,Y) fo a fixed (Vx, Vy) velocity position.
'''

plt.clf()
fig = plt.figure()
ax = fig.add_subplot()# 111,projection='3d')
im = ax.imshow(fdistribu[0,0,:,:,Vx,Vy] )
im = ax.imshow(fdistribu[itime,0,:,:,Vx,Vy] )
fig.colorbar(im)
plt.title('initial distribution function at Vx='+str(Vx)+' Vy='+str(Vy))
plt.savefig('test_fdistribution.png')

plot_electric_field()
plot_electric_potential(args.itime)
plot_electric_field(args.itime)
plot_electric_energy_density_field(args.itime)
plot_electric_energy()
plot_fdist(31,31)
plot_fdist(args.itime,31,31)

0 comments on commit dc4ed37

Please sign in to comment.