Skip to content

Commit

Permalink
change start and end time in minutes not hour
Browse files Browse the repository at this point in the history
  • Loading branch information
kumdonoaa authored and kumdonoaa committed Aug 15, 2024
1 parent d80b6f8 commit 08ee8bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
44 changes: 17 additions & 27 deletions src/kernel/diffusive/diffusive_lightweight.f90
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ subroutine compute_diffusive_couplingtimestep(timestep_ar_g, nts_ql_g, nts_db_g,
x = 0.0
newQ = -999
newY = -999
t = t_start*60.0 ![min]
t = t_start ![min]
q_sk_multi = 1.0
oldQ = iniq
newQ = oldQ
Expand Down Expand Up @@ -411,13 +411,6 @@ subroutine compute_diffusive_couplingtimestep(timestep_ar_g, nts_ql_g, nts_db_g,
! Initial depth at bottom node of tail water reach
if (dsbc_option == 1) then
! use tailwater downstream boundary observations
! needed for coastal coupling
! **** COMING SOON ****
!do n = 1, nts_db_g
! varr_db(n) = dbcd(n) + z(ncomp, j) !* when dbcd is water depth [m], channel bottom elev is added.
!end do
!t = t0 * 60.0
t = t_start * 60.0
oldY(ncomp, j) = intp_y(nts_db_g, tarr_db, varr_db, t)
newY(ncomp, j) = oldY(ncomp, j)
if ((newY(ncomp, j) - z(ncomp, j)).lt.mindepth_nstab) then
Expand Down Expand Up @@ -464,7 +457,7 @@ subroutine compute_diffusive_couplingtimestep(timestep_ar_g, nts_ql_g, nts_db_g,
oldY(i, j) = inidepth(i,j) + z(i,j)
enddo
enddo
endif
endif

!-----------------------------------------------------------------------------
! With initial flow and depth, identify the maximum calculated celerity/dx ratio
Expand Down Expand Up @@ -496,12 +489,11 @@ subroutine compute_diffusive_couplingtimestep(timestep_ar_g, nts_ql_g, nts_db_g,

!-----------------------------------------------------------------------------
! Initializations and re-initializations
qpx = iniqpx !0.
t = t_start*60.0 ![minuntes]
qpx = iniqpx

!-----------------------------------------------------------------------------
! Ordered network routing computations
do while ( t < t_end * 60.)
do while ( t < t_end)

!+-------------------------------------------------------------------------
!+ PREDICTOR
Expand All @@ -515,7 +507,7 @@ subroutine compute_diffusive_couplingtimestep(timestep_ar_g, nts_ql_g, nts_db_g,
! Calculate the duration of this timestep (dtini)
! Timestep duration is selected to maintain numerical stability
if (j == mstem_frj(1)) then
call calculateDT(t_start, t, saveInterval, cfl, tfin, maxCelDx, dtini_given)
call calculateDT(t_start, t, saveInterval, cfl, t_end, maxCelDx, dtini_given)
end if

! estimate lateral flow at current time t
Expand Down Expand Up @@ -551,7 +543,7 @@ subroutine compute_diffusive_couplingtimestep(timestep_ar_g, nts_ql_g, nts_db_g,
end if

! add upstream flows to reach head
newQ(1,j)= newQ(1,j) + q_usrch
newQ(1,j)= newQ(1,j) + q_usrch
end do
else

Expand Down Expand Up @@ -654,7 +646,7 @@ subroutine compute_diffusive_couplingtimestep(timestep_ar_g, nts_ql_g, nts_db_g,
endif

! write results to output arrays
if ( (mod((t - t_start * 60.) * 60., saveInterval) <= TOLERANCE) .or. (t == t_end * 60.)) then
if ( (mod((t - t_start ) * 60., saveInterval) <= TOLERANCE) .or. (t == t_end)) then
do jm = 1, nmstem_rch
j = mstem_frj(jm)
ncomp = frnw_g(j, 1)
Expand Down Expand Up @@ -713,10 +705,10 @@ subroutine calculateDT(initialTime, time, saveInterval, maxAllowCourantNo, tfin,
!-----------------------------------------------------------------------------

! Subroutine arguments
real(prec), intent(in) :: initialTime ! [sec]
real(prec), intent(in) :: time ! [hrs]
real(prec), intent(in) :: initialTime ! [minutes]
real(prec), intent(in) :: time ! [minutes]
real(prec), intent(in) :: saveInterval ! [sec]
real(prec), intent(in) :: tfin ! [hrs]
real(prec), intent(in) :: tfin ! [minutes]
real(prec), intent(in) :: given_dt ! [sec]
real(prec), intent(in) :: maxAllowCourantNo ! = cfl
real(prec), intent(in) :: max_C_dx ! = maxCelDx
Expand All @@ -727,19 +719,17 @@ subroutine calculateDT(initialTime, time, saveInterval, maxAllowCourantNo, tfin,

!-----------------------------------------------------------------------------
! Calculate maximum timestep duration for numerical stability

dtini = maxAllowCourantNo / max_C_dx

a = floor( (time - initialTime * 60.) / &
( saveInterval / 60.))
b = floor(((time - initialTime * 60.) + dtini / 60.) / &
( saveInterval / 60.))
a = floor( (time - initialTime) / ( saveInterval / 60.))
b = floor(((time - initialTime) + dtini / 60.) / ( saveInterval / 60.))
if (b > a) then
dtini = (a + 1) * (saveInterval) - (time - initialTime * 60.) * 60.
dtini = (a + 1) * (saveInterval) - (time - initialTime) * 60.
end if

! if dtini extends beyond final time, then truncate it
if (time + dtini / 60. > tfin * 60.) dtini = (tfin * 60. - time) * 60.
if (time + dtini / 60. > tfin) dtini = (tfin - time) * 60.

end subroutine

Expand Down Expand Up @@ -806,7 +796,7 @@ subroutine mesh_diffusive_forward(t, saveInterval,j)
!print *, '****** DIFFUSIVE FORWARD *****'
!print *, '---------'
ncomp = frnw_g(j, 1)

do i = 2, ncomp

cour = dtini / dx(i - 1, j)
Expand Down Expand Up @@ -1180,7 +1170,7 @@ subroutine mesh_diffusive_backward(t, saveInterval, j)
if (diffusivity(i, j) > D_ulm) diffusivity(i, j) = D_ulm
if (diffusivity(i, j) < D_llm) diffusivity(i, j) = D_llm
end do

end subroutine mesh_diffusive_backward

subroutine compute_only_celerity_diffusivity(t, ncomp, j, temp_q, temp_elev)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ cpdef object compute_network_structured_with_hybrid_routing(
for fj in range(num_reaches_diffusive_domain):
for fi in range(max_num_node_reach):
diffusive_inputs["iniqpx"][fi,fj] = iniqpx_np[fi,fj]

(out_q_next_out_time,
out_elv_next_out_time,
out_depth_next_out_time,
Expand All @@ -1376,10 +1376,10 @@ cpdef object compute_network_structured_with_hybrid_routing(
diffusive_inputs,
out_chxsec_lookuptable,
out_z_adj,
dt*(timestep-1)/3600.0, # start time of the current coupling time step [hr]
dt*timestep/3600.0, # end time of the current coupling time step [hr]
dt*(timestep-1)/60.0, # start time of the current coupling time step [minutes]
dt*timestep/60.0, # end time of the current coupling time step [minutes]
)

iniqpx_np = out_qpx_next_out_time

for seg_id in diffusive_segments:
Expand Down

0 comments on commit 08ee8bb

Please sign in to comment.