#################################
# Domain, Resolution & Numerics
#

# time-scale with highly kinetic dynamics
stop_time = 0.2e-12            # [s]
# time-scale for converged ion energy
#   notes: - effective acc. time depends on laser pulse
#          - ions will start to leave the box
#stop_time = 1.0e-12           # [s]

# quick tests at ultra-low res. (CI)
#amr.n_cell = 384 512

# proper resolution for 10 n_c excl. acc. length
# (>=1x V100)
amr.n_cell = 2688 3712

# proper resolution for 30 n_c (dx<=3.33nm) incl. acc. length
# (>=6x V100)
#amr.n_cell = 7488 14720

# simulation box, no MR
#   note: increase z (space & cells) for converging ion energy
amr.max_level = 0
geometry.prob_lo = -7.5e-6 -5.e-6
geometry.prob_hi =  7.5e-6 25.e-6
geometry.is_periodic = 0 0 0  # non-periodic (default)

# macro-particle shape
interpolation.nox = 3
interpolation.noy = 3
interpolation.noz = 3

# numerical tuning
warpx.cfl = 0.999
warpx.use_filter = 1          # bilinear current/charge filter


#################################
# Performance Tuning
#
amr.max_grid_size = 64
amr.blocking_factor = 64
warpx.do_dynamic_scheduling = 0

# load balancing
warpx.load_balance_int = 10
warpx.load_balance_with_sfc = 0
#warpx.load_balance_efficiency_ratio_threshold = 1.1
algo.load_balance_costs_update = Heuristic
#algo.costs_heuristic_particles_wt = 0.9
#algo.costs_heuristic_cells_wt = 0.1

# particle bin-sorting on GPU (ideal defaults not investigated in 2D)
#warpx.sort_int = 4
#warpx.sort_bin_size = 4 4 4


#################################
# Target Profile
#
particles.species_names = electrons hydrogen

# particle species
hydrogen.species_type = hydrogen
hydrogen.injection_style = NUniformPerCell
hydrogen.num_particles_per_cell_each_dim = 2 2 4
hydrogen.momentum_distribution_type = constant
hydrogen.ux = 0.0
hydrogen.uy = 0.0
hydrogen.uz = 0.0
#hydrogen.zmin = -10.0e-6
#hydrogen.zmax =  10.0e-6
hydrogen.profile = parse_density_function

electrons.species_type = electron
electrons.injection_style = NUniformPerCell
electrons.num_particles_per_cell_each_dim = 2 2 4
electrons.momentum_distribution_type = "gaussian"
electrons.ux_th = .01
electrons.uz_th = .01
#electrons.zmin = -10.0e-6
#electrons.zmax =  10.0e-6

# ionization physics (field ionization/ADK)
#   [i1] none (fully pre-ionized):
electrons.profile = parse_density_function
#   [i2] field ionization (ADK):
#hydrogen.do_field_ionization = 1
#hydrogen.physical_element = H
#hydrogen.ionization_initial_level = 0
#hydrogen.ionization_product_species = electrons
#electrons.profile = constant
#electrons.density = 0.0

# collisional physics (binary MC model after Nanbu/Perez)
#collisions.collision_names = c_eH c_ee c_HH
#c_eH.species = electrons hydrogen
#c_ee.species = electrons electrons
#c_HH.species = hydrogen hydrogen
#c_eH.CoulombLog = 15.9
#c_ee.CoulombLog = 15.9
#c_HH.CoulombLog = 15.9

# number density: "fully ionized" electron density as reference
#   [material 1] cryogenic H2
my_constants.nc    = 1.742e27  # [m^-3]  1.11485e21 * 1.e6 / 0.8**2
my_constants.n0    = 30.0      # [n_c]
#   [material 2] liquid crystal
#my_constants.n0    = 192
#   [material 3] PMMA
#my_constants.n0    = 230
#   [material 4] Copper (ion density: 8.49e28/m^3; times ionization level)
#my_constants.n0    = 1400

