Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instability in RBM #37

Merged
merged 29 commits into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
fd21414
inserted a comment at top of Begin.f90 to verify PR
rniemeyer07 Jul 19, 2017
2253a6a
small changes to read_forcing.f90 to read in energy and flow files
rniemeyer07 Jul 25, 2017
f16833b
removed ^M carriage returns
rniemeyer07 Jul 31, 2017
f5f2430
updated rbm10, added Block_Reservoir
rniemeyer07 Jul 31, 2017
3352fb0
added Block_Reservoir, added variables to read in reservoir data, add…
rniemeyer07 Aug 1, 2017
33593d8
Merge branch 'RBM_res_develop' of https://github.com/UW-Hydro/RBM int…
Oct 20, 2017
965ade8
fix small bugs in RBM in particle tracking
Nov 7, 2017
8e22071
fix minor error in particle tracking branch
Jan 29, 2018
0ad3424
test for instability in RBM
Jan 30, 2018
2a98174
calculate the error aroused because of numerical schemes implemented
Feb 1, 2018
3d32e8f
add estimation of second order error
Feb 8, 2018
ea88e91
comment out printing statement (for test)
Feb 8, 2018
06acd9a
add output filtering
Feb 8, 2018
b680dff
Fix the number of segments output for each grid cell.
Feb 8, 2018
6b552fa
fix output statement
Feb 9, 2018
f7e0c06
debug - allocated space is not sufficient for variables in Block_Hyd…
Feb 12, 2018
0ff5c18
git rid of the speeding up in make file
Feb 22, 2018
d4be946
experiment for temperature spikes in model simulation
Feb 23, 2018
10e5b6e
set the minimum wind speed to be 1 m/s
Feb 23, 2018
71ecae4
fix small bug for wind speed threshold
Feb 26, 2018
f358f92
check reservoir temperature instability
Feb 26, 2018
518aabb
add Error_estimate subroutine
Feb 28, 2018
25d0191
fix bugs in dynamic time step to calculate reservoir temperature
Mar 6, 2018
d80444a
Set the initial storage to be 95% of reservoir capacity
Mar 8, 2018
5dcc50d
1) calculate equilibrium temperature
Mar 14, 2018
b7c132e
set the minimum river depth to be 5 feet
Apr 5, 2018
963319e
bug fix for reservoir storage data
Apr 16, 2018
7c385a3
clean up makefile
Apr 25, 2018
c1a667f
Merge branch 'test_instability_to_delete' into RBM_res_develop
Apr 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 42 additions & 28 deletions src/Begin.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Subroutine BEGIN(param_file,spatial_file)
character (len=200):: param_file,source_file,spatial_file
!
integer:: Julian
integer:: head_name,trib_cell
integer:: head_name,trib_cell
integer:: jul_start,main_stem,nyear1,nyear2,nc,ncell,nseg
integer:: ns_max_test,node,ncol,nrow,nr,cum_sgmnt
!
integer:: nreservoir
integer:: nreservoir,nseg_temp,nseg_cum
!
logical:: first_cell,source
!
Expand Down Expand Up @@ -83,6 +83,7 @@ Subroutine BEGIN(param_file,spatial_file)
allocate(res_start_node(nres))
allocate(res_end_node(nres))
allocate(res_capacity_mcm(nres))
allocate(nseg_out(nreach,heat_cells,nseg_out_num))
!
! Start reading the reach date and initialize the reach index, NR
! and the cell index, NCELL
Expand Down Expand Up @@ -117,12 +118,13 @@ Subroutine BEGIN(param_file,spatial_file)
! Initialize NSEG, the total number of segments in this reach
!
nseg=0
nseg_cum=0
write(*,*) ' Starting to read reach ',nr
!
! Read the number of cells in this reach, the headwater #,
! the number of the cell where it enters the next higher order stream,
! the headwater number of the next higher order stream it enters, and
! the river mile of the headwaters.
! the river mile of the headwaters.
!
read(90,'(i5,11x,i4,10x,i5,15x,i5,15x,f10.0,i5)') no_cells(nr) &
,head_name,trib_cell,main_stem,rmile0
Expand All @@ -139,7 +141,7 @@ Subroutine BEGIN(param_file,spatial_file)
if (trib_cell.gt.0) then
no_tribs(trib_cell) = no_tribs(trib_cell)+1
trib(trib_cell,no_tribs(trib_cell)) = nr
end if
end if
!
! Reading Mohseni parameters for each headwaters (UW_JRY_2011/06/18)
!
Expand All @@ -165,7 +167,7 @@ Subroutine BEGIN(param_file,spatial_file)
end if
!
! The headwaters index for each cell in this reach is given
! in the order the cells are read
! in the order the cells are read
!
! Card Type 3. Cell indexing #, Node # Row # Column Lat Long RM
!
Expand All @@ -175,14 +177,14 @@ Subroutine BEGIN(param_file,spatial_file)
if (reservoir) then
read(90,'(5x,i5,5x,i5,8x,i5,6x,a8,6x,a10,7x,f10.0,f5.0,i6)') &
node,nrow,ncol,lat,long,rmile1,ndelta(ncell),res_num(ncell)
write(*,*) node,nrow,ncol,lat,long,rmile1,ndelta(ncell),res_num(ncell)
!write(*,*) node,nrow,ncol,lat,long,rmile1,ndelta(ncell),res_num(ncell)
if(res_num(ncell) .gt. 0) then
res_pres(ncell) = .TRUE.
end if
else
read(90,'(5x,i5,5x,i5,8x,i5,6x,a8,6x,a10,7x,f10.0,f5.0)') &
node,nrow,ncol,lat,long,rmile1,ndelta(ncell)
write(*,*) node,nrow,ncol,lat,long,rmile1,ndelta(ncell)
!write(*,*) node,nrow,ncol,lat,long,rmile1,ndelta(ncell)
end if
!
! Set the number of segments of the default, if not specified
Expand All @@ -197,9 +199,16 @@ Subroutine BEGIN(param_file,spatial_file)
! Added variable ndelta (UW_JRY_2011/03/15)
!
dx(ncell)=miles_to_ft*(rmile0-rmile1)/ndelta(ncell)
rmile0=rmile1
nndlta=0
200 continue
rmile0=rmile1
!
! Here we define the output segments
!
do nseg_temp=1,nseg_out_num
nseg_out(nr,ncell,nseg_temp)=nseg_cum+ndelta(ncell)*nseg_temp/(nseg_out_num)
end do
nseg_cum = nseg_cum+ndelta(ncell)
nndlta=0
200 continue
nndlta=nndlta+1
nseg=nseg+1
segment_cell(nr,nseg)=ncell
Expand All @@ -208,20 +217,25 @@ Subroutine BEGIN(param_file,spatial_file)
!
! Write Segment List for mapping to temperature output (UW_JRY_2008/11/19)
!
open(22,file=TRIM(spatial_file),status='unknown') ! (changed by WUR_WF_MvV_2011/01/05)
write(22,'(4i6,1x,a8,1x,a10,f5.0)') nr,ncell,nrow,ncol,lat,long,nndlta
do nseg_temp=1,nseg_out_num
if (nseg_out(nr,ncell,nseg_temp).eq.nseg) then
open(22,file=TRIM(spatial_file),status='unknown') ! (changed by WUR_WF_MvV_2011/01/05)
write(22,'(4i6,1x,a8,1x,a10,i5)') nr,ncell,nrow,ncol,lat,long,nseg_temp
end if
end do
!
!
!
! Added variable ndelta (UW_JRY_2011/03/15)
!
if(nndlta.lt.ndelta(ncell)) go to 200
no_celm(nr)=nseg
no_celm(nr)=nseg
segment_cell(nr,nseg)=ncell
x_dist(nr,nseg)=miles_to_ft*rmile1
x_dist(nr,nseg)=miles_to_ft*rmile1
write(*,*) 'number of segment in reach', nr, nseg
!
! End of cell and segment loop
!
!
end do
!
! If this is a reach that is tributary to another, set the confluence cell to the previous
Expand All @@ -233,26 +247,26 @@ Subroutine BEGIN(param_file,spatial_file)
conflnce(trib_cell,no_tribs(trib_cell)) = ncell
end if

