tree¶
- tree(node, 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
Specify
max_depthto possibly limit the number of lower branches.Often the node would refer to the model’s root in order to inspect the entire model tree. A
Modelobject is therefore also accepted as a value fornode.Note that this function performs poorly in client–server mode, which is the default way to communicate with the Comsol backend. The client–server communication introduces inefficiencies that do not occur in stand-alone mode, where client and backend run in the same process, and the model tree, i.e. the hierarchy of related Java objects, can thus be traversed reasonably fast.