Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.qss = self.grid.add_zeros("node", "subsurface_water__discharge")
# Get the transmissivity parameter
# transmissivity is hydraulic condiuctivity times soil thickness
self.trans = hydraulic_conductivity * soil_thickness
if np.any(self.trans) <= 0.0:
raise ValueError("BasicStVs: Transmissivity must be > 0")
self.tlam = self.trans * self.grid._dx # assumes raster
# Run flow routing and lake filler
self.flow_accumulator.run_one_step()
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.K,
m_sp=self.m,
n_sp=self.m,
discharge_name="surface_water__discharge",
)
# Instantiate a LinearDiffuser component
self.diffuser = LinearDiffuser(
self.grid, linear_diffusivity=regolith_transport_parameter
)
# Call ErosionModel"s init
super(BasicCh, self).__init__(clock, grid, **kwargs)
# verify correct fields are present.
self._verify_fields(self._required_fields)
# Get Parameters and convert units if necessary:
self.m = m_sp
self.n = n_sp
self.K = water_erodibility
regolith_transport_parameter = regolith_transport_parameter
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.K,
m_sp=self.m,
n_sp=self.n,
discharge_name="surface_water__discharge",
)
# Instantiate a NonLinearDiffuser component
self.diffuser = TaylorNonLinearDiffuser(
self.grid,
linear_diffusivity=regolith_transport_parameter,
slope_crit=critical_slope,
nterms=number_of_taylor_terms,
)
# Call ErosionModel"s init
super(BasicCh, self).__init__(clock, grid, **kwargs)
# verify correct fields are present.
self._verify_fields(_REQUIRED_FIELDS)
# Get Parameters and convert units if necessary:
self.m = m_sp
self.n = n_sp
self.K = water_erodability
regolith_transport_parameter = regolith_transport_parameter
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.K,
m_sp=self.m,
n_sp=self.n,
discharge_name="surface_water__discharge",
)
# Instantiate a NonLinearDiffuser component
self.diffuser = TaylorNonLinearDiffuser(
self.grid,
linear_diffusivity=regolith_transport_parameter,
slope_crit=critical_slope,
nterms=number_of_taylor_terms,
)
self.m = m_sp
self.n = n_sp
self.climate_factor = climate_factor
self.climate_constant_date = climate_constant_date
time = [0, self.climate_constant_date, self.clock.stop + self.clock.step]
K = [
water_erodability * self.climate_factor,
water_erodability,
water_erodability,
]
self.K_through_time = interp1d(time, K)
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=K[0],
m_sp=self.m,
n_sp=self.n,
discharge_name="surface_water__discharge",
)
# Instantiate a LinearDiffuser component
self.diffuser = LinearDiffuser(
self.grid, linear_diffusivity=regolith_transport_parameter
)
self.qss = self.grid.add_zeros("node", "subsurface_water__discharge")
# Get the transmissivity parameter
# transmissivity is hydraulic condiuctivity times soil thickness
self.trans = hydraulic_conductivity * soil_thickness
if np.any(self.trans) <= 0.0:
raise ValueError("BasicStVs: Transmissivity must be > 0")
self.tlam = self.trans * self.grid._dx # assumes raster
# Run flow routing and lake filler
self.flow_accumulator.run_one_step()
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.K,
m_sp=self.m,
n_sp=self.m,
discharge_name="surface_water__discharge",
)
# Instantiate a LinearDiffuser component
self.diffuser = LinearDiffuser(
self.grid, linear_diffusivity=regolith_transport_parameter
)
#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + init_elev
mg['node']['topographic__elevation'] = z + numpy.random.rand(len(z))/1000.
#make some K values in a field to test
mg.at_node['K_values'] = 0.1+numpy.random.rand(nrows*ncols)/10.
print( 'Running ...' )
#instantiate the components:
fr = FlowAccumulator(mg, flow_director='D8')
sp = StreamPowerEroder(mg, './drive_sp_params.txt')
#load the Fastscape module too, to allow direct comparison
fsp = FastscapeEroder(mg, './drive_sp_params.txt')
#perform the loop:
elapsed_time = 0. #total time in simulation
while elapsed_time < time_to_run:
print(elapsed_time)
if elapsed_time+dt>time_to_run:
print("Short step!")
dt = time_to_run - elapsed_time
mg = fr.run_one_step()
#print 'Area: ', numpy.max(mg.at_node['drainage_area'])
#mg = fsp.erode(mg)
mg = fsp.erode(mg, K_if_used='K_values')
#mg,_,_ = sp.erode(mg, dt, node_drainage_areas='drainage_area', slopes_at_nodes='topographic__steepest_slope')
#add uplift
mg.at_node['topographic__elevation'][mg.core_nodes] += uplift*dt
elapsed_time += dt
super(BasicChSa, self).__init__(clock, grid, **kwargs)
# verify correct fields are present.
self._verify_fields(self._required_fields)
self.m = m_sp
self.n = n_sp
self.K = water_erodibility
# Create bedrock elevation field
soil_thickness = self.grid.at_node["soil__depth"]
bedrock_elev = self.grid.add_zeros("node", "bedrock__elevation")
bedrock_elev[:] = self.z - soil_thickness
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.K,
m_sp=self.m,
n_sp=self.n,
discharge_name="surface_water__discharge",
)
# Instantiate a weathering component
self.weatherer = ExponentialWeatherer(
self.grid,
soil_production__maximum_rate=soil_production__maximum_rate,
soil_production__decay_depth=soil_production__decay_depth,
)
# Instantiate a soil-transport component
self.diffuser = DepthDependentTaylorDiffuser(
>>> model.run_one_step(1.)
>>> model.model_time
1.0
"""
# Call ErosionModel"s init
super(BasicRtSa, self).__init__(clock, grid, **kwargs)
# verify correct fields are present.
self._verify_fields(self._required_fields)
# Set up rock-till boundary and associated grid fields.
self._setup_rock_and_till()
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.erody,
m_sp=self.m,
n_sp=self.n,
discharge_name="surface_water__discharge",
)
soil_thickness = self.grid.at_node["soil__depth"]
bedrock_elev = self.grid.add_zeros("node", "bedrock__elevation")
bedrock_elev[:] = self.z - soil_thickness
# Instantiate diffusion and weathering components
self.diffuser = DepthDependentDiffuser(
self.grid,
linear_diffusivity=self.regolith_transport_parameter,
soil_transport_decay_depth=soil_transport_decay_depth,
super(BasicChSa, self).__init__(clock, grid, **kwargs)
# verify correct fields are present.
self._verify_fields(_REQUIRED_FIELDS)
self.m = m_sp
self.n = n_sp
self.K = water_erodability
# Create bedrock elevation field
soil_thickness = self.grid.at_node["soil__depth"]
bedrock_elev = self.grid.add_zeros("node", "bedrock__elevation")
bedrock_elev[:] = self.z - soil_thickness
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.K,
m_sp=self.m,
n_sp=self.n,
discharge_name="surface_water__discharge",
)
# Instantiate a weathering component
self.weatherer = ExponentialWeatherer(
self.grid,
soil_production__maximum_rate=soil_production__maximum_rate,
soil_production__decay_depth=soil_production__decay_depth,
)
# Instantiate a soil-transport component
self.diffuser = DepthDependentTaylorDiffuser(
>>> model.run_one_step(1.)
>>> model.model_time
1.0
"""
# Call ErosionModel"s init
super(BasicRt, self).__init__(clock, grid, **kwargs)
# verify correct fields are present.
self._verify_fields(self._required_fields)
# Set up rock-till boundary and associated grid fields.
self._setup_rock_and_till()
# Instantiate a FastscapeEroder component
self.eroder = FastscapeEroder(
self.grid,
K_sp=self.erody,
m_sp=self.m,
n_sp=self.n,
discharge_name="surface_water__discharge",
)
# Instantiate a LinearDiffuser component
self.diffuser = LinearDiffuser(
self.grid, linear_diffusivity=self.regolith_transport_parameter
)