Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed a few bugs in volume calculation
  • Loading branch information
Austin Blevins committed Feb 27, 2023
1 parent 8d7a7be commit 367d9ff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 27 deletions.
15 changes: 8 additions & 7 deletions src/regolith/regolith_streamtube_head.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ subroutine regolith_streamtube_head(user,surfi,deltar,totmare,tots,age_collector
age_collector(:) = age_collector(:) + current(M)%age(:) * recyratio
headmeltvol = current(M)%meltfrac * vsgly * recyratio
meltinejecta = meltinejecta + headmeltvol
distvol(:) = distvol(:) + (current(M)%meltdist(:)*vsgly*recyratio)
distvol(:) = distvol(:) + (current(M)%meltdist(:)*vsgly)!*recyratio)
totvol = totvol + vsgly
else ! head is not intersected with layers.

Expand All @@ -81,10 +81,10 @@ subroutine regolith_streamtube_head(user,surfi,deltar,totmare,tots,age_collector
totmarehead = totmarehead + vhead * vratio * current(N)%comp
recyratio = vhead * vratio / (user%pix**2) / current(N)%thickness
age_collector(:) = age_collector(:) + current(N)%age(:) * recyratio
headmeltvol = current(N)%meltfrac * tothead * recyratio
headmeltvol = current(N)%meltfrac * tothead! * recyratio
meltinejecta = meltinejecta + headmeltvol
distvol(:) = distvol(:) + (current(N)%meltdist(:)*tothead*recyratio)
totvol = totvol + tothead
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vhead*vratio))!*recyratio)
!totvol = totvol + tothead
!current => current%next
!N = N - 1
z = z + current(N-1)%thickness
Expand All @@ -95,10 +95,11 @@ subroutine regolith_streamtube_head(user,surfi,deltar,totmare,tots,age_collector
tothead = vsgly
recyratio = (vsgly - tothead) / (user%pix**2) / current(N)%thickness
age_collector(:) = age_collector(:) + current(N)%age(:) * recyratio
headmeltvol = current(N)%meltfrac * tothead*recyratio
headmeltvol = current(N)%meltfrac * (vsgly-tothead)!*recyratio
meltinejecta = meltinejecta + headmeltvol
distvol(:) = distvol(:) + (current(N)%meltdist(:)*tothead*recyratio)
totvol = totvol + tothead
!distvol(:) = distvol(:) + (current(N)%meltdist(:)*tothead*recyratio) !should be +0 since recyratio=0
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vsgly-tothead))
totvol = totvol + vsgly
exit
end if
end do
Expand Down
20 changes: 10 additions & 10 deletions src/regolith/regolith_streamtube_lineseg.f90
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ subroutine regolith_streamtube_lineseg(user,surfi,thetast,ri,rip1,zmin,zmax,erad
recyratio = max(ebh_recyl,0.0_DP) / current(N-1)%thickness
age_collector(:) = age_collector(:) + current(N-1)%age(:) * recyratio
vol = vol + sum(current(N-1)%age(:)) * recyratio
linmelt = current(N-1)%meltfrac * vsgly * recyratio
linmelt = current(N-1)%meltfrac * (vsgly-vsh)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*vsgly*recyratio)
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*(vsgly-vsh))!*recyratio)
totvol = totvol + vsgly
else if (ri <= xmints .and. rip1 > xmints) then
vseg = regolith_streamtube_volume_func(eradi,xmints,rip1,deltar)
vsh = regolith_shock_damage(eradi,deltar,xmints,xsfints,ri,rip1)
recyratio = max((vseg-vsh),0.0_DP) / (user%pix**2) / current(N-1)%thickness
age_collector(:) = age_collector(:) + current(N-1)%age(:) * recyratio
vol = vol + sum(current(N-1)%age(:)) * recyratio
linmelt = current(N-1)%meltfrac * vseg * recyratio
linmelt = current(N-1)%meltfrac * (vseg-vsh)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*vseg*recyratio)
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*(vseg-vsh))!*recyratio)
totvol = totvol + vseg
end if
exit
Expand Down Expand Up @@ -124,9 +124,9 @@ subroutine regolith_streamtube_lineseg(user,surfi,thetast,ri,rip1,zmin,zmax,erad
recyratio = max((vseg-vsh),0.0_DP) / (user%pix**2) / current(N)%thickness
age_collector(:) = age_collector(:) + current(N)%age(:) * recyratio
vol = vol + sum(current(N)%age(:)) * recyratio
linmelt = current(N)%meltfrac * vseg * recyratio
linmelt = current(N)%meltfrac * (vseg-vsh)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N)%meltdist(:)*vseg*recyratio)
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vseg-vsh))!*recyratio)
totvol = totvol + vseg
end if

Expand All @@ -137,9 +137,9 @@ subroutine regolith_streamtube_lineseg(user,surfi,thetast,ri,rip1,zmin,zmax,erad
recyratio = max((vseg-vsh),0.0_DP) / (user%pix**2) / current(N)%thickness
age_collector(:) = age_collector(:) + current(N)%age(:) * recyratio
vol = vol + sum(current(N)%age(:)) * recyratio
linmelt = current(N)%meltfrac * vseg * recyratio
linmelt = current(N)%meltfrac * (vseg-vsh)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N)%meltdist(:)*vseg*recyratio)
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vseg-vsh))!*recyratio)
totvol = totvol + vseg
end if
!current => current%next
Expand All @@ -162,9 +162,9 @@ subroutine regolith_streamtube_lineseg(user,surfi,thetast,ri,rip1,zmin,zmax,erad
recyratio = max((vseg-vsh),0.0_DP) / (user%pix**2) / current(N)%thickness
age_collector(:) = age_collector(:) + current(N)%age(:) * recyratio
vol = vol + sum(current(N)%age(:)) * recyratio
linmelt = current(N)%meltfrac * vseg * recyratio
linmelt = current(N)%meltfrac * vseg! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N)%meltdist(:)*vseg*recyratio)
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vseg-vsh))!*recyratio)
totvol = totvol + vseg
end if

