Implement Keplerian orbit for the satellite in binaries problem.
- now the satellite changes positions and velocity accordind to Keplers laws; correct Keplerian orbit has been implemented in shape_binaries(); - correct initialization of the satellite in init_binaries();
This commit is contained in:
parent
68a39a28e4
commit
e68a189916
180
src/problem.F90
180
src/problem.F90
@ -709,7 +709,7 @@ module problem
|
|||||||
use config , only : im, jm, km
|
use config , only : im, jm, km
|
||||||
use config , only : dens, pres, csnd2, gamma
|
use config , only : dens, pres, csnd2, gamma
|
||||||
use config , only : dnfac, dnrat
|
use config , only : dnfac, dnrat
|
||||||
use config , only : rstar, vstar, rsat, dsat, vsat, tsat
|
use config , only : rstar, vstar, rsat, dsat, vsat, tsat, esat
|
||||||
use constants, only : dpi
|
use constants, only : dpi
|
||||||
use coords , only : ax, ay, az, adr
|
use coords , only : ax, ay, az, adr
|
||||||
use scheme , only : prim2cons
|
use scheme , only : prim2cons
|
||||||
@ -731,14 +731,14 @@ module problem
|
|||||||
|
|
||||||
! local variables
|
! local variables
|
||||||
!
|
!
|
||||||
integer :: i, j, k
|
integer :: i, j, k
|
||||||
real :: dr
|
real :: dr, rc, rs, xs, ys
|
||||||
real :: dnamb, pramb
|
real :: om = 0.0d0, sn = 0.0d0, cs = 1.0d0
|
||||||
real :: dnstar, prstar, vrstar, rc
|
real, save :: dnamb, pramb
|
||||||
real :: dnsat , prsat , vrsat , rs, xs, ys
|
real, save :: dnstar, prstar, vrstar
|
||||||
real :: om = 0.0d0, sn = 0.0d0, cs = 1.0d0
|
real, save :: dnsat , prsat , vrsat
|
||||||
real :: asat, bsat, xsat
|
real, save :: asat, bsat, xsat = - 1.0d0
|
||||||
real :: xsh, ysh, xvl, yvl
|
real, save :: xsh, ysh, xvl, yvl
|
||||||
|
|
||||||
! local arrays
|
! local arrays
|
||||||
!
|
!
|
||||||
@ -749,32 +749,50 @@ module problem
|
|||||||
!
|
!
|
||||||
!-------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
|
! calculate the interior and orbit parameters only once
|
||||||
|
!
|
||||||
|
if (xsat .le. 0.0d0) then
|
||||||
|
|
||||||
! calculate pressure from sound speed
|
! calculate pressure from sound speed
|
||||||
!
|
!
|
||||||
#ifdef ISO
|
#ifdef ISO
|
||||||
pres = csnd2 * dens
|
pres = csnd2 * dens
|
||||||
#endif /* ISO */
|
#endif /* ISO */
|
||||||
#ifdef ADI
|
#ifdef ADI
|
||||||
pres = csnd2 * dens / gamma
|
pres = csnd2 * dens / gamma
|
||||||
#endif /* ADI */
|
#endif /* ADI */
|
||||||
|
|
||||||
! calculate parameters
|
! calculate star interior parameters
|
||||||
!
|
!
|
||||||
dnamb = dens
|
dnamb = dens
|
||||||
pramb = pres
|
pramb = pres
|
||||||
dnstar = dnamb * dnfac * dnrat
|
dnstar = dnamb * dnfac * dnrat
|
||||||
dnsat = dnamb * dnfac
|
dnsat = dnamb * dnfac
|
||||||
prstar = pramb * dnfac
|
prstar = pramb * dnfac
|
||||||
prsat = pramb * dnfac / dnrat
|
prsat = pramb * dnfac / dnrat
|
||||||
vrstar = vstar / rstar
|
vrstar = vstar / rstar
|
||||||
vrsat = vsat / rsat
|
vrsat = vsat / rsat
|
||||||
if (tsat .gt. 0.0d0) then
|
|
||||||
om = dpi / tsat
|
! calculate orbit parameters
|
||||||
sn = 0.0d0
|
!
|
||||||
cs = 1.0d0
|
asat = dsat / (1.0d0 - esat)
|
||||||
|
xsat = asat * esat
|
||||||
|
bsat = sqrt(asat * asat - xsat * xsat)
|
||||||
|
|
||||||
|
! angular speed and triginometric functions
|
||||||
|
!
|
||||||
|
om = dpi / tsat
|
||||||
|
sn = 0.0d0
|
||||||
|
cs = 1.0d0
|
||||||
|
|
||||||
|
! calculate satellite initial position and speed
|
||||||
|
!
|
||||||
|
xsh = asat * cs - xsat
|
||||||
|
ysh = bsat * sn
|
||||||
|
xvl = - asat * sn * om
|
||||||
|
yvl = bsat * cs * om
|
||||||
|
|
||||||
end if
|
end if
|
||||||
xvl = - asat * om * sn
|
|
||||||
yvl = bsat * om * cs
|
|
||||||
|
|
||||||
! obtain the diagonal size of a cell at the current level
|
! obtain the diagonal size of a cell at the current level
|
||||||
!
|
!
|
||||||
@ -1385,20 +1403,23 @@ module problem
|
|||||||
|
|
||||||
! local variables
|
! local variables
|
||||||
!
|
!
|
||||||
integer :: i, j, k
|
integer :: i, j, k
|
||||||
real :: dr
|
real :: dr, rs, xs, ys, rc
|
||||||
real :: dnamb, pramb
|
real :: om = 0.0d0, sn = 0.0d0, cs = 1.0d0
|
||||||
real :: dnstar, vrstar, prstar, rc
|
real :: rhs, res
|
||||||
real :: dnsat , vrsat , prsat , rs, xs, ys
|
real, save :: dnamb, pramb
|
||||||
|
real, save :: dnstar, vrstar, prstar
|
||||||
|
real, save :: dnsat , vrsat , prsat
|
||||||
#ifdef ADI
|
#ifdef ADI
|
||||||
real :: ekin, ekstar, eksat
|
real, save :: ekstar, eksat
|
||||||
|
real :: ekin
|
||||||
#ifdef MHD
|
#ifdef MHD
|
||||||
real :: emag
|
real :: emag
|
||||||
#endif /* MHD */
|
#endif /* MHD */
|
||||||
#endif /* ADI */
|
#endif /* ADI */
|
||||||
real :: om = 0.0d0, ang = 0.0d0, sn = 0.0d0, cs = 1.0d0
|
real, save :: asat, bsat, xsat = -1.0d0
|
||||||
real :: asat, bsat, xsat
|
real, save :: xsh, ysh, xvl, yvl
|
||||||
real :: xsh, ysh, xvl, yvl
|
real, save :: tpre = -1.0d0, ang = 0.0d0
|
||||||
|
|
||||||
! local arrays
|
! local arrays
|
||||||
!
|
!
|
||||||
@ -1408,39 +1429,76 @@ module problem
|
|||||||
!
|
!
|
||||||
!-------------------------------------------------------------------------------
|
!-------------------------------------------------------------------------------
|
||||||
!
|
!
|
||||||
! calculate parameters
|
! calculate the star and satellite orbit parameters only once
|
||||||
|
!
|
||||||
|
if (xsat .lt. 0.0d0) then
|
||||||
|
|
||||||
|
! calculate parameters for the star interiors
|
||||||
!
|
!
|
||||||
#ifdef ISO
|
#ifdef ISO
|
||||||
pres = csnd2 * dens
|
pres = csnd2 * dens
|
||||||
#endif /* ISO */
|
#endif /* ISO */
|
||||||
#ifdef ADI
|
#ifdef ADI
|
||||||
pres = csnd2 * dens / gamma
|
pres = csnd2 * dens / gamma
|
||||||
#endif /* ADI */
|
#endif /* ADI */
|
||||||
dnamb = dens
|
dnamb = dens
|
||||||
pramb = pres
|
pramb = pres
|
||||||
dnstar = dnamb * dnfac * dnrat
|
dnstar = dnamb * dnfac * dnrat
|
||||||
dnsat = dnamb * dnfac
|
dnsat = dnamb * dnfac
|
||||||
prstar = pramb * dnfac
|
prstar = pramb * dnfac
|
||||||
prsat = pramb * dnfac / dnrat
|
prsat = pramb * dnfac / dnrat
|
||||||
vrstar = vstar / rstar
|
vrstar = vstar / rstar
|
||||||
vrsat = vsat / rsat
|
vrsat = vsat / rsat
|
||||||
#ifdef ADI
|
#ifdef ADI
|
||||||
ekstar = 0.5d0 * dnstar * vstar * vstar
|
ekstar = 0.5d0 * dnstar * vstar * vstar
|
||||||
eksat = 0.5d0 * dnsat * vsat * vsat
|
eksat = 0.5d0 * dnsat * vsat * vsat
|
||||||
#endif /* ADI */
|
#endif /* ADI */
|
||||||
if (tsat .gt. 0.0d0) then
|
|
||||||
om = dpi / tsat
|
! calculate orbit parameters
|
||||||
ang = om * t
|
!
|
||||||
sn = sin(ang)
|
asat = dsat / (1.0d0 - esat)
|
||||||
cs = cos(ang)
|
xsat = asat * esat
|
||||||
|
bsat = sqrt(asat * asat - xsat * xsat)
|
||||||
|
|
||||||
|
end if
|
||||||
|
|
||||||
|
! recalculate the angles and coordinates
|
||||||
|
!
|
||||||
|
if (t .gt. tpre) then
|
||||||
|
|
||||||
|
! calculate the new value of eccentric anomaly
|
||||||
|
!
|
||||||
|
rhs = dpi * t / tsat
|
||||||
|
res = 1.0d0
|
||||||
|
i = 1
|
||||||
|
do while(res .ge. 1.0e-14 .and. i .le. 1000)
|
||||||
|
sn = esat * sin(ang)
|
||||||
|
ang = rhs + sn
|
||||||
|
res = abs((ang - sn) - rhs)
|
||||||
|
i = i + 1
|
||||||
|
end do
|
||||||
|
|
||||||
|
! calculate trigonometric functions
|
||||||
|
!
|
||||||
|
sn = sin(ang)
|
||||||
|
cs = cos(ang)
|
||||||
|
|
||||||
|
! calculate the angular velocity
|
||||||
|
!
|
||||||
|
om = dpi / tsat / (1.0d0 - esat * cs)
|
||||||
|
|
||||||
|
! calculate position coordinates and velocity components
|
||||||
|
!
|
||||||
|
xsh = asat * cs - xsat
|
||||||
|
ysh = bsat * sn
|
||||||
|
xvl = - asat * sn * om
|
||||||
|
yvl = bsat * cs * om
|
||||||
|
|
||||||
|
! substitute the previous time
|
||||||
|
!
|
||||||
|
tpre = t
|
||||||
|
|
||||||
end if
|
end if
|
||||||
asat = dsat / (1.0d0 - esat)
|
|
||||||
xsat = asat * esat
|
|
||||||
bsat = sqrt(asat * asat - xsat * xsat)
|
|
||||||
xsh = asat * cs - xsat
|
|
||||||
ysh = bsat * sn
|
|
||||||
xvl = - asat * om * sn
|
|
||||||
yvl = bsat * om * cs
|
|
||||||
|
|
||||||
! obtain the diagonal size of a cell at the current level
|
! obtain the diagonal size of a cell at the current level
|
||||||
!
|
!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user