Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed bug causing negative melt
  • Loading branch information
Austin Blevins committed Feb 27, 2023
1 parent 367d9ff commit 335825e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/regolith/regolith_streamtube_head.f90
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ subroutine regolith_streamtube_head(user,surfi,deltar,totmare,tots,age_collector
totmare = totmare + vsgly * current(M)%comp
recyratio = vsgly / (user%pix**2) /current(M)%thickness
age_collector(:) = age_collector(:) + current(M)%age(:) * recyratio
headmeltvol = current(M)%meltfrac * vsgly * recyratio
headmeltvol = current(M)%meltfrac * vsgly! * recyratio
meltinejecta = meltinejecta + headmeltvol
distvol(:) = distvol(:) + (current(M)%meltdist(:)*vsgly)!*recyratio)
totvol = totvol + vsgly
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-vsh)! * recyratio
linmelt = current(N-1)%meltfrac * max(vsgly-vsh,0.0_DP)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*(vsgly-vsh))!*recyratio)
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*max(vsgly-vsh,0.0_DP))!*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-vsh)! * recyratio
linmelt = current(N-1)%meltfrac * max(vseg-vsh,0.0_DP)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*(vseg-vsh))!*recyratio)
distvol(:) = distvol(:) + (current(N-1)%meltdist(:)*max(vseg-vsh,0.0_DP))!*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-vsh)! * recyratio
linmelt = current(N)%meltfrac * max(vseg-vsh,0.0_DP)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vseg-vsh))!*recyratio)
distvol(:) = distvol(:) + (current(N)%meltdist(:)*max(vseg-vsh,0.0_DP))!*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-vsh)! * recyratio
linmelt = current(N)%meltfrac * max(vseg-vsh,0.0_DP)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vseg-vsh))!*recyratio)
distvol(:) = distvol(:) + (current(N)%meltdist(:)*max(vseg-vsh,0.0_DP))!*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 * max(vseg-vsh,0.0_DP)! * recyratio
meltinejecta = meltinejecta + linmelt
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(vseg-vsh))!*recyratio)
distvol(:) = distvol(:) + (current(N)%meltdist(:)*max(vseg-vsh,0.0_DP))!*recyratio)
totvol = totvol + vseg
end if

Expand Down
10 changes: 5 additions & 5 deletions src/regolith/regolith_subpixel_streamtube.f90
Original file line number Diff line number Diff line change
Expand Up @@ -188,26 +188,26 @@ subroutine regolith_subpixel_streamtube(user,surfi,deltar,ri,rip1,eradi,newlayer
!if (rrighti>max(xmints,sqrt(rm**2 - z**2))) then
if (rrighti > xmints) then
vsh = regolith_shock_damage(eradi,deltar,xmints,xsfints,rrighti,rrightf)
recyratio = max((vsgly2 -vsh),0.0)/ (user%pix**2) / current(N)%thickness
recyratio = max((vsgly2 -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
mvr = (vsgly2-vsh) * current(N)%meltfrac! * recyratio
mvr = max((vsgly2 -vsh),0.0_DP) * 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
recyratio = max((vsgly1-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
mvl = (vsgly1-vsh) * current(N)%meltfrac!*recyratio
mvl = max((vsgly1-vsh),0.0_DP) * current(N)%meltfrac!*recyratio
end if

!current => current%next
meltinejecta = meltinejecta + mvl + mvr
!distvol(:) = distvol(:) + (current(N)%meltdist(:)*((vsgly1-vsh)*recyratio)+((vsgly2-vsh2)*recyratio2))
distvol(:) = distvol(:) + (current(N)%meltdist(:)*((vsgly1-vsh)+(vsgly2-vsh2)))
distvol(:) = distvol(:) + (current(N)%meltdist(:)*(max((vsgly1-vsh),0.0_DP)+max((vsgly2-vsh),0.0_DP)))
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-vsh)!*recyratio
distvol(:) = distvol(:) + (surfi%regolayer(N)%meltdist(:)*(vseg-vsh))!*recyratio)
meltinejecta = meltinejecta + surfi%regolayer(N)%meltfrac*max(vseg-vsh,0.0_DP)!*recyratio
distvol(:) = distvol(:) + (surfi%regolayer(N)%meltdist(:)*max(vseg-vsh,0.0_DP))!*recyratio)
totvol = totvol + vseg
end if

Expand Down

0 comments on commit 335825e

Please sign in to comment.