A design tool was formulated for optimizing the efficiency of inorganic, thin-film, photovoltaic solar cells. The solar cell can have multiple semiconductor layers in addition to antireflection coatings, passivation layers, and buffer layers. The solar cell is backed by a metallic grating which is periodic along a fixed direction. The rigorous coupled-wave approach is used to calculate the electron-hole-pair generation rate. The hybridizable discontinuous Galerkin method is used to solve the drift-diffusion equations that govern charge-carrier transport in the semiconductor layers. The chief output is the solar-cell efficiency which is maximized using the differential evolution algorithm to determine the optimal dimensions and bandgaps of the semiconductor layers.