Energy flow analysis is a fundamental tool to determine the network states of the integrated energy systems. For the widely deployed IES with coupled power grids (PG) and heating networks (HN), we still lack a generic tool that can be easily employed to calculate its quasi-dynamic energy flows. In this paper, we have developed a generic code package (named as MATHN) for energy flow analysis of the quality-regulated HN. Based on it, a generic solution framework that leverages MATPOWER and MATHN to realize decomposed energy flow calculation of PG and HN is further proposed. Behind the MATHN tool, a model reformulation technique is proposed to eliminate the massive indirect variables of the basic HN model discretized by finite difference, which finally derives a compact matrix formulation (similar to the network equation of power grid: I=YU) for generic description of any HN and also slashes the original model scale by around 20 times. Moreover, the solution strategy behind the MATHN tool further converts this matrix formulation into a standard system of non-homogeneous linear equations, with which some existing well-recognized algorithms can be directly employed for efficient and accurate solution. All the codes and input data are made open-source for non-commercial use.