Nitrate Network Model
Function documentation
NitrateNetworkModel.StreamModel
— TypeStreamModel(
mc::ModelConstants,
nc::NetworkConstants,
mv::ModelVariables
)
The StreamModel structure is a wrapper around three other structures. ModelConstants
holds values of physical and process constants that do not change during the run. NetworkConstants
holds the specification of the links, their characteristics, and nitrate concentrations from the landscape. It will not change during the run, but is expected to be adapted for each management scenario. Finally, ModelVariables
holds the values that are calculated during the model run. All WatershedSim
functions will take the entire StreamModel
as an argument, so there is no need to pull out the component structures. It is also expected that users will use the file-based constructor StreamModel(::String, ::String)
.
NitrateNetworkModel.StreamModel
— MethodStreamModel(baseparams_file::String, network_file::String)
Constructs a StreamModel
based on inputs in two csv files. The files should be structured as follows:
- baseparams_file: columns "variable" and "value".
- network_file: many more columns.
NitrateNetworkModel.evaluate!
— Methodevaluate!(model::StreamModel; qgage::Float64, contrib_n_load_reduction::Union{nothing,Array{Float64,1}})
Main model function. Assumes that model.nc
has already been updated to reflect the desired management scenario, e.g. updates to model.nc.contrib_n_load_factor
or model.nc.feature
and model.nc.wetland_area
.
If a value for qgage is provided, the model will be run using that value as the flow measured at the link model.nc.gage_link
, which is used to assign flow values to all other links. Otherwise, the model will be run using model.nc.gage_flow
.
#TODO: the reason I'm doing it this way is because the nc struct is currently immutable. I could switch it to mutable, but I've been avoiding that due to potential performance regressions. I should test that, since this is introduces a funny assymetry in how different model parameters are handled.
NitrateNetworkModel.save_model_results
— Functionsave_model_results(model::StreamModel, filename::String)
Writes model results to csv file
Results access
These functions give ways of extracting key results from the model structure.
NitrateNetworkModel.get_outlet_nconc
— Functionget_outlet_nconc(model::StreamModel)::Float64
Gets nitrate concentration leaving outlet link
NitrateNetworkModel.get_avg_nconc
— Functionget_avg_nconc(model::StreamModel)::Float64
Gets link length-weighted nitrate concentration
NitrateNetworkModel.get_delivery_ratios
— Functionget_delivery_ratios(model::StreamModel)::Tuple{Vector{Float64}, Vector{Float64}}
Returns vectors with net delivery ratio and escape fraction for each link.