Analytical solution for a Josephson-junction model with capacitance