# profiles
#   pre-plasma
my_constants.L    = 0.05e-6      # [1/m] scale length (>0)
my_constants.Lcut = 2.0e-6       # [1/m] hard cutoff from surface
#   core: flat foil, cylinder or sphere
my_constants.r0 = 2.5e-6        # [m] radius or half-thickness

# [target 1] flat foil (thickness = 2*r0)
#electrons.density_function(x,y,z) = "nc*n0*(
#    (abs(z)<=r0) +
#    (abs(z)>r0)*(abs(z)<r0+Lcut)*exp( (-abs(z)+r0)/L ) )"
#hydrogen.density_function(x,y,z) = "nc*n0*(
#    (abs(z)<=r0) +
#    (abs(z)>r0)*(abs(z)<r0+Lcut)*exp( (-abs(z)+r0)/L ) )"

# [target 2] cylinder
electrons.density_function(x,y,z) = "nc*n0*(
    ((x*x+z*z)<=(r0*r0)) +
    (sqrt(x*x+z*z)>r0)*(sqrt(x*x+z*z)<r0+Lcut)*exp( (-sqrt(x*x+z*z)+r0)/L ) )"
hydrogen.density_function(x,y,z) = "nc*n0*(
    ((x*x+z*z)<=(r0*r0)) +
    (sqrt(x*x+z*z)>r0)*(sqrt(x*x+z*z)<r0+Lcut)*exp( (-sqrt(x*x+z*z)+r0)/L ) )"

# [target 3] sphere
#electrons.density_function(x,y,z) = "nc*n0*(
#    ((x*x+y*y+z*z)<=(r0*r0)) +
#    (sqrt(x*x+y*y+z*z)>r0)*(sqrt(x*x+y*y+z*z)<r0+Lcut)*exp( (-sqrt(x*x+y*y+z*z)+r0)/L ) )"
#hydrogen.density_function(x,y,z) = "nc*n0*(
#    ((x*x+y*y+z*z)<=(r0*r0)) +
#    (sqrt(x*x+y*y+z*z)>r0)*(sqrt(x*x+y*y+z*z)<r0+Lcut)*exp( (-sqrt(x*x+y*y+z*z)+r0)/L ) )"


#################################
# Laser Pulse Profile
#
lasers.names        = laser1
laser1.position     = 0. 0. -4.0e-6     # point the laser plane (antenna)
laser1.direction    = 0. 0. 1.          # the plane's (antenna's) normal direction
laser1.polarization = 1. 0. 0.          # the main polarization vector
laser1.e_max        = 64.e12            # maximum amplitude of the laser field [V/m]
laser1.wavelength   = 0.8e-6            # central wavelength of the laser pulse [m]
laser1.profile      = Gaussian
laser1.profile_waist = 4.e-6            # beam waist (E(w_0)=E_0/e) [m]
laser1.profile_duration = 30.e-15       # pulse length (E(tau)=E_0/e; tau=tau_E=FWHM_I/1.17741) [s]
laser1.profile_t_peak = 50.e-15         # time until peak intensity reached at the laser plane [s]
laser1.profile_focal_distance = 4.0e-6  # focal distance from the antenna [m]

# E_0 = a_0 * 3.211e12 / lambda_0[mu]
#   a_0 = 16, lambda_0 = 0.8mu -> E_0 = 64.22 TV/m


#################################
# Diagnostics
#
diagnostics.diags_names = diag1 openPMDh5

diag1.period = 100
diag1.diag_type = Full
diag1.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho
diag1.electrons.variables = w ux uy uz rho
diag1.hydrogen.variables = w ux uy uz rho

openPMDh5.period = 100
openPMDh5.diag_type = Full
openPMDh5.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho
openPMDh5.electrons.variables = w ux uy uz rho
openPMDh5.hydrogen.variables = w ux uy uz rho
openPMDh5.format = openpmd
openPMDh5.openpmd_backend = h5


#################################
# Physical Background
#
# This example is modeled after a target similar to the hydrogen jet here:
#   [1] https://doi.org/10.1038/s41598-017-10589-3
#   [2] https://arxiv.org/abs/1903.06428
#
authors = "Axel Huebl <axelhuebl@lbl.gov>"
