| 1 |
!----------------------------------------------------------------- |
| 2 |
! |
| 3 |
! This file is (or was) part of SPLASH, a visualisation tool |
| 4 |
! for Smoothed Particle Hydrodynamics written by Daniel Price: |
| 5 |
! |
| 6 |
! http://users.monash.edu.au/~dprice/splash |
| 7 |
! |
| 8 |
! SPLASH comes with ABSOLUTELY NO WARRANTY. |
| 9 |
! This is free software; and you are welcome to redistribute |
| 10 |
! it under the terms of the GNU General Public License |
| 11 |
! (see LICENSE file for details) and the provision that |
| 12 |
! this notice remains intact. If you modify this file, please |
| 13 |
! note section 2a) of the GPLv2 states that: |
| 14 |
! |
| 15 |
! a) You must cause the modified files to carry prominent notices |
| 16 |
! stating that you changed the files and the date of any change. |
| 17 |
! |
| 18 |
! Copyright (C) 2005-2009 Daniel Price. All rights reserved. |
| 19 |
! Contact: [email protected] |
| 20 |
! |
| 21 |
!----------------------------------------------------------------- |
| 22 |
|
| 23 |
! ---------------------------------------------------------------------- |
| 24 |
! Plots various analytic density profiles |
| 25 |
! |
| 26 |
! Currently implemented: |
| 27 |
! |
| 28 |
! 1) Plummer sphere |
| 29 |
! 2) Hernquist sphere |
| 30 |
! |
| 31 |
! Added by D. Price 5/9/05 |
| 32 |
! ---------------------------------------------------------------------- |
| 33 |
module densityprofiles |
| 34 |
implicit none |
| 35 |
|
| 36 |
contains |
| 37 |
|
| 38 |
subroutine exact_densityprofiles(iplot,iprofile,Msphere,rsoft,xplot,yplot,ierr) |
| 39 |
real, parameter :: pi = 3.1415926536 |
| 40 |
integer, intent(in) :: iplot,iprofile |
| 41 |
real, intent(in), dimension(2) :: Msphere,rsoft |
| 42 |
real, intent(in), dimension(:) :: xplot |
| 43 |
real, intent(out), dimension(size(xplot)) :: yplot |
| 44 |
integer, intent(out) :: ierr |
| 45 |
integer :: i |
| 46 |
! |
| 47 |
! check for errors |
| 48 |
! |
| 49 |
ierr = 0 |
| 50 |
if (all(Msphere <= 0.)) then |
| 51 |
print*,'error: mass <= 0 in exact_densityprofile' |
| 52 |
ierr = 2 |
| 53 |
return |
| 54 |
endif |
| 55 |
if (any(rsoft < 0.)) then |
| 56 |
print*,'error: rsoft < 0 in exact_densityprofile' |
| 57 |
ierr = 3 |
| 58 |
return |
| 59 |
endif |
| 60 |
|
| 61 |
select case(iprofile) |
| 62 |
case(1) |
| 63 |
! |
| 64 |
!--Plummer sphere |
| 65 |
! |
| 66 |
select case(iplot) |
| 67 |
case(2) |
| 68 |
!--potential |
| 69 |
do i=1,size(xplot) |
| 70 |
yplot(i) = -Msphere(1)/sqrt(rsoft(1)**2 + xplot(i)**2) & |
| 71 |
-Msphere(2)/sqrt(rsoft(2)**2 + xplot(i)**2) |
| 72 |
enddo |
| 73 |
!--force |
| 74 |
case(3) |
| 75 |
do i=1,size(xplot) |
| 76 |
yplot(i) = Msphere(1)*xplot(i)/((rsoft(1)**2 + xplot(i)**2)**1.5) & |
| 77 |
+ Msphere(2)*xplot(i)/((rsoft(2)**2 + xplot(i)**2)**1.5) |
| 78 |
enddo |
| 79 |
!--density |
| 80 |
case default |
| 81 |
do i=1,size(xplot) |
| 82 |
yplot(i) = 3.*Msphere(1)*rsoft(1)**2/(4.*pi*(rsoft(1)**2 + xplot(i)**2)**2.5) & |
| 83 |
+ 3.*Msphere(2)*rsoft(2)**2/(4.*pi*(rsoft(2)**2 + xplot(i)**2)**2.5) |
| 84 |
enddo |
| 85 |
end select |
| 86 |
|
| 87 |
case(2) |
| 88 |
! |
| 89 |
!--Hernquist model (use tiny to prevent divergences in cusp) |
| 90 |
! |
| 91 |
select case(iplot) |
| 92 |
case(2) |
| 93 |
!--potential |
| 94 |
do i=1,size(xplot) |
| 95 |
yplot(i) = -Msphere(1)/(rsoft(1) + xplot(i)) & |
| 96 |
-Msphere(2)/(rsoft(2) + xplot(i)) |
| 97 |
enddo |
| 98 |
!--force |
| 99 |
case(3) |
| 100 |
do i=1,size(xplot) |
| 101 |
yplot(i) = Msphere(1)/(rsoft(1) + xplot(i))**2 & |
| 102 |
+ Msphere(2)/(rsoft(2) + xplot(i))**2 |
| 103 |
enddo |
| 104 |
!--density |
| 105 |
case default |
| 106 |
do i=1,size(xplot) |
| 107 |
yplot(i) = Msphere(1)*rsoft(1)/ & |
| 108 |
((2.*pi*xplot(i)*(rsoft(1) + xplot(i))**3)) & |
| 109 |
+ Msphere(2)*rsoft(2)/ & |
| 110 |
((2.*pi*xplot(i)*(rsoft(2) + xplot(i))**3)) |
| 111 |
enddo |
| 112 |
end select |
| 113 |
|
| 114 |
case default |
| 115 |
ierr = 1 |
| 116 |
end select |
| 117 |
|
| 118 |
return |
| 119 |
end subroutine exact_densityprofiles |
| 120 |
|
| 121 |
end module densityprofiles |