if(ns_max_test.lt.nseg) ns_max_test=nseg
!
if(ns_max_test.lt.nseg) ns_max_test=nseg
!
! End of reach loop
!
!
end do
if(ns_max_test.gt.ns_max) then
write(*,*) 'RBM is terminating because'
write(*,*) 'NS_MAX exceeded. Change NS_MAX in Block_Network to: ',ns_max_test
stop
end if
!
nwpd=1
xwpd=nwpd
dt_comp=86400./xwpd
end if
!
nwpd=1
xwpd=nwpd
dt_comp=86400./xwpd
!
! ******************************************************
! Return to RMAIN
! ******************************************************
!
! ******************************************************
! Return to RMAIN
! ******************************************************
!
900 continue
900 continue
!
!
end subroutine BEGIN
5 changes: 4 additions & 1 deletion src/Block_Energy.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ module Block_Energy
! Some important constants
!
real :: lvp,rb,rho
real :: deriv_2nd,error_EE
real :: deriv_conv,deriv_evap,deriv_ws
real :: temp_equil,time_equil
real,parameter :: evap_coeff=1.5e-9 !Lake Hefner coefficient, 1/meters
real,parameter :: pf=0.640,pi=3.14159
real,parameter :: rfac=304.8 !rho/Cp kg/meter**3/Kilocalories/kg/Deg K
real,parameter :: sec_day = 86400 !number of seconds in a day
real,parameter :: a_z=0.408, b_z=0.392 !Leopold parameter for depth
real,parameter :: a_w=4.346, b_w=0.520 !Leopold parameter for width
real,parameter :: a_w=4.346, b_w=0.520 !Leopold parameter for width
!
end module Block_Energy
4 changes: 2 additions & 2 deletions src/Block_Hydro.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
! Module for hydraulic characteristics and water quality constituents of the basin
!
module Block_Hydro
integer, dimension(2000):: no_dt,nstrt_elm
real, dimension(2000) :: dt_part,x_part
integer, dimension(2500):: no_dt,nstrt_elm
real, dimension(2500) :: dt_part,x_part
!
real, dimension(:), allocatable :: depth
real, dimension(:), allocatable :: width
Expand Down
13 changes: 12 additions & 1 deletion src/Block_Network.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,29 @@ Module Block_Network
!
integer, dimension(:,:), allocatable::conflnce,reach_cell,segment_cell,trib
!
integer, dimension(:,:,:), allocatable::nseg_out
!
! Integer variables
!
integer:: flow_cells,heat_cells
integer:: ndays,nreach,ntrb,nwpd
integer,parameter::ns_max=200
integer,parameter::ns_max=3000
integer,parameter::nseg_out_num=2
integer:: start_year,start_month,start_day
integer:: end_year,end_month,end_day
integer:: numsub !number of subdaily timestep
integer:: nsub
!
! Real variables
!
real :: delta_n,n_default=2
real :: dt_comp
real :: dt_res
real, dimension(:), allocatable :: ndelta
!
! Logical variables
!



