While there is intense global research activity addressing problems underpinning the re-engineering of the electrical power grid, thermal energy grids are likely to play an increasing role in energy systems. This paper describes an on-going effort in hybrid modeling and co-simulation of the physical and control domains of district heating networks. The focus is on modeling each domain using semantics and tools natural to each; we also describe the challenges of, and a method for, integration and synchronization of the simulation models in each domain. Here, the dataflow model of computation used by Simulink provides a flexible industry-grade environment for modeling the dynamics of heat energy flows, and the IEC 61499 automation architecture facilitates distributed systems modeling and enables rapid deployment to field hardware. At the application level, we show how this framework enables the study of energy flows within a producer/consumer (prosumer) and the analysis of the economic value of integrating distributed solar thermal generation and storage into a prosumer participating in a district heating network.