README - Code and data package (v7, 26 Nov 2026)
Paper: Year-Resolved Quasi-Static Time-Series Assessment of Photovoltaic
Hosting Capacity in a 59-Bus 22 kV Egyptian Distribution Network Model.

CONTENTS
Code:
  cairo59.py             network data (appendix of [11]) and pandapower construction
  pp_stub.py             construction-only fallback used when pandapower is not
                         installed; NOT the real pandapower, do not use for load flow
  qsts_core.py           vectorized backward/forward-sweep QSTS engine (Feeder)
  qsts_experiment.py     HC metric, methods, bootstrap summaries, binding hours
  profiles.py            PVGIS loading, PV model, assumed load shape
  profiles_empirical.py  national-scale load shape (Ember monthly x EEHC peak day)
  rev_core.py            per-year runner (methods on identical scenarios)
  run_all.py             19-year run, time shifts, slack 1.00 sensitivity
  run_extra.py           assumed-shape comparison run
  ext.py, ext2.py        thermal/tilt/load-level extensions
  thermal.py             Table III cases (thermal under assumed ratings, tilt, load)
  binding.py             binding-branch analysis of the 300 A case
  validate_solver.py     validates the sweep solver against REAL pandapower
                         (requires: pip install pandapower); see validate_solver.log
  test_monotone.py       monotonicity check behind the HC bisection (paper
                         Section III.E); see test_monotone.log
  build_doc3.py + doc_text3.py  rebuild the paper docx and figures from the results

Input data:
  cairo_pvgis_hourly_2005_2023-bccb95d5.csv  PVGIS-SARAH3 hourly, Cairo 30.04N 31.24E
  tilt30.csv                                 PVGIS plane-of-array, 30 deg south tilt
  egypt_load_shape_8760.csv                  national composite load shape

Results:
  rev_results.json        HC95 + CI per method, per year; shifts; slack 1.00
  rev_hc_YYYY_slack1.02.csv  per-scenario HC for every method, 2005-2023
  rev_thermal.json        Table III source data (incl. per-scenario HC, _hc)
  results_ext.json        tilt energy ratio, ratings, peak currents
  rev_extra.json          assumed-shape comparison
  rev_binding_horizontal.json/.csv  binding-branch analysis (271 violations)
  hc2_*.csv               per-scenario HC per constraint case (Table III)
  fig1_methods.png, fig2_binding.png, fig3_constraints.png
  run_all.log, validate_solver.log, test_monotone.log
  Paper2_QSTS_PV_Hosting_Capacity_Cairo59_v7.docx  the paper

RE-RUN ORDER
  python3 run_all.py            # 19 years, methods, shifts, slack 1.00 (~25 min)
  python3 run_extra.py          # assumed-shape comparison
  python3 thermal.py            # thermal/tilt/load cases (rev_thermal.json)
  python3 ext.py                # extension summaries (intermediate results_ext.json)
  python3 ext2.py               # per-scenario HC per case (hc2_*.csv) and the
                                # final results_ext.json read by build_doc3.py
  BKEY="horizontal|load1.0" python3 binding.py
  python3 build_doc3.py         # figures + docx (reads results_ext.json from ext2.py)
  python3 test_monotone.py      # monotonicity check (~8 min; chunked use: see its docstring)
  python3 validate_solver.py          [1]+[2], needs pandapower
  python3 validate_solver.py 3 0 5    # HC equality, scenarios 0-4
  python3 validate_solver.py 3 5 10   # HC equality, scenarios 5-9

NOTES
- v4 changes vs v3: test_monotone.py added - the monotonicity behind the HC
  bisection is now checked explicitly (full year and realistic snapshot hour,
  all 200 scenarios, 5% grid 5-400%, empirical 2019 series; bisection HC
  equals the brute-force grid HC for every scenario; see test_monotone.log)
  and is referenced from Section III.E and the data-availability statement;
  the III.B sentence on paper-1 violation counts was removed (no comparison
  script is part of the package); reference [18] now reads "submitted for
  publication, 2026"; stale references in code comments to internal scripts
  that were never part of the package (a paper-1 comparison script and the
  load-shape build script) were removed - the load shape is an included
  input CSV built outside this package (the Ember monthly factors and the
  digitised EEHC curve are not redistributed); RE-RUN ORDER now includes
  ext.py and ext2.py (ext2.py writes the final results_ext.json that
  build_doc3.py reads). No results, figures or numbers changed.
- v3 changes vs v2: abstract rewritten (result first, ~210 words); per-scenario
  snapshot-vs-full-year agreement added (Table I text); realistic-snapshot
  selection from the 8760 h series made explicit (III.F); conclusion tilt/load
  wording corrected (10 pp tilt = two grid steps, up to 5 pp load); 271/200
  branch violations printed as 1.36 per scenario; CI rounding conventions stated
  in table captions; references [5], [6], [8], [12] corrected/verified against
  Crossref/OSTI; the author's earlier study is now cited as [18] (under review);
  pandapower.py stub renamed to pp_stub.py with automatic fallback; real
  validate_solver.py added and run (base case matches published 218.9 kW /
  0.98646 p.u.; max |dV| 2.7e-9 p.u. over 40 random points; per-scenario HC
  identical to pandapower for 10 scenarios); v1 scratch files removed;
  requirements.txt and LICENSE added.
- Table II was confirmed against rev_hc_YYYY_slack1.02.csv after the PVGIS
  re-download (26 Nov 2026): full-year HC95 165-170 and worst-day dates match
  for every year 2005-2023 (table values rounded to the nearest 5% step).
- PVGIS files were re-downloaded 26 Nov 2026 from PVGIS-SARAH3 v5.3 (the
  originals were missing from the first package); 2019 base results reproduced.
- Solver validation was run with pandapower 3.5.6.

LICENSE
Code: MIT (see LICENSE). Data keep their original licenses: Ember CC BY 4.0;
PVGIS (c) European Union, JRC PVGIS terms of use; EEHC curve digitized from the
cited annual report (report not redistributed); network data republished from
the appendix of [11] (Sci. Rep., doi:10.1038/s41598-026-57051-x).
- v5 changes vs v4: data-availability statement now names the final 8760-h
  load-shape file; Section III.E states the scope of the monotonicity check
  (voltage limit, 2019, 1.02 p.u.); section number and a stale comment fixed.
  No results, figures or numbers changed.
- v6 changes vs v5: reference [5] now cites the ISGT 2019 paper (preprint
  NREL/CP-5D00-72284); author order of reference [7] corrected. No results
  or numbers changed.
- v7 changes vs v6: reference [5] gained its DOI (10.1109/ISGT.2019.8791569)
  and the v6 note's claim that 73304 is the slides was corrected (73304 is
  the NREL technical-report number for the same work); run_all.py now also
  writes main_2019._corr_legacy_vs_year, which build_doc3.py reads (without
  this line a fresh run_all.py + build_doc3.py failed with a KeyError);
  results_ext.json and hc2_*.csv were regenerated with the current PVGIS
  files - the shipped v6 copies predated the 26 Nov PVGIS re-download
  (HC95 and CIs unchanged; per-case means moved by at most one grid step);
  a full end-to-end re-run of the package was verified byte-identical
  against the shipped result files. No results, figures or numbers changed.
