## 2 Application and Methodology
### Water Quality Modeling Using SWAT  
SWAT was applied to simulate the outflow regime and nitrate concentration time series in the simulation period. Two types of inputs were required in this model: raster files as well as text files. A soil map, land use map, and digital elevation model were inserted as the raster files in the model. The model carried out two main processes, including watershed discretization and hydrological response units (HRUs) definitions, before the simulation. Calibration and validation of the outflow and nitrate load are key processes after the initial simulation using the model. Manual calibration and validation might be an arduous task for engineers. Hence, SWAT-CUP was developed as a standalone program to calibrate and validate the outputs of SWATs. This program calibrates the outputs using numerous iterations and tuning some hydrological parameters such as the curve number Figure 2 displays the slope map generated by the SWAT for the Tajan River basin as one of the required inputs for the simulation. It should be highlighted that we simulated the whole basin because of some technical considerations. For the accurate calibration and validation of the nitrate load for different crops, more simulated data were needed to increase the accuracy of the model. In this study, SWAT 2012 was used as an extension of ARCGIS to simulate river flow as well as nitrate load at the outlet of the selected downstream sub-basin. Moreover, SWAT-CUP 5.6.1.2 was applied in the calibration process in which the Sequential Uncertainty Fitting (SUFI2) algorithm was utilized to find the optimal calibration parameters. We selected four calibration parameters, i.e., CN2.mgt  
Figure 1: Land use and river network map of Tajan basin.  
(initial SCS runoff curve number for moisture condition II), ALPHA_BF.gw (alpha factor for groundwater recession curve of the deep aquifer (1/days)), GW_DELAY.gw (ground water delay time), and GWQMN.gw (threshold depth of water in a shallow aquifer required for return flow to occur (mm H\({}_{2}\)O)) in SWAT-CUP to calibrate the model. As the focus of this study was cropping pattern optimization, additional analyses such ash sensitivity analysis of the SWAT outputs were not carried out.  
The final output of the SWAT was the generated nitrate concentration time series in the simulated period for each crop per hectare. The outputs of the SWAT were utilized in the optimized model as described in the next section. The Nash-Sutcliffe model efficiency coefficient (NSE), RMSE observations' standard deviation ratio (RSR), and percent bias (PBIAS) were applied to measure the robustness of the performance in the validation period of the results as displayed in Equation (1) [21].  
\[\text{NSE}=1-\frac{\sum_{t=1}^{T}(\text{OBS}_{t}-\text{SIM}_{t})^{2}}{\sum_{t=1 }^{T}(\text{OBS}_{t}-\text{OBSm})^{2}} \tag{1}\]  
\[\text{RSR}=\frac{\sqrt{\sum_{t=1}^{T}(\text{OBS}_{t}-\text{SIM}_{t})^{2}}}{ \sqrt{\sum_{t=1}^{T}(\text{OBS}_{t}-\text{OBSm})^{2}}} \tag{2}\]  
\[\text{PBIAS}=100*\left(\frac{\sum_{t=1}^{T}(\text{OBS}_{t}-\text{SIM}_{t})}{ \sum_{t=1}^{T}(\text{OBS}_{t})}\right) \tag{3}\]  
where \(\text{OBS}_{t}\) is the observed or recorded data, \(\text{SIM}_{t}\) is the simulated data, and T is the total number of time steps. Finally, a regression relationship between river flow and nitrate concentration was generated based on the outputs of the SWAT, which was utilized in the structure for cropping pattern optimization. Table 1 shows the recommended thresholds of the above indices used in this study [21].  
Figure 2: Slope map of Tajan River basin.