In view of the diversity of the distributed generation control system and the influence on the simulation efficiency due to adoption of the user-defined model based on the basic elements of control systems, a control system compositional modeling method is proposed that consists in combining the basic elements into a number of functions. The corresponding compositional function values and derivatives can be accurately and highly efficiently found using the automatic differentiation technique, effectively increasing the computational efficiency of the simulation program while maintaining the code maintainability and scalability. This method is validated with an example.