Learning Center

Course:

Getting Started with Building Simulation Apps

Modifying Command Sequences and Creating Methods to Customize App Operation


When developing a simulation app using the Application Builder in COMSOL Multiphysics, it is likely that you want to include buttons for performing various actions in the app. You can customize the actions that are triggered by any button in your simulation app by modifying the command sequences and creating Java methods using the Method Editor. Examples include a button that updates the graphical display to show the geometry (such as when a user has changed the dimensions of the design) or a button that computes the model then plays a certain sound to alert that the computation has finished. Learn how to make such further customizations here.

Tutorial: Command Sequences and Methods

The simplified thermal microactuator tutorial model is used for the model example, which a simulation app was developed for previously. Here, the simulation app is customized by making changes to the Compute button so that upon the computation finishing, a sound is played and a plot of the stress and deformation is displayed. Enabling these default settings requires adding to a linear sequence of commands. For more flexibility, the command sequence can be converted into a Java method and then continue to be edited by writing code. Topics covered in the tutorial video include the following:

  • Overview of command sequences
    • The Commands to Run section
    • Modifying the command sequence
  • Converting a command sequence into a method
  • Overview of the Method Editor
    • Writing code in the Method Editor
    • Using Ctrl+Space for code completion in the Method Editor
  • Referencing features from the model tree in methods
    • Enabling tags to display in the Model Builder window

Further Learning


Submit feedback about this page or contact support here.