17 subroutine getlqgrid(lQgrid,ixI^L,ixO^L,qt,trelax,tramp,x,ntimes,vlim^D)
20 integer,
intent(in) :: ixI^L, ixO^L, ntimes, vlim^D
21 double precision,
intent(in) :: qt, trelax, tramp,x(ixI^S,1:ndim)
22 double precision,
intent(inout) :: lQgrid(ixI^S)
24 double precision :: xcar(ixI^S,1:ndim)
25 double precision :: tshift,tr,stt^D,xcarmin^D
26 double precision :: tl1,tl2,tl3,tl4,tl5,tl6
27 double precision :: pulse1,pulse2,pulse3,pulse4,pulse5,pulse6
28 integer :: iip^D,ix^D,i
32 if(qt .lt. trelax)
then
34 elseif(qt .lt. trelax+tramp)
then
49 {
do ix^db = ixomin^db,ixomax^db\}
53 ^d&stt^d=(xprobmax^d-xprobmin^d)/(dble(vlim^d)-1.d0);
54 ^d&iip^d=floor((x(ix^dd,^d)-xprobmin^d)/stt^d)+1;
55 ^d&iip^d=max(1,iip^d);
58 call mpistop(
"random_heating_3D to be adjusted for 2D cylindrical")
62 xcar(ix1,ix2,ix3,1)=x(ix1,ix2,ix3,
r_)*dcos(x(ix1,ix2,ix3,
phi_))
63 xcar(ix1,ix2,ix3,2)=x(ix1,ix2,ix3,
r_)*dsin(x(ix1,ix2,ix3,
phi_))
64 xcar(ix1,ix2,ix3,3)=x(ix1,ix2,ix3,
z_)
70 stt1=(2.0d0*xprobmax1)/(dble(vlim1)-1.d0)
72 stt2=(2.0d0*xprobmax1)/(dble(vlim2)-1.d0)
74 stt3=(xprobmax2-xprobmin2)/(dble(vlim3)-1.d0)
76 ^d&iip^d=floor((xcar(ix^dd,^d)-xcarmin^d)/stt^d)+1;
77 ^d&iip^d=max(1,iip^d);
79 call mpistop(
"random_heating_3D to be adjusted for this geometry")
81 call mpistop(
"random_heating_3D to be adjusted for this geometry")
83 pulse1=(^d&
va^d(iip^d+(i-4)*vlim^d)|*)
84 pulse2=(^d&
va^d(iip^d+(i-3)*vlim^d)|*)
85 pulse3=(^d&
va^d(iip^d+(i-2)*vlim^d)|*)
86 pulse4=(^d&
va^d(iip^d+(i-1)*vlim^d)|*)
87 pulse5=(^d&
va^d(iip^d+(i)*vlim^d)|*)
88 pulse6=(^d&
va^d(iip^d+(i+1)*vlim^d)|*)
89 lqgrid(ix^d) = tl1 * pulse1 + tl2 *pulse2 &
90 +tl3 * pulse3 + tl4 *pulse4 &
91 +tl5 * pulse5 + tl6 *pulse6
97 lqgrid(ixo^s)=tr*lqgrid(ixo^s)
101 subroutine generatetv(ntimes,vlim^D,periods,variation,nwaves,si)
102 integer,
intent(in) :: ntimes,vlim^D,nwaves
103 double precision,
intent(in) :: periods,variation,si
118 call mpi_barrier(icomm,ierrmpi)
120 call mpi_bcast(
timearray,ntimes,mpi_double_precision,0,icomm,ierrmpi)
121 call mpi_bcast(
dtimearr,ntimes,mpi_double_precision,0,icomm,ierrmpi)
130 call randomv(^d,
va^d,ntimes,vlim^d,nwaves,si)
132 call mpi_barrier(icomm,ierrmpi)
134 call mpi_bcast(
va^d,vx^d,mpi_double_precision,0,icomm,ierrmpi)
140 subroutine randomt(tb,ntimes,periods,variation)
141 integer,
intent(in) :: ntimes
142 double precision,
intent(in) :: periods,variation
143 double precision,
intent(inout) :: tb(:)
145 character(len=100) :: filename
146 double precision :: tt1,tt,mm
151 call random_number(mm)
152 tt1 = periods + variation * 2. * (mm - 0.5)
154 tb(i) = tt / unit_time
157 write(filename,
"(a)")
"randomtimes.dat"
158 open(unit=21,file=filename,form=
'formatted',status=
'replace')
159 write(21,
'(es12.4)') tb
164 subroutine randomv(ival,va,ntimes,vlim,nwaves,si)
165 integer,
intent(in) :: ival,ntimes,vlim,nwaves
166 double precision,
intent(in) :: si
167 double precision,
intent(inout) :: va(:)
169 character(len=100) :: filename
170 character(len=10) :: xdirection
172 double precision,
allocatable :: vn(:,:),vm(:)
173 double precision :: lambda,ampl,lambda_min,lambda_max,rms,phase
176 allocate(vn(nwaves, vlim))
178 lambda_min = 1.d0/dble(vlim)
182 lambda = (dble(i-1)/dble(nwaves-1))*(lambda_max-lambda_min)+lambda_min
184 call random_number(phase)
186 phase=4.0d0*dpi*(phase-0.5d0)
188 vn(i,j) = ampl*dsin(2.d0*dpi*(dble(j-1)/dble(vlim-1))/lambda+phase)
196 vm(j) = vm(j) + vn(i, j)
200 vm = vm / dsqrt(rms/vlim)
202 va(vlim*(kk-1)+j) = vm(j)**2
206 write(xdirection,
'(I2.2)') ival
207 write(filename,
"(a)")
"randompositions"//trim(xdirection)//
".dat"
208 open(unit=22,file=filename,form=
'formatted',status=
'replace')
209 write(22,
'(es12.4)') va