SmileiPIC / Smilei

Particle-in-cell code for plasma simulation
https://smileipic.github.io/Smilei
337 stars 118 forks source link

3D visualization #375

Closed Sonuphd closed 3 years ago

Sonuphd commented 3 years ago

Respected Sir,

I want to visualize 3D simulation of field diagnostic, but I found some errors during post-processing. I am sending you my input file and post-processing command.

import math

l0 = 2.0math.pi # laser wavelength [in code units] t0 = l0 # optcal cycle Lsimx = 300.l0 # length of the simulation box in x (= 240 mum) Lsimy = 80.l0 # length of the simulation box in y (= 64 mum) Lsimz = 80.l0 Tsim = 375.t0 # duartion of the simulation (= 1 ps) resx = 4. resy = 1. resz = 1. # nb of cells in on laser wavelength rest = resx/0.8 # nb of timesteps in one optical cycle dt = t0/rest nx = 3004 # nb of cells along x-axis npatchx = 8 # nb of patches along x-axis

xtot =12500.*l0 #(= 10000 mum)

x0 = xtot/2.0

widthx = 5875.*l0 #(= 4700 mum)

Lx = 62.5*l0 #(= 50 mum)

n0max = 5.734e-3 # electron density (code units =>1=plasma critical density)

initial density profile of electrons

def n0_electron(x,y):

#return 1./(1.+math.exp((abs(x-x0)-widthx)/Lx))*n0max

FWHMinI = 12.5l0 #(= 10 mum) waistinI = FWHMinI/(2.0math.sqrt(math.log(2.0))) waistinE = FWHMinI/math.sqrt(2.0math.log(2.0)) FWHMtinI = 8.0t0 #(= 21.3 fs) FWHMtinE = FWHMtinI*math.sqrt(2.0) #(= 30 fs)

diagEvery = int(37.5*t0/dt) # frequency of some outputs(= 100 fs)

DEFINING SMILEI's VARIABLES

All in "bloacks"

Main( geometry = "3Dcartesian", interpolation_order = 2, timestep = dt, simulation_time = Tsim, cell_length = [l0/resx,l0/resy,l0/resz], grid_length = [Lsimx,Lsimy,Lsimz], number_of_patches = [8,4,4], clrw = nx/npatchx, reference_angular_frequency_SI = 2.0math.pi3.0e8/0.8e-6, EM_boundary_conditions = [["silver-muller","silver-muller"],["silver-muller","silver-muller"],["silver-muller","silver-muller"]], solve_poisson = False, print_every = 100, random_seed = smilei_mpi_rank )

MovingWindow( time_start = 0.9*Main.grid_length[0], velocity_x = 0.9997 )

LoadBalancing( initial_balance = False, every = 20, cell_load = 1.,

)

Species( name = "electron", position_initialization = "random", momentum_initialization = "cold", particles_per_cell = 4, mass = 1.0, charge = -1.0, number_density = 0.005734, mean_velocity = [0.0,0.0,0.0], pusher = "boris", time_frozen = 0.0, boundary_conditions = [["remove","remove"],["remove","remove"],["remove","remove"]], )

LaserGaussian3D( box_side = "xmin", a0 = 5.2, # intensity 5.8e+19 omega = 1., focus = [0.,Main.grid_length[1]/2.,Main.grid_length[2]/2.], waist = waistinE,

time_envelope = tgaussian(start=0.,duration=2.*FWHMtinE,fwhm=FWHMtinE,center=FWHMtinE)

)

list_fields = ['Ex','Ey','Bz','Rho','Jx']

DiagFields( every = diagEvery, fields = list_fields, subgrid = None

)

DiagProbe( every = diagEvery, origin = [0.,Main.grid_length[1]/2.,Main.grid_length[2]/2.], corners = [[Main.grid_length[0],Main.grid_length[1]/2.,Main.grid_length[2]/2], ], number = [nx], fields = list_fields )

DiagScalar( every = int(diagEvery/10), vars=['Uelm','Ukin_electron', 'ExMax','ExMaxCell','EyMax','EyMaxCell','RhoMin', 'RhoMinCell','Ukin_bnd','Uelm_bnd','Ukin_out_mvw','Ukin_inj_mvw','Uelm_out_mvw','Uelm_inj_mvw'] )

DiagParticleBinning(

#deposited_quantity = "weight",
#every = diagEvery,
#species =  ["electron"],
#axes = [
#   ["moving_x",0., Lsimx, 300],
    #["ekin",1.,500.,200]
    #]
#)

DiagPerformances( every = diagEvery )

In [4]: diag=S.Field(0,"Rho",units=["10^20 cm^-3","um","fs"],title_font = {'size': 15, 'weight': 'bold', 'family':'serif', 'color': 'k'},xlabel_font = {'size' ...: : 15, 'weight': 'bold', 'family':'serif', 'color': 'k'},ylabel_font = {'size': 15, 'weight': 'bold', 'family':'serif', 'color': 'k'},xticklabels_font ...: = {'size': 15, 'weight': 'bold', 'family':'serif', 'color': 'k'},yticklabels_font = {'size': 15, 'weight': 'bold', 'family':'serif', 'color': 'k'},cma ...: p="seismic_r",colorbar_font= {'size': 15, 'weight': 'bold', 'family':'serif', 'color': 'k'},vmin=0,vmax=-1.0)

In [5]: diag.plot() Cannot plot in 3 dimensions !

mccoys commented 3 years ago

The error is very clear. You cannot plot in 3 dimensions with happi. However you can export to VTK if you want to use some visualization software.