Analytical Calculation of Power Flow between Two Weakly Coupled Pendula and Its Application to an Optical Switch