From 08ee8bb9f607f5aa8f8de6a531725b0fba6424e3 Mon Sep 17 00:00:00 2001 From: kumdonoaa Date: Thu, 15 Aug 2024 16:23:20 -0500 Subject: [PATCH] change start and end time in minutes not hour --- .../diffusive/diffusive_lightweight.f90 | 44 +++++++------------ .../fast_reach/hybrid_routing_reach.pyx | 8 ++-- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/kernel/diffusive/diffusive_lightweight.f90 b/src/kernel/diffusive/diffusive_lightweight.f90 index 2533c946f..4d0afdc7b 100644 --- a/src/kernel/diffusive/diffusive_lightweight.f90 +++ b/src/kernel/diffusive/diffusive_lightweight.f90 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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) @@ -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) diff --git a/src/troute-routing/troute/routing/fast_reach/hybrid_routing_reach.pyx b/src/troute-routing/troute/routing/fast_reach/hybrid_routing_reach.pyx index d4168463a..f9cc7a247 100644 --- a/src/troute-routing/troute/routing/fast_reach/hybrid_routing_reach.pyx +++ b/src/troute-routing/troute/routing/fast_reach/hybrid_routing_reach.pyx @@ -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, @@ -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: