Sun position
Declination δ = 23.45° sin(2π(284 + n)/365) (Cooper 1969), hour angle ω = 15°(t_solar - 12), altitude sin h = sinφ sinδ + cosφ cosδ cosω. The east and north components of the sun vector follow from the same angles, so azimuth is exact for the model but time is solar time (no equation of time, no daylight saving).
Clear sky and clouds
Air mass from Kasten and Young (1989). Beam DNI = I0 [(1 - 0.14 a) 0.7^(AM^0.678) + 0.14 a] (Meinel and Meinel 1976, a = altitude in km), diffuse DHI = I0 sin h (0.271 - 0.294 τ_b) (Liu and Jordan 1960). "Typical" weather mixes clear and overcast hours so that the mean equals a city clearness factor kc (rounded, approximate); overcast uses the Erbs, Klein and Duffie (1982) diffuse fraction. This is a model of average sky, not weather data: real yield varies year to year by several per cent.
Plane of array
G_poa = DNI cosθ · IAM + DHI (1 + cosβ)/2 + GHI ρ (1 - cosβ)/2, with cosθ the dot product of the sun vector and the roof normal, roof pitch β, ground reflectance ρ = 0.2 and a glass incidence-angle modifier IAM = 1 - b0 (1/cosθ - 1), b0 = 0.05. Isotropic sky (Liu-Jordan); anisotropic models such as Hay-Davies or Perez add a little at low sun.
Cell temperature and power
T_cell = T_amb + (NOCT - 20)/800 · G, NOCT = 47 C for an integrated roof tile. P = η A G (1 - γ(T_cell - 25)) · 0.97 with η = 19% (generic), γ = 0.35 %/K and 3% for wiring, soiling and mismatch. Each tile is 0.5 × 0.3 m (28.5 Wp).
Shading and bypass diodes
A ray from every tile centre toward the sun is tested against the chimney (a box) and the tree canopy (a sphere). A blocked tile loses its beam and keeps diffuse and ground light; a leafy tree lets 15% of the beam through, a bare one 85% (the tree is deciduous unless set to evergreen). Each column of tiles is one series string of three substrings with a bypass diode each. Series current is set by the weakest tile, so the string either lives with it or bypasses that substring; the model picks the better, which gives power in steps of one third. Strings of a slope share one maximum-power tracker and one voltage (parallel strings are not mismatch-modelled); partial shadow on a cell is treated as all or nothing at tile scale.
Inverter, battery and load
P_ac = min(0.96 · P_dc, P_rated), P_rated = array kWp / (DC/inverter ratio). Battery: self-consumption first, surplus charges, deficit discharges, no grid charging, round-trip efficiency 90% split evenly, 90% usable depth, power limit C/2. The daily load is a shaped profile scaled to the annual figure with a winter-heavy season. Self-consumption = useful solar energy / generation; self-sufficiency = 1 - import / load. Energy balance is checked to rounding error.
Optimum tilt
A tilted plane at the latitude sees the noon sun face-on at the equinox, but a year is not an equinox: low winter sun favours steeper tilt, high summer sun and diffuse light favour flatter. Tilt = latitude and the fit 0.76 × latitude + 3.1 are quoted rules of thumb; Experiment A computes the answer for this model. Cloudier places move the optimum toward flatter roofs.
Not modelled: snow, soiling in time, degradation, wind cooling, spectral effects, partial-cell shading, diffuse sky blocked by the tree, shadow from neighbouring buildings, and any tariff structure other than flat prices. The house and every product are generic; this is an education tool, not a design or quotation.