Warwick-Plasma / epoch

Particle-in-cell code for plasma physics simulations
https://epochpic.github.io
GNU General Public License v3.0
186 stars 59 forks source link

Question on simulation set up #596

Closed zhangli28 closed 11 months ago

zhangli28 commented 1 year ago

Hi all,

I am looking for a simulation example in which I can inject and electron beam perpendicular to the laser propagation direction. For example, laser is prorating along X-direction and the electron bunch I would like to inject will be along the Y-direction.

Does such a configuration is possible ?

Thank you. Zhang

Status-Mirror commented 1 year ago

Hey Zhang,

You can have an x-propagating laser and a y-propagating bunch. For this deck, I have combined the simple plane wave demo, and the basic plasma injector demo. The injector block has been modified to inject a laser from the y_min axis.

begin:control
    nx = 200
    ny = 400
    t_end = 20e-15
    x_min = 0
    x_max = 10e-6
    y_min = -10e-6
    y_max = 10e-6
    stdout_frequency = 100
end:control

begin:boundaries
    bc_x_min = simple_laser
    bc_x_max = open
    bc_y_min = open
    bc_y_max = open
end:boundaries

begin:laser
    boundary = x_min
    intensity_w_cm2 = 1.0e18
    lambda = 1.0e-6
end:laser

begin:species
    name = Electron
    mass = 1.0
    charge = -1.0
end:species

begin:injector
   boundary = y_min
   species = Electron
   number_density = 1.0e10
   drift_y = 1.0e-20
   npart_per_cell = 10
end:injector

begin:output
    dt_snapshot = 10 * femto
    ey = always
    number_density = always
end:output

I have plotted both the $E_y$ field and the number density present at the end of the simulation:

perp_inj

zhangli28 commented 1 year ago

Dear @Status-Mirror,

thank you for great and very fast help. It is a great feeling to see that EPOCH developers responded so fast !!

