We present a tool for the modeling of optical circuits, both in the frequency and in the time domain. The tool is based on the definition of a node, which can have both an instantaneous input-output relation, as well as different state variables (e.g. temperature and carrier density) and differential equations for these states. Furthermore, each node has access to part of its input history, allowing the creation of delay lines or digital filters. Additionally, a node can contain subnodes which can be used to create hierarchical networks. This tool can be used in numerous applications such as frequency-domain analysis of optical ring filters, time-domain analysis of optical amplifiers, microdisks and microcavities. Furthermore, it can be used to study the effect of fabrication errors in nanophotonic integrated circuits. Although we mainly use this tool to model optical circuits, it can also be used to model other classes of dynamical systems, such as neural networks, financial modeling and electronical circuits.