Why the wind blows. Air over sun-warmed land is lighter than air over the lake. The pressure of a warm column falls off with height more slowly, so aloft there is a push from land toward lake and, below it, a push from lake toward land. Bjerknes expressed this as a circulation that grows while the temperature contrast lasts. In the equations the density contrast is a torque on the flow: d(eta)/dt = -(g/theta0) d(theta)/dx + ..., where eta = du/dz - dw/dx is the vorticity in the plane, theta the potential temperature anomaly and theta0 = 300 K.
The model. Incompressible flow in the (x,z) plane is described by a streamfunction: u = d(psi)/dz, w = -d(psi)/dx, laplacian(psi) = eta. Each step the code (1) advects theta, eta and the along-shore wind v semi-Lagrangian, (2) adds heating, diffusion and the stable-layer term -w Gamma (Gamma = background lapse of potential temperature, K per km), (3) updates the vorticity from the horizontal temperature gradient, the Coriolis coupling f dv/dz and surface friction, then (4) solves the Poisson equation for psi exactly with a sine transform in x and a tridiagonal solve in z. The grid is 96 x 37 points with 500 m x 100 m spacing (48 km x 3.6 km); walls are free-slip and insulating.
Heating. Over land the sensible heat flux follows H(t) = H_max sin(pi (t - 6 h)/12 h) in the day and a gentler cooling of 30 % of that at night. It is spread over the lowest few hundred metres, dtheta/dt = H/(rho c_p) * exp(-z/z_h)/z_h, rho = 1.2 kg/m3, c_p = 1005 J/(kg K). The lake holds its temperature: the air over it relaxes toward the lake temperature with a 2 h time scale. So the air over the lake stays cooler by day and, if the lake is warm, can become warmer than the land at night, which flips the wind into a land breeze.
Coriolis. Earth's rotation, f = 2 Omega sin(latitude), turns the breeze to the right in the northern hemisphere, so a wind along the shore builds up. Linear theory (Rotunno 1983) says a circulation forced at the diurnal frequency (omega = 7.3e-5 /s) is largely suppressed poleward of the latitude where f = omega, which is 30 degrees. The latitude experiment tests whether this model shows the weakening.
Clouds. A rising parcel cools until its water vapour condenses at the lifting condensation level, about z_LCL = 125 m per K * (T - T_dew). A cloud sprite is drawn where the model updraft at that height is upward. This illustrates the idea; it is not a cloud-microphysics model.
Two independent checks. (1) The Poisson solver is fed the Laplacian of a known function; the exact inversion must return it (error at rounding level), and the discrete Laplacian is compared with the continuum value. (2) Heat budget: the integral of the temperature anomaly over the domain must equal the time integral of all heating terms. Semi-Lagrangian advection and the boundary treatment are not strictly conservative, so a few percent mismatch is normal and is reported.
Honest simplifications. A 2-D slice: no variation along the shore, no terrain or coastline curvature, no sea-breeze-front turbulence (resolved only at 500 m), no moisture feedback on buoyancy, no radiation, a single eddy diffusivity and a height-dependent friction time instead of a boundary-layer scheme, a fixed lake temperature. Speeds of a few m/s and the day-night swing are realistic for fair-weather lake breezes, but this is a teaching tool, not a forecast.