Skip to content

Commit

Permalink
-Add new input deck option 'two_stream_neutral' that is an explicitly…
Browse files Browse the repository at this point in the history
… quasineutral version of the two_stream deck.

-The usual momentum conservation relation is only valid if the plasma is quasineutral (because the implied neutralising species would gain/lose significant momentum)

-Now momentum conservation seems to be working as expected.
  • Loading branch information
benmcmillanwarwick committed Feb 11, 2022
1 parent 77775da commit 6e59514
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
3 changes: 3 additions & 0 deletions example_decks/two_stream_neutral.deck
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
&control
problem = 'two_stream_neutral'
/
162 changes: 162 additions & 0 deletions src/user_interaction/ic_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ SUBROUTINE custom_problem_setup(deck_state, problem)
SELECT CASE (TRIM(problem))
CASE('two_stream')
CALL two_stream_setup(deck_state)
CASE('two_stream_neutral')
CALL two_stream_neutral_setup(deck_state)
CASE('one_stream')
CALL one_stream_setup(deck_state)
CASE('drift_kin_default')
Expand Down Expand Up @@ -164,6 +166,166 @@ SUBROUTINE two_stream_setup(deck_state)

END SUBROUTINE two_stream_setup

SUBROUTINE two_stream_neutral_setup(deck_state)

INTEGER, INTENT(IN) :: deck_state
REAL(num), PARAMETER :: v_drift = 0.2_num * c
REAL(num), PARAMETER :: v_therm = 0.01_num * c
REAL(num), PARAMETER :: v_pert = 0.1_num * v_therm
REAL(num), PARAMETER :: n0 = 8e11
INTEGER, PARAMETER :: ppc = 16
REAL(num) :: gamma_drift, temp_x, omega
INTEGER :: ix
TYPE(particle_species), POINTER :: current_species

IF (deck_state == c_ds_first) THEN
! Set control variables here
nx_global = 64
ny_global = 4
nz_global = 4
x_min = 0.0_num
x_max = 2.0_num * pi
y_min = x_min
! Could do (x_max * ny_global) / nx_global, but be wary of compilers
! which don't obey precedence implied by parentheses by default
! (e.g. Intel)
y_max = x_max * REAL(ny_global, num) / REAL(nx_global, num)
z_min = x_min
z_max = x_max * REAL(nz_global, num) / REAL(nx_global, num)

! Plasma frequency
omega = SQRT(n0 * q0 * q0 / epsilon0 / m0)
t_end = 30.0_num / omega
stdout_frequency = 10

! dt_multiplier = 0.5


! Need to set-up species here
NULLIFY(current_species)
CALL setup_species(current_species, 'Right')

! mass -- MANDATORY
current_species%mass = 1.1_num * m0

! charge -- MANDATORY
current_species%charge = -1.0_num * q0

! npart_per_cell
current_species%npart_per_cell = ppc

! MANDATORY
NULLIFY(current_species)
CALL setup_species(current_species, 'Left')

! mass -- MANDATORY
current_species%mass = 1.0_num * m0

! charge -- MANDATORY
current_species%charge = -1.0_num * q0

! npart_per_cell
current_species%npart_per_cell = ppc

NULLIFY(current_species)
CALL setup_species(current_species, 'Balance')

! mass -- MANDATORY
current_species%mass = 100 * m0

! charge -- MANDATORY
current_species%charge = 1.0_num * q0

! npart_per_cell
current_species%npart_per_cell = ppc

RETURN
END IF

! Calculate gamma_drift
! Strictly should be function of x, but vpert << vdrift
gamma_drift = 1.0_num / SQRT(1.0_num - (v_drift / c)**2)

! Calculate (1 DoF) temperature
temp_x = v_therm**2 * m0 / kb

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! Species

! MANDATORY (Is the NULLIFY mandatory?)
NULLIFY(current_species)
CALL setup_species(current_species, 'Right')

! density
current_species%density = n0

! drift_x
! Add on perturbation to seed instability
DO ix = 1-ng, nx+ng
current_species%drift(ix,:,:,1) = gamma_drift * current_species%mass &
* (v_drift + v_pert * SIN(3.0_num * x(ix)))
END DO

! temp_x
current_species%temp(:,:,:,1) = temp_x

IF (explicit_pic) THEN
current_species%is_implicit = .FALSE.
ELSE
current_species%is_implicit = .TRUE.
END IF

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! MANDATORY
NULLIFY(current_species)
CALL setup_species(current_species, 'Left')

! density
current_species%density = n0

! drift_x
! Add on perturbation to seed instability
DO ix = 1-ng, nx+ng
current_species%drift(ix,:,:,1) = gamma_drift * current_species%mass &
* (-v_drift + v_pert * SIN(3.0_num * x(ix)))
END DO

! temp_x
current_species%temp(:,:,:,1) = temp_x

IF (explicit_pic) THEN
current_species%is_implicit = .FALSE.
ELSE
current_species%is_implicit = .TRUE.
END IF

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! MANDATORY
NULLIFY(current_species)
CALL setup_species(current_species, 'Balance')

! density
current_species%density = 2.0_num * n0

! drift_x
DO ix = 1-ng, nx+ng
current_species%drift(ix,:,:,1) = 0.0_num
END DO

! temp_x
current_species%temp(:,:,:,1) = temp_x

IF (explicit_pic) THEN
current_species%is_implicit = .FALSE.
ELSE
current_species%is_implicit = .TRUE.
END IF


END SUBROUTINE two_stream_neutral_setup


SUBROUTINE em_wave_setup(deck_state)
Expand Down

0 comments on commit 6e59514

Please sign in to comment.