Mathematical modeling of real-world physical systems requires the consistent
combination of a multitude of physical laws and phenomenological models. This
challenging task can be greatly simplified by hierarchically decomposing
systems into ultimately simple components. Moreover, the use of diagrams for
expressing the decomposition helps make the process more intuitive and
facilitates communication, even with non-experts. As an important requirement,
models have to respect fundamental physical laws such as the first and the
second law of thermodynamics. While some existing modeling frameworks make such
guarantees based on structural properties of their models, they lack a formal
graphical syntax. We present a compositional and thermodynamically consistent
modeling language with a graphical syntax. In terms of its semantics, we
essentially endow port-Hamiltonian systems with additional structural
properties and a fixed physical interpretation, ensuring thermodynamic
consistency in a manner closely related to the metriplectic or GENERIC
formalism. While port-Hamiltonian systems are inspired by graphical modeling
with bond graphs, neither the link between the two, nor bond graphs themselves,
can be easily formalized. In contrast, our syntax is based on a refinement of
the well-studied operad of undirected wiring diagrams. By combining a
compositional, graphical syntax with an energy-based, thermodynamic approach,
the presented modeling language simplifies the understanding, reuse, and
modification of complex physical models.