From e8366aac7401ec3b9343a0288cbae2e9f08882db Mon Sep 17 00:00:00 2001 From: Grzegorz Kowal Date: Wed, 18 Aug 2021 14:28:46 -0300 Subject: [PATCH] USER_PROBLEM: Make the perturbation periodic if zlen /= xlen. Signed-off-by: Grzegorz Kowal --- sources/user_problem.F90 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sources/user_problem.F90 b/sources/user_problem.F90 index e9f3e05..8dc3c3d 100644 --- a/sources/user_problem.F90 +++ b/sources/user_problem.F90 @@ -110,7 +110,7 @@ module user_problem use constants , only : pi #endif /* NDIMS == 3 */ use constants , only : pi2 - use coordinates, only : ng => nghosts, ady + use coordinates, only : ng => nghosts, ady, xlen, zlen use equations , only : magnetized, csnd, csnd2 use helpers , only : print_section, print_parameter use parameters , only : get_parameter @@ -129,7 +129,7 @@ module user_problem ! local variables ! character(len=64) :: perturbation = "noise" - integer :: n + integer :: n, kd real(kind=8) :: thh, fc, ka #if NDIMS == 3 real(kind=8) :: thv, tx, ty, tz, tt @@ -299,6 +299,7 @@ module user_problem ! choose random wave vector directions ! + kd = int(xlen / zlen) fc = 1.0d+00 / sqrt(1.0d+00 * nper) do n = 1, nper thh = pi2 * randuni() @@ -309,7 +310,7 @@ module user_problem tz = sin(thv) kx(n) = pi2 * nint(kper * tx) ky(n) = pi2 * nint(kper * ty) - kz(n) = pi2 * nint(kper * tz) + kz(n) = pi2 * nint(kper * tz / kd) * kd tt = 0.0d+00 do while(tt < 1.0d-08) thh = pi2 * randuni()