Convert to noncartesian coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| double precision, | intent(out) | :: | xp(1:3) | |||
| double precision, | intent(in) | :: | xpcart(1:3) |
subroutine partcoord_from_cartesian(xp,xpcart) ! conversion of particle coordinate from Cartesian to cylindrical/spherical coordinates done here use mod_global_parameters use mod_geometry double precision, intent(in) :: xpcart(1:3) double precision, intent(out) :: xp(1:3) double precision :: xx, yy, zz double precision :: rr, tth, pphi select case (coordinate) case (Cartesian,Cartesian_stretched,Cartesian_expansion) xp(1:3)=xpcart(1:3) case (cylindrical) xp(r_) = sqrt(xpcart(1)**2 + xpcart(2)**2) xp(phi_) = atan2(xpcart(2),xpcart(1)) if (xp(phi_) .lt. 0.d0) xp(phi_) = 2.0d0*dpi + xp(phi_) xp(z_) = xpcart(3) case (spherical) xx = xpcart(1) yy = xpcart(2) zz = xpcart(3) rr = sqrt(xx**2 + yy**2 + zz**2) tth = acos(zz/rr) if (yy > 0.d0) then pphi = acos(xx/sqrt(xx**2+yy**2)) else pphi = 2.d0*dpi - acos(xx/sqrt(xx**2+yy**2)) endif xp(1:3) = (/ rr, tth, pphi /) case default write(*,*) "No converter for coordinate=",coordinate end select end subroutine partcoord_from_cartesian