To reduce the mass of underwater vehicles and the temperature gradient of battery racks, the methods of element birth and death is used to study topology optimization. First, with an objective function based on the minimum configuration flexibility, the optimization results can be obtained by varying the proportion of optimization. Second, the structural minimum temperature gradient is considered as the objective function to achieve a further topology optimization by varying the proportion of optimization. Finally, under the condition of a given topology optimization ratio, the thermal-stress coupled topology optimization is applied by changing the proportion of the thermal load to the stress load. The corresponding battery frame structures are obtained, and the correctness of the mathematical model is verified.