# mthapachhetr2023/hydrocnhs-nitrogen_modeling architecture

> Architecture diagram of the GitHub repository mthapachhetr2023/hydrocnhs-nitrogen_modeling, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling
- Repository: https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling

## Overview

HydroCNHS is a research model for coupled hydrology, water quality, and human decision-making, extended to evaluate agricultural nitrogen policies in the Susquehanna River Basin. The main workflow configures a model, simulates hydrology and routing alongside agent decisions, computes nitrogen and sediment outcomes, and analyzes policy results. Calibration, sensitivity analysis, and publication figures are supporting research capabilities. Edges reflect the supplied excerpts, SOURCE INDEX references, or README; unsampled implementation details are not inferred.

Main entry points: [`src/hydrocnhs/hydrocnhs.py`](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/hydrocnhs.py) (Coupled simulator), [`src/abm_testing/abm_sim_integrated.py`](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/abm_sim_integrated.py) (Policy simulations), [`src/hydrocnhs/model_builder.py`](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/model_builder.py) (Model builder), [`src/hydrocnhs/calibration/ga_deap.py`](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/calibration/ga_deap.py) (Genetic calibration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Model setup and execution"]
  node_builder["Model builder<br/>[model_builder.py]"]
  node_simulator["Coupled simulator<br/>[hydrocnhs.py]"]
  node_collector["Result collector<br/>[data_collector.py]"]
end

subgraph group_natural["Natural systems"]
  node_abcd["ABCD runoff<br/>[abcd.py]"]
  node_gwlfrunoff["GWLF runoff<br/>[gwlf.py]"]
  node_pet["Hamon PET<br/>[pet_hamon.py]"]
  node_routing["Streamflow routing<br/>[routing.py]"]
  node_nitrogen["Nitrogen transport<br/>[nitrogen.py]"]
  node_sediment["Sediment transport<br/>[sediment.py]"]
end

subgraph group_agents["Agents and policies"]
  node_abmengine["ABM engine<br/>[abm.py]"]
  node_abmscript["ABM scripting<br/>[abm_script.py]"]
  node_policyagents["Policy and farm agents<br/>[abm_integrated.py]"]
  node_scenario["Policy simulations"]
end

subgraph group_analysis["Calibration and analysis"]
  node_caliconvert["Calibration conversion<br/>[convertor.py]"]
  node_caliga["Genetic calibration<br/>[ga_deap.py]"]
  node_indicators["Performance indicators<br/>[indicators.py]"]
  node_visual["Model visualization<br/>[visual.py]"]
  node_sensitivity["Sensitivity analysis"]
  node_figures["Policy figures"]
end

node_researcher(("Researcher"))

node_researcher -->|"configures model"| node_builder
node_builder -->|"loads ABM scripts"| node_abmscript
node_researcher -->|"runs scenarios"| node_scenario
node_scenario -->|"runs coupled model"| node_simulator
node_scenario -->|"uses agents"| node_policyagents
node_simulator -->|"runs runoff"| node_abcd
node_simulator -->|"runs runoff"| node_gwlfrunoff
node_simulator -->|"computes PET"| node_pet
node_simulator -->|"routes flow"| node_routing
node_simulator -->|"runs nitrogen"| node_nitrogen
node_simulator -->|"runs sediment"| node_sediment
node_simulator -->|"runs agents"| node_abmengine
node_simulator -->|"records results"| node_collector
node_caliga -.->|"formats parameters"| node_caliconvert
node_researcher -->|"calibrates parameters"| node_caliga
node_researcher -->|"analyzes sensitivity"| node_sensitivity
node_sensitivity -->|"samples scenarios"| node_scenario
node_scenario -->|"generates figures"| node_figures
node_researcher -->|"evaluates outputs"| node_indicators
node_researcher -->|"views results"| node_visual

click node_builder "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/model_builder.py"
click node_simulator "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/hydrocnhs.py"
click node_collector "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/data_collector.py"
click node_abcd "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/rainfall_runoff_model/abcd.py"
click node_gwlfrunoff "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/rainfall_runoff_model/gwlf.py"
click node_pet "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/rainfall_runoff_model/pet_hamon.py"
click node_routing "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/routing.py"
click node_nitrogen "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/water_quality_model/nitrogen.py"
click node_sediment "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/water_quality_model/sediment.py"
click node_abmengine "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/abm.py"
click node_abmscript "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/abm_script.py"
click node_policyagents "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/abm_integrated.py"
click node_scenario "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/abm_sim_integrated.py"
click node_caliconvert "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/calibration/convertor.py"
click node_caliga "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/calibration/ga_deap.py"
click node_indicators "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/indicators.py"
click node_visual "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/visual.py"
click node_sensitivity "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/sobol_sensitivity_analysis.py"
click node_figures "https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/publication_figures.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_builder,node_simulator,node_collector toneBlue
class node_abcd,node_gwlfrunoff,node_pet,node_routing,node_nitrogen,node_sediment toneAmber
class node_abmengine,node_abmscript,node_policyagents,node_scenario toneMint
class node_caliconvert,node_caliga,node_indicators,node_visual,node_sensitivity,node_figures toneRose
class node_researcher toneIndigo
```

## Components

### Model setup and execution

- [Model builder](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/model_builder.py): `src/hydrocnhs/model_builder.py`
- [Coupled simulator](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/hydrocnhs.py): `src/hydrocnhs/hydrocnhs.py`
- [Result collector](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/data_collector.py): `src/hydrocnhs/data_collector.py`

### Natural systems

- [ABCD runoff](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/rainfall_runoff_model/abcd.py): `src/hydrocnhs/rainfall_runoff_model/abcd.py`
- [GWLF runoff](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/rainfall_runoff_model/gwlf.py): `src/hydrocnhs/rainfall_runoff_model/gwlf.py`
- [Hamon PET](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/rainfall_runoff_model/pet_hamon.py): `src/hydrocnhs/rainfall_runoff_model/pet_hamon.py`
- [Streamflow routing](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/routing.py): `src/hydrocnhs/routing.py`
- [Nitrogen transport](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/water_quality_model/nitrogen.py): `src/hydrocnhs/water_quality_model/nitrogen.py`
- [Sediment transport](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/water_quality_model/sediment.py): `src/hydrocnhs/water_quality_model/sediment.py`

### Agents and policies

- [ABM engine](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/abm.py): `src/hydrocnhs/abm.py`
- [ABM scripting](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/abm_script.py): `src/hydrocnhs/abm_script.py`
- [Policy and farm agents](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/abm_integrated.py): `src/abm_testing/abm_integrated.py`
- [Policy simulations](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/abm_sim_integrated.py): `src/abm_testing/abm_sim_integrated.py`

### Calibration and analysis

- [Calibration conversion](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/calibration/convertor.py): `src/hydrocnhs/calibration/convertor.py`
- [Genetic calibration](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/calibration/ga_deap.py): `src/hydrocnhs/calibration/ga_deap.py`
- [Performance indicators](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/indicators.py): `src/hydrocnhs/indicators.py`
- [Model visualization](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/hydrocnhs/visual.py): `src/hydrocnhs/visual.py`
- [Sensitivity analysis](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/sobol_sensitivity_analysis.py): `src/abm_testing/sobol_sensitivity_analysis.py`
- [Policy figures](https://github.com/mthapachhetr2023/hydrocnhs-nitrogen_modeling/blob/main/src/abm_testing/publication_figures.py): `src/abm_testing/publication_figures.py`

### Other components

- **Researcher**

## Connections

- Researcher → Model builder: configures model (evidence: `README.md`)
- Model builder → ABM scripting: loads ABM scripts (evidence: `src/hydrocnhs/model_builder.py`)
- Researcher → Policy simulations: runs scenarios (evidence: `README.md`)
- Policy simulations → Coupled simulator: runs coupled model (evidence: `src/abm_testing/abm_sim_integrated.py`)
- Policy simulations → Policy and farm agents: uses agents (evidence: `src/abm_testing/abm_sim_integrated.py`)
- Coupled simulator → ABCD runoff: runs runoff (evidence: `src/hydrocnhs/hydrocnhs.py`)
- Coupled simulator → GWLF runoff: runs runoff (evidence: `src/hydrocnhs/hydrocnhs.py`)
- Coupled simulator → Hamon PET: computes PET (evidence: `src/hydrocnhs/hydrocnhs.py`)
- Coupled simulator → Streamflow routing: routes flow (evidence: `src/hydrocnhs/hydrocnhs.py`)
- Coupled simulator → Nitrogen transport: runs nitrogen (evidence: `src/hydrocnhs/hydrocnhs.py`)
- Coupled simulator → Sediment transport: runs sediment (evidence: `src/hydrocnhs/hydrocnhs.py`)
- Coupled simulator → ABM engine: runs agents (evidence: `README.md`)
- Coupled simulator → Result collector: records results (evidence: `src/hydrocnhs/hydrocnhs.py`)
- Genetic calibration → Calibration conversion: formats parameters
- Researcher → Genetic calibration: calibrates parameters (evidence: `README.md`)
- Researcher → Sensitivity analysis: analyzes sensitivity (evidence: `README.md`)
- Sensitivity analysis → Policy simulations: samples scenarios (evidence: `src/abm_testing/sobol_sensitivity_analysis.py`)
- Policy simulations → Policy figures: generates figures (evidence: `src/abm_testing/abm_sim_integrated.py`)
- Researcher → Performance indicators: evaluates outputs (evidence: `README.md`)
- Researcher → Model visualization: views results (evidence: `README.md`)
