Warwick-Plasma / epoch

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

My code run for several minutes and stopped #684

Closed kundi-physics closed 4 months ago

kundi-physics commented 4 months ago

9e721383c33c0b994036579da7624e06

Status-Mirror commented 4 months ago

Hi @kundi-physics,

Could you copy and paste an input deck to the issue? If you surround your deck with ```

``` Like this ```

GitHub will format it correctly

Like this

Cheers, Stuart

kundi-physics commented 4 months ago
begin:constant

  # laser parameter
  la = 0.8 * micron
  omega = 2 * pi * c / la
  a0 = 120
  dl=10*la/c
  w0=3*la
  xr=pi*w0*w0/la
  xf0=50*la  # focus distance from left
  t0=3*dl

  #coordinate
  r = sqrt(y^2+z^2)

  # target parameter
  ro = 39.5*la

  den0 = 0.03 * critical(omega)
  x0 = 50*la
  ll = 200*la
  x1 = x0 + ll
  sigma_x1 = 5*la    # jet length corresponding to ... laser wavelength
  profile_0 = gauss(x, x0, sigma_x1)
  sigma_x2 = 5*la   # jet length corresponding to ... laser wavelength
  profile_1 = gauss(x, x1, sigma_x2)

end:constant

begin:control
  nx = 3600
  ny = 1600
  nz = 1600

  # final time of simulation
  t_end = (450 * la+ll)/c

  # size of domain
  x_min = 0
  x_max = 180 * la
  y_min = -40 * la
  y_max = -y_min
  z_min = -40  * la
  z_max = -z_min
  particle_tstart = t0
end:control

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

begin:window
  move_window = T
  window_start_time = 165 * la/c + t0
  bc_x_min_after_move = simple_outflow
  bc_x_max_after_move = simple_outflow
  window_v_x = (1.0-den0/critical(omega)) * c
end:window

begin:species
  name = proton
  charge = 1.0
  mass = 1836.15
  npart_per_cell = 4
  density = if((x lt x0), den0*profile_0, den0)
  density = if(x gt x1, den0*profile_1, density(proton))
  density = if(r gt ro, 0.0 , density(proton))
  density = if(x gt 300*la, 0.0, density(proton))
end:species

begin:species
  name = chlorine
  charge = 17.0
  mass = 67384.7
  npart_per_cell = 1
  density = density(proton)
end:species

begin:species
  name = electron
  charge = -1.0
  mass = 1.0
  npart_per_cell = 4
  density = 18*density(proton)
end:species

begin:laser
  boundary = x_min
  intensity_w_cm2 = a0*a0*1.37e18 /la*micron/la*micron
  lambda = la
  phase= 0 + pi*r_yz*r_yz*(xf0)/(xr*xr+(xf0)*(xf0))/la-atan((xf0)/xr)
  pol_angle = 0    # p-pol = 0.0    s-pol = pi/2
  profile = gauss(r_yz,0,w0*sqrt(1+(xf0)*(xf0)/xr/xr))/sqrt(1+(xf0)*(xf0)/xr/xr)
  t_profile = gauss(time,t0,dl)
  t_start=0
  t_end=2*t0
end:laser

begin:subset
  name = check
  gamma_min = 1.005
  include_species:proton
end:subset

begin:subset
  name = check1
  gamma_min = 1.005
  include_species:electron
end:subset

begin:output
  name = o1
  file_prefix = a
  # number of timesteps between output dumps
  dt_snapshot = 10 * la/c
  time_start = t0 + ll/c

  # Properties at particle positions
  particles = check+check1
  px = check+check1
  py = check+check1
  pz = check+check1
  particle_weight = check+check1
  spinx = check
  spiny = check
  spinz = check
 end:output

begin:output
  name = o2
  file_prefix = b
  # number of timesteps between output dumps
  dt_snapshot = 10 * la/c
  time_start = t0 + ll/c

 # Properties on grid
  grid = always
  ex = always + single
  ey = always + single
  ez = always + single
  bx = always + single
  by = always + single
  bz = always + single
  charge_density = always + no_sum + species + single

end:output
Status-Mirror commented 4 months ago

Hi @kundi-physics,

This simulation is too large for me to run for testing. I was able to run the deck by removing the particles and changing the domain to

  nx = 360
  ny = 180
  nz = 180

so I don't think there's a problem with your deck itself. I notice you have the key particle_tstart = t0 - does your deck "stop" when particles start moving? A large 3D simulation like this is incredibly expensive to run when the particles move, so I'm wondering if your code seemed to stop when the particle-pushing calculations began.

My advice would be to retry in a 2D simulation first, before moving to 3D. I think 64 cores may not be enough for the simulation you present here.

Hope this helps, Stuart

kundi-physics commented 4 months ago

Dear @Status-Mirror, I have tried a 2D simulation before this. 64 cores are used in a 2D simulation, and it's exactly not enough for a 3D simulation. So I tried to use 192 cores in my new 3D simulation, but it seems to be the same as before. Maybe 192 cores are still not enough for my 3D simulation, I will try to use more cores.

Next screenshots are "output" and "slurm" respectively in my 3D simulation which used 192 cores. b179c19c76cc9311d232f070adb7cc8a 3ba2c941bd6f51ba75468fde26967d2b

Thank you for your solution! kundi

TomGoffrey commented 4 months ago

You are using nz = 1600. Assuming you ran the 2D simulation with the same values of nx and ny your simulation will be 1600 times larger in 3D, so you will need a significant increase in the number of cores you are using.

kundi-physics commented 4 months ago

@TomGoffrey Yes, you are right. When I increase the number of cores from 192 to 480, the code run. Thank you for your suggestion!

TomGoffrey commented 4 months ago

Good to hear. I'll close the issue now, but should you run into further problems please feel free to re-open or start a new issue.