Using the N2 diagram

Main takeaway

The N2 diagram is a fantastic interactive tool to understand and debug your OpenMDAO models. If you’re wondering how systems are organized, connected, or solved, an N2 is for you.

from IPython.display import YouTubeVideo; YouTubeVideo('42VtbX6CX3A', width=854, height=480)

Using the N2 diagram effectively

This lesson is really focused on the video more than any notebook content. This is because I want to introduce the N2, show what it means, and guide you through all of the buttons and options. We’ll also introduce some of the debugging practices using the N2, but these are also covered in other lessons in more detail, like how to debug solvers.

The OpenMDAO docs already cover the basics of creating N2 visualizations, so I will not repeat that here. Please consult that doc to see how to have OpenMDAO make N2s for your model – it’s easy!

The N2 diagram is closely related to the XDSM diagram, but is more detailed and information-dense. The N2 provides a comprehensive and interactive view of your model whereas the XDSM provides a more high-level view, often suited for publications and presentations.

Tips for debugging connections using N2s

  • Look at the off diagonals; see if anything is missing

  • Mouse over the names that you’re interested in

  • Click to keep connections and look around

  • Look at which ones are red or orange or come from auto-IVCs; are they correct? Should they be connected to something else?

Tips for debugging grouping using N2s

  • Take a look at your components and groups. Are they all where they should be? Can you group components in a different way that will make more intuitive sense for other users?

  • Are there places where you have a nonlinear solver around a group that doesn’t necessarily need one? also see how to debug solvers and [[Nested nonlinear solvers]]