Beispiel #1
0
    def advance_in_time(self):
        """ Update avulsion model one time step. """

        ### future work: SLRR can be a vector to change rates ###

        # determine if there is an avulsion & find new path if so
        ### need to change this to look for shoreline after coupling ###
        ### (instead of looking for sea level)
        (self._riv_i, self._riv_j), self._avulsion_type, self._loc = avulse.find_avulsion(
             self._riv_i, self._riv_j, self._n,
             self._super_ratio, self._SL, self._ch_depth,
             self._short_path, self._splay_type, self._splay_dep, dx=self._dx,
             dy=self._dy)

        if self._saveavulsions & self._avulsion_type > 0:
            new_info = (self._avulsion_type, self._time / _SECONDS_PER_YEAR, self._loc)
            self._avulsion_info = np.vstack([self._avulsion_info, new_info])

        #assert(self._riv_i[-1] != 0)

        # save timestep and avulsion location if there was one
        #if len(loc) != 0:
        #    self._avulsions = self._avulsions + [(self._time/_SECONDS_PER_DAY),
        #                loc[-1], avulsion_type, length_old,
        #                length_new_sum, self._SL)]
        
        # raise first two rows by inlet rise rate (subsidence)
        self._n[:2, :] += self._IRR

        # change elevations according to sea level rise (SLRR)
        ### needs to be changed to subtracting elevation once coupled ###
        SLR.elev_change(self._SL, self._n, self._riv_i,
                        self._riv_j, self._ch_depth)

        # smooth river course elevations using linear diffusion equation
        diffuse.smooth_rc(self._dx, self._dy, self._nu, self._dt,
                          self._riv_i, self._riv_j, self._n)

        # Floodplain sedimentation
        FP.dep_blanket(self._SL, self._blanket_rate, self._n,
                       self._riv_i, self._riv_j, self._ch_depth)

        # Wetland sedimentation
        ### no wetlands in first version of coupling to CEM ###
        FP.wetlands(self._SL, self._WL_Z, self._WL_dist * self._dy,
                    self._n, self._riv_i, self._riv_j, self._x, self._y)

        # calculate sediment flux
        self._sed_flux = flux.calc_qs(self._nu, self._riv_i,
                                      self._riv_j, self._n,
                                      self._dx, self._dy, self._dt)

        self._profile = self._n[self._riv_i, self._riv_j]

        # Update sea level
        self._SL += self._SLRR
        self._time += self._dt
    def advance_in_time(self):
        """ Update avulsion model one time step. """
        # if (self._time / _SECONDS_PER_YEAR) > 2000:
        #     self._SLRR = 0.01 / _SECONDS_PER_YEAR * self._dt

        self._riv_i, self._riv_j, self._course_update = steep_desc.update_course(
            self._n, self._riv_i, self._riv_j, self._ch_depth, self._slope,
            sea_level=self._SL, dx=self._dx, dy=self._dy)

        self._n = avulsion_utils.fix_elevations(self._n, self._riv_i, self._riv_j,
            self._ch_depth, self._SL, self._slope, self._dx, self._max_rand, self._SLRR)

        """ Save every time the course changes? """
        if self._saveupdates and self._course_update > 0:
            with open('output_data/river_info.out','a') as file:
                file.write("%.5f %i \n" % ((self._time / _SECONDS_PER_YEAR),
                    self._course_update))

        """ determine if there is an avulsion & find new path if so """
        (self._riv_i, self._riv_j), self._avulsion_type, self._loc, self._avulse_length, \
         self._path_diff, self._splay_deposit = avulse.find_avulsion(self._riv_i,
            self._riv_j, self._n, self._super_ratio, self._SL, self._ch_depth,
            self._short_path, self._splay_type, self._slope,
            self._splay_deposit, self._nu, self._dt, dx=self._dx, dy=self._dy)

        """ Save avulsion record. """
        if self._saveavulsions and self._avulsion_type > 0:
            with open('output_data/river_info.out','a') as file:
                file.write("%.5f %i %i %.5f %.5f\n" % ((self._time / _SECONDS_PER_YEAR),
                    self._avulsion_type, self._loc, self._avulse_length, self._path_diff))

        """ Save crevasse splay deposits. """        
        if self._saveavulsions and (self._splay_deposit.sum() > 0):
            np.savetxt('output_data/splay_deposit.out', self._splay_deposit, '%.8f')

        # need to fill old river channels if coupled to CEM
        if (self._avulsion_type == 1) or (self._avulsion_type == 2):
            self._n = avulsion_utils.fix_elevations(self._n, self._riv_i, self._riv_j,
                self._ch_depth, self._SL, self._slope, self._dx, self._max_rand, self._SLRR)

        #assert(self._riv_i[-1] != 0)

        """ change elevations according to sea level rise (SLRR)
        (if not coupled -- this occurs in coupling script otherwise) """
        # SLR.elev_change(self._SL, self._n, self._riv_i,
        #                 self._riv_j, self._ch_depth, self._SLRR)

        """ smooth river course elevations using linear diffusion equation """
        self._dn_rc = diffuse.smooth_rc(self._dx, self._dy, self._nu, self._dt, self._ch_depth,
                          self._riv_i, self._riv_j, self._n, self._SL, self._slope)

        """ Floodplain sedimentation (use one or the other) """
        #-------------------------------------------------------
        ### Deposit blanket across entire subaerial domain: ###
        # FP.dep_blanket(self._SL, self._blanket_rate, self._n,
        #                self._riv_i, self._riv_j, self._ch_depth)

        ### Deposit fines adjacent to river channel: ###
        FP.dep_fines(self._n, self._riv_i, self._riv_j, self._dn_rc, self._frac_fines,
                     self._SL)
        #-------------------------------------------------------

        """ Wetland sedimentation """
        ### no wetlands in first version of coupling to CEM ###
        # FP.wetlands(self._SL, self._WL_Z, self._WL_dist * self._dy,
        #             self._n, self._riv_i, self._riv_j, self._x, self._y)

        """ Subsidence """
        subside.linear_subsidence(self._n, self._riv_i, self._riv_j, self._ch_depth,
                                  self._SubRate, self._SubStart, self._SL)

        """ calculate sediment flux at the river mouth """
        self._sed_flux = flux.calc_qs(self._nu, self._riv_i, self._riv_j,
                                      self._n, self._SL, self._ch_depth,
                                      self._dx, self._dy, self._dt, self._slope)

        self._profile = self._n[self._riv_i, self._riv_j]

        # Update time
        self._time += self._dt
        # update sea level
        self._SL += self._SLRR
    def _init_from_dict(self, params):
        # seed random number generator
        np.random.seed(params['rand_seed'])

        # Spatial parameters
        self._dy = params['spacing'][0] * 1000.
        self._dx = params['spacing'][1] * 1000.

        n_rows = int(params['shape'][0])
        n_cols = int(params['shape'][1])

        # Initialize elevation grid
        # transverse and longitudinal space
        self._x, self._y = np.meshgrid(np.arange(n_cols) * self._dx,
                                       np.arange(n_rows) * self._dy)
        # eta, elevation
        n0 = params['n0']
        self._slope = params['nslope']
        self._max_rand = params['max_rand'] * params['nslope']
        self._n = n0 - (self._slope * self._y +
                        np.random.rand(n_rows, n_cols) * self._max_rand)
        self._n -= 0.05

        # self._dn_rc = np.zeros((self._imax))       # change in elevation along river course
        # self._dn_fp = np.zeros_like(self._n)     # change in elevation due to floodplain dep

        self._riv_i = np.zeros(1, dtype=np.int) # defines first x river locations
        self._riv_j = np.zeros(1, dtype=np.int) # defines first y river locations
        self._riv_j[0] = self._n.shape[1] / 2

        # Time parameters
        self._dt = params['dt_day'] * _SECONDS_PER_DAY # convert timestep to seconds
        self._time = 0.

        # Sea level and subsidence parameters
        self._SL = params['Initial_SL'] # starting sea level
        self._SLRR = params['SLRR_m'] / _SECONDS_PER_YEAR * self._dt # sea level rise rate in m (per timestep)
        self._SubRate = params['SubRate_m'] / _SECONDS_PER_YEAR * self._dt # subsidence rate in m (per timestep)
        self._SubStart = params['Sub_Start'] # row where subsidence begins

        # River parameters
        self._nu = ((8. * (params['ch_discharge'] / params['ch_width']) * params['A']
                    * np.sqrt(params['c_f'])) / (params['C_0'] * (params['sed_sg'] - 1)))
        ### NEED TO REDO DIFFUSE.PY TO HAVE SIGN OF NU CORRECT (NEG) ABOVE ###
        init_cut = params['init_cut_frac'] * params['ch_depth']
        self._super_ratio = params['super_ratio']
        self._short_path = params['short_path']
        self._ch_depth = params['ch_depth']

        # Floodplain and wetland characteristics
        self._WL_Z = params['WL_Z']
        self._WL_dist = params['WL_dist']
        self._blanket_rate = (params['blanket_rate_m'] / _SECONDS_PER_YEAR) * self._dt    # blanket deposition in m
        self._splay_type = params['splay_type']
        self._frac_fines = params['fine_dep_frac']

        self._sed_flux = 0.
        self._splay_deposit = np.zeros_like(self._n)

        # Saving information
        self._saveavulsions = params['saveavulsions']
        self._saveupdates = params['savecourseupdates']

        self._riv_i, self._riv_j = steep_desc.find_course(self._n, self._riv_i, self._riv_j,
                                                          len(self._riv_i), self._ch_depth,
                                                          sea_level=self._SL)

        # downcut into new river course by amount determined by init_cut
        downcut.cut_init(self._riv_i, self._riv_j, self._n, init_cut)

        # smooth initial river course elevations using linear diffusion equation
        diffuse.smooth_rc(self._dx, self._dy, self._nu, self._dt, self._ch_depth,
                          self._riv_i, self._riv_j, self._n, self._SL, self._slope)

        # initial profile
        self._profile = self._n[self._riv_i, self._riv_j]
        y[i][j] = j * dy
        if Linear == 1:
            n[i][j] = n0 - (nslope * float(x[i][j]) + max_rand*random())
        elif Concave == 1:
            n[i][j] = n0 - (drop * np.sqrt(x[i][j]) + max_rand*random())
        j += 1
    i += 1

# Determine initial river course
riv_x, riv_y = steep_desc.find_course(dx, dy, imax, jmax, n, riv_x, riv_y)

# downcut into new river course by amount determined by init_cut
n = downcut.cut_init(dx, dy, riv_x, riv_y, n, init_cut, Initial_SL)

# smooth initial river course elevations using linear diffusion equation
n, dn_rc = diffuse.smooth_rc(dx, dy, nu, dt, riv_x, riv_y, n, nslope)

# Determine initial river profile
profile = prof.make_profile(dx, dy, n, riv_x, riv_y, profile)

# make directories and save initial condition files
if savefiles == 1:
    # os.mkdir("run" + str(run_num) + "_out")
    os.mkdir("elev_grid")
    os.mkdir("riv_course")
    os.mkdir("profile")
    os.mkdir("dn_fp")
#   saves initial conditions
#    np.savetxt('elev_grid/elev_0.out', n, fmt='%f')
#    np.savetxt('riv_course/riv_0.out', zip(riv_x, riv_y), fmt='%i')
#    np.savetxt('profile/prof_0.out', profile, fmt='%f')