end module Block_Network
11 changes: 11 additions & 0 deletions src/Block_Reservoir.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module Block_Reservoir
logical, dimension(:), allocatable :: res_trib_calc !
logical, dimension(:), allocatable :: res_stratif_start !
logical, dimension(:), allocatable :: res_turnover !
logical :: exceed_error_bound
logical :: adjust_timestep
logical :: recalculate_volume
!
!
real, parameter :: depth_e_frac=0.4, depth_h_frac=0.6
Expand All @@ -23,6 +26,13 @@ module Block_Reservoir
real :: flow_epi_hyp_x, outflow_x
real :: res_vol_delta_x, vol_change_hyp_x, vol_change_epi_x
real :: res_storage_pre, res_storage_post
!
! Error estimation
!
real :: m11,m12,m21,m22
real :: const1,const2
real :: error_e,error_h
real, parameter :: error_threshold = 0.1
real, dimension(:), allocatable :: K_z
real, dimension(:), allocatable :: depth_e, depth_h
real, dimension(:), allocatable :: density_epil, density_hypo
Expand Down Expand Up @@ -54,6 +64,7 @@ module Block_Reservoir
real, dimension(:), allocatable :: qsurf_tot
real, dimension(:), allocatable :: res_capacity_mcm
real, dimension(:), allocatable :: volume_h_min
real, dimension(:), allocatable :: volume_e_min
real, dimension(:,:), allocatable :: res_storage
!
!
Expand Down
Loading