According to Maxwell theory, the RF field in the RF cavity can be expressed by the modes of the cavity. And the characterizes of the cavity is determined by these modes, such as the frequencies and the fields. Because of sophisticated shapes of cavities, it's very difficult to calculate the modes of an actual cavity by using the usual methods. In this paper, an actual RF cavity is divided into two parts: the normal part (such as normal cylindrical cavity) and the abnormal parts. According Maxwell theory, there exists a coupling equation between the modes of the normal part and the modes of the cavity. In another words, the modes of the cavity can be expressed by the modes of the normal part. And by solving the coupling equation, frequencies and fields of the cavity's modes can be calculate