Skip to content

Commit 4b74532

Browse files
haocheyhenryleberre
authored andcommitted
Add support for cylindrical to monopoles
1 parent d80602a commit 4b74532

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/simulation/m_monopole.f90

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ subroutine s_monopole_calculations(mono_mass_src, mono_mom_src, mono_e_src, q_c
217217
if (support(q) == 5) then
218218
mono_mom_src(1, j, k, l) = mono_mom_src(1, j, k, l) + s2*cos(angle)
219219
mono_mom_src(2, j, k, l) = mono_mom_src(2, j, k, l) + s2*sin(angle)
220+
else if (support(q) == 6) then
221+
! Cylindrical Coordinate
222+
mono_mom_src(1, j, k, l) = mono_mom_src(1, j, k, l) + s2*cos(dir(q))
223+
mono_mom_src(2, j, k, l) = mono_mom_src(2, j, k, l)
220224
else
221225
mono_mom_src(1, j, k, l) = mono_mom_src(1, j, k, l) + s2*cos(dir(q))
222226
mono_mom_src(2, j, k, l) = mono_mom_src(2, j, k, l) + s2*sin(dir(q))
@@ -318,7 +322,9 @@ function f_delta(j, k, l, mono_loc, mono_leng, nm, angle, angle_z)
318322

319323
integer :: q
320324
real(kind(0d0)) :: h, hx, hy, hz
325+
real(kind(0d0)) :: hx_cyl, hy_cyl, hz_cyl
321326
real(kind(0d0)) :: hxnew, hynew
327+
real(kind(0d0)) :: hxnew_cyl, hynew_cyl
322328
real(kind(0d0)) :: sig
323329
real(kind(0d0)) :: f_delta
324330
real(kind(0d0)) :: angle
@@ -436,6 +442,27 @@ function f_delta(j, k, l, mono_loc, mono_leng, nm, angle, angle_z)
436442
else
437443
f_delta = 0d0
438444
end if
445+
else if (support(nm) == 6) then
446+
! Support for cylindrical coordinate system
447+
!sig = maxval((/dx(j), dy(k)*sin(dz(l)), dz(l)*cos(dz(l))/))
448+
sig = dx(j)
449+
sig = sig*2.5d0
450+
hx_cyl = x_cc(j) - mono_loc(1)
451+
hy_cyl = y_cc(k)*sin(z_cc(l)) - mono_loc(2)
452+
hz_cyl = y_cc(k)*cos(z_cc(l)) - mono_loc(3)
453+
454+
! Rotate actual point by -theta
455+
hxnew_cyl = cos(dir(nm))*hx_cyl + sin(dir(nm))*hy_cyl
456+
hynew_cyl = -1.d0*sin(dir(nm))*hx_cyl + cos(dir(nm))*hy_cyl
457+
458+
if (abs(hynew_cyl) < length(nm)/2. .and. &
459+
abs(hz_cyl) < length(nm)/2.) then
460+
f_delta = 1.d0/(dsqrt(2.d0*pi)*sig/2.d0)* &
461+
dexp(-0.5d0*(hxnew_cyl/(sig/2.d0))**2.d0)
462+
else
463+
f_delta = 0d0
464+
end if
465+
439466
end if
440467
end if
441468

0 commit comments

Comments
 (0)