I am trying to cross a Gaussian laser pulse and Gaussian electron bunch instead of plane laser pulse and plasma. I hope that the (https://epochpic.github.io/quickstart/basic_examples/injectors.html) example will help in this case. I will replace the plasma density with an electron bunch density. If there is any problem I will let you know for further help.

Thank you and best regards, Zhang

zhangli28 commented 1 year ago

Dear @Status-Mirror,

I have one additional question ... is it possible to inject the electron and the laser pulse (perpendicular to each other) with a moving window ? or it can only be done with static window ?

best regards, Zhang

Status-Mirror commented 1 year ago

Hey @zhangli28,

I think this should be fine until the laser starts to move. From quickly checking the window block documentation, you can keep the window static until a certain time using the window_start_time key. As long as the laser pulse and injected beam have fully entered the simulation window by then, I think it's fine to start moving.

Don't try injecting any particles or lasers once the window has started moving. You can be sure the laser block and injector block have been deactivated by this time using the t_end key in both blocks.

Cheers, Stuart

zhangli28 commented 12 months ago

Dear @Status-Mirror,

Thanks for clear explanation. I think every thing is clear enough and I can close this issue. If there is any problem, I will reopen it.

best regards, Zhang

zhangli28 commented 11 months ago

Dear @Status-Mirror,

I am following the example of particle bunch given in https://epochpic.github.io/quickstart/basic_examples/injectors.html#file-injectors

for 3D case should I make the profile as follows: number_density = 1.0e10 * gauss(r_yz,0,w_y) * gauss(time,t_hw01m,w_t)

Thank you. Zhang

Status-Mirror commented 11 months ago

Hey Zhang,

You've linked to the file-injectors example, but I think you mean the particle-bunch demo.

That is generally correct for 3d, but the maths parser doesn't recognise the variable r_yz, so you need to define it yourself. There are additional domains to specify in a 3d simulation. If I was adapting the particle-bunch demo to 3d, I'd end up with an input.deck of the form:

begin:control
    nx = 500
    ny = 200
    nz = 200
    t_end = 20.0e-15
    x_min = 0
    x_max = 25e-6
    y_min = -5e-6
    y_max = 5e-6
    z_min = -5e-6
    z_max = 5e-6
    stdout_frequency = 100
end:control

begin:boundaries
    bc_x_min = open
    bc_x_max = open
    bc_y_min = open
    bc_y_max = open
    bc_z_min = open
    bc_z_max = open
end:boundaries

begin:species
    name = Electron
    mass = 1.0
    charge = -1.0
end:species

begin:constant
    x_fwhm = 1.0e-6
    r_fwhm = 1.0e-6
    t_fwhm = x_fwhm / c
    w_t = t_fwhm / (2.0 * sqrt(loge(2)))
    w_r = r_fwhm / (2.0 * sqrt(loge(2)))
    r_yz = sqrt(y^2 + z^2)
    t_hw01m = 0.5 * t_fwhm * sqrt(loge(10) / loge(2))
end:constant

begin:injector
   boundary = x_min
   species = Electron
   number_density = 1.0e10 * gauss(r_yz,0,w_r) * gauss(time,t_hw01m,w_t)
   number_density_min = 1.0e9
   t_start = 0
   t_end = 2.0 * t_hw01m
   drift_x = 1.0e-20
   temp_ev = 1.0e3
   npart_per_cell = 10
end:injector

begin:output
    dt_snapshot = t_end
    number_density = always
end:output

Note that 3d simulations are significantly slower than 2d simulations, and that most PIC projects are usually performed in 2d.

Hope this helps, Stuart

zhangli28 commented 11 months ago

Dear @Status-Mirror,

Thank you for your very very kind help.

Now, comes the main problem ... I am trying to launch this electron beam from boundary = y_min

I want a Gaussian particle bunch to move from y_min towards y_max. Few days ago, you showed me how to do it with slab of plasma, but when I am trying to do with Gaussian bunch I am not getting the beam anywhere ... may be I am doing some mistakes.

I want to use boundary = y_min and drift_y = 1.0e-20

Please, could you help me to achieve this ( with some modification in the previous example).

Thank you so much. Zhang

Status-Mirror commented 11 months ago

Sure thing, I've changed the previous 3d example to inject from y_min towards y_max. I haven't tested this myself, so let me know if it isn't working.

In addition to your boundary and drift_y changes, I have also added an ability to move the central position of the bunch in the x-z plane. Maybe you were trying to inject a bunch outside the simulation window?

begin:control
    nx = 500
    ny = 200
    nz = 200
    t_end = 20.0e-15
    x_min = 0
    x_max = 25e-6
    y_min = -5e-6
    y_max = 5e-6
    z_min = -5e-6
    z_max = 5e-6
    stdout_frequency = 100
end:control

begin:boundaries
    bc_x_min = open
    bc_x_max = open
    bc_y_min = open
    bc_y_max = open
    bc_z_min = open
    bc_z_max = open
end:boundaries

begin:species
    name = Electron
    mass = 1.0
    charge = -1.0
end:species

begin:constant
    x_centre = 12.5e-6
    z_centre = 0.0e-6
    y_fwhm = 1.0e-6
    r_fwhm = 1.0e-6
    t_fwhm = y_fwhm / c
    w_t = t_fwhm / (2.0 * sqrt(loge(2)))
    w_r = r_fwhm / (2.0 * sqrt(loge(2)))
    r_xz = sqrt((x - x_centre)^2 + (z - z_centre)^2)
    t_hw01m = 0.5 * t_fwhm * sqrt(loge(10) / loge(2))
end:constant

begin:injector
   boundary = y_min
   species = Electron
   number_density = 1.0e10 * gauss(r_xz,0,w_r) * gauss(time,t_hw01m,w_t)
   number_density_min = 1.0e9
   t_start = 0
   t_end = 2.0 * t_hw01m
   drift_y = 1.0e-20
   temp_ev = 1.0e3
   npart_per_cell = 10
end:injector

begin:output
    dt_snapshot = t_end
    number_density = always
end:output
zhangli28 commented 11 months ago

Dear @Status-Mirror,

Thank you so so much. Now, with your deck file at least I can see the Gaussian beam. I need to adjust some parameters to see what I am trying to do. If I fail once again, I will ask you again.

Thank you so so much once again. Zhang

zhangli28 commented 11 months ago

Dear @Status-Mirror,

Now, I can see what I was looking for. All credit goes to you.

However, I noticed one thing that I would like to bring to your notice. I found that that instead of defining

r_xz = sqrt( (x - x_centre)^2 + (z - z_centre)^2 ) in the constant block, it should be used directly in the profile as:

number_density = 1.0e10 * gauss( sqrt((x - x_centre)^2 + (z - z_centre)^2) , 0, w_r) * gauss(time, t_hw01m, w_t)

Otherwise the beam cannot be shifted to the desired position along x-direction.

Thank you once again and I am closing this issue.

best regards, Zhang