Expand Down
17 changes: 9 additions & 8 deletions src/regolith/regolith_subpixel_streamtube.f90
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ subroutine regolith_subpixel_streamtube(user,surfi,deltar,ri,rip1,eradi,newlayer
real(DP) :: zm, recyratio, xmints1, vseg, recyratio2

! Parameters for calculating shocked segment of stream tube
real(DP) :: x_up_sh, x_low_sh, vsh
real(DP) :: x_up_sh, x_low_sh, vsh, vsh2

! The depth that a stream tube dips
zmax = rip1/4.0_DP
Expand Down Expand Up @@ -113,9 +113,9 @@ subroutine regolith_subpixel_streamtube(user,surfi,deltar,ri,rip1,eradi,newlayer
vseg = regolith_streamtube_volume_func(eradi,xmints,eradi,deltar)
vsh = regolith_shock_damage(eradi,deltar,xmints,xsfints,0.0_DP,eradi)
recyratio = max(vseg-vsh,0.0 )/ (user%pix**2) / (surfi%regolayer(M)%thickness)
meltinejecta = surfi%regolayer(M)%meltfrac * vseg * recyratio
distvol(:) = distvol(:) + (surfi%regolayer(M)%meltdist(:)*vseg*recyratio)
totvol = vseg
meltinejecta = surfi%regolayer(M)%meltfrac * (vseg-vsh) * recyratio
distvol(:) = distvol(:) + (surfi%regolayer(M)%meltdist(:)*(vseg-vsh)*recyratio)
totvol = vseg - vsh
age_collector(:) = age_collector(:) + surfi%regolayer(M)%age(:) * recyratio
vol = vol + sum(age_collector(:))
! write(*,*) '1',eradi, xmints, xsfints, &
Expand Down Expand Up @@ -191,22 +191,23 @@ subroutine regolith_subpixel_streamtube(user,surfi,deltar,ri,rip1,eradi,newlayer
recyratio = max((vsgly2 -vsh),0.0)/ (user%pix**2) / current(N)%thickness
age_collector(:) = age_collector(:) + current(N)%age(:) * recyratio
vol = vol + sum(current(N)%age(:)) * recyratio
mvr = vsgly2 * current(N)%meltfrac * recyratio
mvr = (vsgly2-vsh) * current(N)%meltfrac! * recyratio
recyratio2 = recyratio
vsh2 = vsh
end if

if (rlefti > xmints) then
vsh = regolith_shock_damage(eradi,deltar,xmints,xsfints,rlefti,rleftf)
recyratio = max((vsgly1-vsh),0.0) / (user%pix**2) / current(N)%thickness
age_collector(:) = age_collector(:) + current(N)%age(:) * recyratio
vol = vol + sum(current(N)%age(:)) * recyratio
mvl = vsgly1 * current(N)%meltfrac*recyratio
mvl = (vsgly1-vsh) * current(N)%meltfrac!*recyratio
end if

!current => current%next
meltinejecta = meltinejecta + mvl + mvr
distvol(:) = distvol(:) + (current(N)%meltdist(:)*((vsgly1*recyratio)+(vsgly2*recyratio2)))
!distvol = distvol + (current(N)%meltdist(:)*(vsgly1+vsgly2))
!distvol(:) = distvol(:) + (current(N)%meltdist(:)*((vsgly1-vsh)*recyratio)+((vsgly2-vsh2)*recyratio2))
distvol(:) = distvol(:) + (current(N)%meltdist(:)*((vsgly1-vsh)+(vsgly2-vsh2)))
totvol = totvol + vsgly1 + vsgly2
!N = N - 1
z = z + current(N-1)%thickness
Expand Down
4 changes: 2 additions & 2 deletions src/regolith/regolith_traverse_streamtube.f90
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ subroutine regolith_traverse_streamtube(user,surfi,deltar,ri,rip1,eradi,erado,ne
vsh = regolith_shock_damage(eradi,deltar,xmints,xsfints,ri,rip1)
recyratio = max(vseg-vsh,0.0_DP) / (user%pix**2) / surfi%regolayer(N)%thickness
age_collector(:) = age_collector(:) + surfi%regolayer(N)%age(:) * recyratio
meltinejecta = meltinejecta + surfi%regolayer(N)%meltfrac * vseg*recyratio
distvol(:) = distvol(:) + (surfi%regolayer(N)%meltdist(:)*vseg*recyratio)
meltinejecta = meltinejecta + surfi%regolayer(N)%meltfrac*(vseg-vsh)!*recyratio
distvol(:) = distvol(:) + (surfi%regolayer(N)%meltdist(:)*(vseg-vsh))!*recyratio)
totvol = totvol + vseg
end if

Expand Down

0 comments on commit 367d9ff

Please sign in to comment.