diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index f08e8eb05..1ee3bdf80 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -775,6 +775,19 @@ module pure subroutine orbel_xv2aqt(mu, x, v, a, q, capm, tperi) real(DP), intent(out) :: tperi !! time of pericenter passage end subroutine orbel_xv2aqt + module pure subroutine orbel_xv2el(mu, x, v, a, e, inc, capom, omega, capm) + implicit none + real(DP), intent(in) :: mu !! Gravitational constant + real(DP), dimension(:), intent(in) :: x !! Position vector + real(DP), dimension(:), intent(in) :: v !! Velocity vector + real(DP), intent(out) :: a !! semimajor axis + real(DP), intent(out) :: e !! eccentricity + real(DP), intent(out) :: inc !! inclination + real(DP), intent(out) :: capom !! longitude of ascending node + real(DP), intent(out) :: omega !! argument of periapsis + real(DP), intent(out) :: capm !! mean anomaly + end subroutine orbel_xv2el + module subroutine orbel_xv2el_vec(self, cb) implicit none class(swiftest_body), intent(inout) :: self !! Swiftest body object diff --git a/src/orbel/orbel.f90 b/src/orbel/orbel.f90 index f1ab88825..c07200b14 100644 --- a/src/orbel/orbel.f90 +++ b/src/orbel/orbel.f90 @@ -890,7 +890,7 @@ module subroutine orbel_xv2el_vec(self, cb) end do end subroutine orbel_xv2el_vec - pure subroutine orbel_xv2el(mu, x, v, a, e, inc, capom, omega, capm) + module pure subroutine orbel_xv2el(mu, x, v, a, e, inc, capom, omega, capm) !! author: David A. Minton !! !! Compute osculating orbital elements from relative Cartesian position and velocity @@ -906,9 +906,17 @@ pure subroutine orbel_xv2el(mu, x, v, a, e, inc, capom, omega, capm) !! Adapted from David E. Kaufmann's Swifter routine: orbel_xv2el.f90 !! Adapted from Martin Duncan's Swift routine orbel_xv2el.f implicit none - real(DP), intent(in) :: mu - real(DP), dimension(:), intent(in) :: x, v - real(DP), intent(out) :: a, e, inc, capom, omega, capm + ! Arguments + real(DP), intent(in) :: mu !! Gravitational constant + real(DP), dimension(:), intent(in) :: x !! Position vector + real(DP), dimension(:), intent(in) :: v !! Velocity vector + real(DP), intent(out) :: a !! semimajor axis + real(DP), intent(out) :: e !! eccentricity + real(DP), intent(out) :: inc !! inclination + real(DP), intent(out) :: capom !! longitude of ascending node + real(DP), intent(out) :: omega !! argument of periapsis + real(DP), intent(out) :: capm !! mean anomaly + ! Internals integer(I4B) :: iorbit_type real(DP) :: r, v2, h2, h, rdotv, energy, fac, u, w, cw, sw, face, cape, tmpf, capf real(DP), dimension(NDIM) :: hvec diff --git a/src/python/orbel.f90 b/src/python/orbel.f90 new file mode 100644 index 000000000..4dd26a68d --- /dev/null +++ b/src/python/orbel.f90 @@ -0,0 +1,32 @@ +module orbel + use swiftest + private + public :: xv2el +contains + pure elemental subroutine xv2el(mu, px, py, pz, vx, vy, vz, a, e, inc, capom, omega, capm) + use module_interfaces, only : orbel_xv2el + implicit none + ! Arguments + real*8, intent(in) :: mu, px, py, pz, vx, vy, vz + real*8, intent(out) :: a, e, inc, capom, omega, capm + !$f2py intent(in) mu + !$f2py intent(in) px + !$f2py intent(in) py + !$f2py intent(in) pz + !$f2py intent(in) vx + !$f2py intent(in) vy + !$f2py intent(in) vz + !$f2py intent(out) a + !$f2py intent(out) e + !$f2py intent(out) inc + !$f2py intent(out) capom + !$f2py intent(out) omega + !$f2py intent(out) capm + ! Internals + real*8, dimension(3) :: x, v + x = [px, py, pz] + v = [vx, vy, vz] + call orbel_xv2el(x, v, mu, a, e, inc, capom, omega, capm) + return + end subroutine xv2el +end module orbel \ No newline at end of file