tree

tree(node, levels=[], max_depth=None)[source]

Displays the model tree.

This is a convenience function to visualize, in an interactive Python session, the branch of the model tree underneath a given node. It produces console output such as this:

>>> mph.tree(model/'physics')
physics
├─ electrostatic
│  ├─ Laplace equation
│  ├─ zero charge
│  ├─ initial values
│  ├─ anode
│  └─ cathode
└─ electric currents
   ├─ current conservation
   ├─ insulation
   ├─ initial values
   ├─ anode
   └─ cathode

Often the node would refer to the model’s root in order to inspect the entire model tree. The model object itself is therefore also accepted as an argument.

levels is used internally when traversing the model tree recursively. Specify max_depth to possibly limit the number of lower branches.

Note that this function performs poorly in client–server mode, the default on Linux and macOS, especially for complex models. The client–server communication introduces inefficiencies that do not occur in stand-alone mode, the default on Windows, where the model tree, i.e. the hierarchy of related Java objects, can be traversed reasonably fast.