Cookbook
Five common edits to a working SWAT+ project. Each recipe lists the file to open, the line to change, and what to check after running. Every recipe assumes you start from a project that already runs successfully.
Add a new HRU¶
You need a new entry in hru.con, hru-data.hru, and a row in any companion table the new HRU points to that does not yet contain the records (topography.hyd, hydrology.hyd, soils.sol, ...).
- Open
hru.con. Append a new row, copying an existing row and bumping theid. Editarea,lat,lon,elev, andhru(the HRU index). Keepwstpointed at an existing weather station. - Open
hru-data.hru. Append a row with the sameidand a newname. Point itstopo,hydro,soil,lu_mgt,soil_plant_init,surf_stor,snow,fieldcolumns at names that exist in the corresponding tables. - Open
object.cntand update thehrucount andobjcount to reflect the new total. - Run. After the run, check
checker.outfor a new row matching the soil name. Ifusle_k,zmx,sumfclook wrong, yoursoils.solrow is incomplete.
References: hru-data.hru, *.con, object.cnt.
Swap the PET method¶
codes.bsn, field 3 (pet):
0: Priestley-Taylor.1: Penman-Monteith.2: Hargreaves.3: read frompet.cli.
Edit the value, save, run.
Penman-Monteith needs solar radiation, relative humidity, and wind. If those climate files are absent, the weather generator will fill them in, and the result will not match a station-driven Penman-Monteith run.
Hargreaves needs only minimum and maximum temperature. It is the right choice for sites with minimal climate data.
If you set pet = 3, also point pet_file (field 1 of codes.bsn) at a valid pet.cli and provide the daily-PET file it references.
Reference: codes.bsn.
Switch to Green-Ampt infiltration¶
codes.bsn, field 21 (gampt):
0: curve-number infiltration (default).1: Green-Ampt with Mein-Larson.
Green-Ampt runs on a sub-daily time step. Set step in time.sim to a non-zero value (the source supports step = 24 for hourly). Your precipitation file must contain sub-daily values; a daily .pcp will not be disaggregated for you.
After the run, look at basin_wb_aa.txt. The split between surq_gen and perc shifts when the method changes; if it does not, the run is still using curve number.
References: codes.bsn, time.sim.
Change the simulation period¶
time.sim:
day_start = 0: start January 1 ofyrc_start.day_start = N > 0: start on Julian day N ofyrc_start.day_end = 0: end December 31 ofyrc_end.day_end = N > 0: end on Julian day N ofyrc_end.
To shorten a run, change yrc_start and yrc_end. To set a warm-up that is excluded from the average-annual outputs, leave time.sim alone and set nyskip in print.prt.
Your climate files must contain data for every day of the simulation period. If they do not, SWAT+ writes a "file not found" or runs off the end of the file.
References: time.sim, print.prt.
Enable the carbon model¶
codes.bsn, field 14 (carbon):
0: static (legacy mineralization).1: C-FARM.2: Century.
For 1 or 2, also:
- Provide a
carb_coefs.cbnfile in the project folder. The Ames_sub1 dataset ships one you can copy. Ifcswat /= 0and nocarb_coefs.cbnis present, SWAT+ uses internal defaults and writes a notice todiagnostics.out. - Confirm
soil_plant.ini(orsoils.sol, depending on tool version) carries initial organic carbon by layer. Without realistic initial pools, the first decade of output is transient as pools spin up. - Turn on carbon outputs in
print.prt. Sethru_cband the per-pool outputs (hru_cbn_lyr,hru_cpool_stat,hru_cflux_stat, ...) todailyif you want to use the carbon notebook.
After the run, basin_carbon_aa.txt, hru_carbon_aa.txt, and the per-pool files appear in the output folder. If they are missing, the print switches were not on.
References: codes.bsn, carb_coefs.cbn, print.prt.