cartesian_from_spherical Subroutine

public pure subroutine cartesian_from_spherical(r, theta, phi, xo, yo, zo, x, y, z, a_y, a_z)

Uses

    • constants
  • proc~~cartesian_from_spherical~~UsesGraph proc~cartesian_from_spherical cartesian_from_spherical constants constants proc~cartesian_from_spherical->constants

Compute the Cartesian coordinates of a points , starting from the spherical, or optionally elliptical, polar coordinates of the point relative to a point

FT 28.11.2022


Arguments

Type IntentOptional Attributes Name
double precision, intent(in) :: r

coordinate of the point , relative to

double precision, intent(in) :: theta

coordinate (colatitude) of the point , relative to

double precision, intent(in) :: phi

coordinate (azimuth) of the point , relative to

double precision, intent(in) :: xo

coordinate of the point

double precision, intent(in) :: yo

coordinate of the point

double precision, intent(in) :: zo

coordinate of the point

double precision, intent(out) :: x

coordinate of the point

double precision, intent(out) :: y

coordinate of the point

double precision, intent(out) :: z

coordinate of the point

double precision, intent(in), optional :: a_y

Ratio between the y and x semiaxes of the ellipse

double precision, intent(in), optional :: a_z

Ratio between the z and x semiaxes of the ellipse


Called by

proc~~cartesian_from_spherical~~CalledByGraph proc~cartesian_from_spherical cartesian_from_spherical none~place_and_print_ghost_particles place_and_print_ghost_particles none~place_and_print_ghost_particles->proc~cartesian_from_spherical proc~find_surface find_surface proc~find_surface->proc~cartesian_from_spherical proc~integrate_baryon_mass_density integrate_baryon_mass_density proc~integrate_baryon_mass_density->proc~cartesian_from_spherical proc~perform_apm perform_apm proc~perform_apm->proc~cartesian_from_spherical proc~perform_apm->none~place_and_print_ghost_particles proc~place_particles_ellipsoidal_surfaces place_particles_ellipsoidal_surfaces proc~place_particles_ellipsoidal_surfaces->proc~cartesian_from_spherical interface~find_surface find_surface interface~find_surface->proc~find_surface interface~integrate_baryon_mass_density integrate_baryon_mass_density interface~integrate_baryon_mass_density->proc~integrate_baryon_mass_density interface~perform_apm perform_apm interface~perform_apm->proc~perform_apm interface~place_particles_ellipsoidal_surfaces place_particles_ellipsoidal_surfaces interface~place_particles_ellipsoidal_surfaces->proc~place_particles_ellipsoidal_surfaces proc~construct_particles_std construct_particles_std proc~construct_particles_std->interface~perform_apm interface~construct_particles_std construct_particles_std interface~construct_particles_std->proc~construct_particles_std interface~particles particles interface~particles->interface~construct_particles_std program~convergence_test convergence_test program~convergence_test->interface~particles program~sphincs_id sphincs_id program~sphincs_id->interface~particles

Contents


Variables

Type Visibility Attributes Name Initial
double precision, public :: ay
double precision, public :: az

Source Code

  PURE SUBROUTINE cartesian_from_spherical &
    ( r, theta, phi, xo, yo, zo, x, y, z, a_y, a_z )

    !****************************************************************
    !
    !# Compute the Cartesian coordinates of a points \(p\),
    !  starting from the spherical, or optionally elliptical, polar
    !  coordinates of the point \(p\) relative to a point \(O\)
    !
    !  FT 28.11.2022
    !
    !****************************************************************

    USE constants, ONLY: pi

    IMPLICIT NONE

    DOUBLE PRECISION, INTENT(IN):: r
    !! \(r\) coordinate of the point \(p\), relative to \(O\)
    DOUBLE PRECISION, INTENT(IN):: theta
    !! \(\theta\) coordinate (colatitude) of the point \(p\), relative to \(O\)
    DOUBLE PRECISION, INTENT(IN):: phi
    !! \(\phi\) coordinate (azimuth) of the point \(p\), relative to \(O\)

    DOUBLE PRECISION, INTENT(IN):: xo
    !! \(x\) coordinate of the point \(O\)
    DOUBLE PRECISION, INTENT(IN):: yo
    !! \(y\) coordinate of the point \(O\)
    DOUBLE PRECISION, INTENT(IN):: zo
    !! \(z\) coordinate of the point \(O\)

    DOUBLE PRECISION, INTENT(OUT):: x
    !! \(x\) coordinate of the point \(p\)
    DOUBLE PRECISION, INTENT(OUT):: y
    !! \(y\) coordinate of the point \(p\)
    DOUBLE PRECISION, INTENT(OUT):: z
    !! \(z\) coordinate of the point \(p\)

    DOUBLE PRECISION, INTENT(IN), OPTIONAL:: a_y
    !! Ratio between the y and x semiaxes of the ellipse
    DOUBLE PRECISION, INTENT(IN), OPTIONAL:: a_z
    !! Ratio between the z and x semiaxes of the ellipse

    DOUBLE PRECISION:: ay, az

    IF(PRESENT(a_y))THEN
      ay= a_y
    ELSE
      ay= one
    ENDIF
    IF(PRESENT(a_z))THEN
      az= a_z
    ELSE
      az= one
    ENDIF

    x= xo +    r*SIN(theta)*COS(phi)
    y= yo + ay*r*SIN(theta)*SIN(phi)
    z= zo + az*r*COS(theta)

  END SUBROUTINE cartesian_from_spherical