About the COMSOL Model File Formats
This section describes the COMSOL file formats: MPH-files for applications and models, model files for Java, model files for MATLAB, and model files for VBA.
The Root Node
When you first open or create a new model, the root node () is the topmost level of the tree. By default, unnamed files are called Untitled.mph. The filename changes when the file is saved for the first time, but the root node Name does not change for this top level node. See The Root Settings Windows for details about the settings available when this node is clicked.
COMSOL MPH-Files
The default standard file format with the extension .mph. The files contain binary and text data. The mesh and solution data are stored as binary data, while all other information is stored as plain text.
You can quickly save and load MPH-files. All models and applications in the COMSOL Application Libraries in the modules are saved as MPH-files.
The MPH-files in the COMSOL Application Libraries can have three formats:
Solved MPH-files include all meshes and solutions. In the Application Libraries window these files appear with the icon . If the MPH-file’s size exceeds 25MB, a tooltip with the text “Large file” and the file size appears when you position the cursor at the node in the Application Libraries tree.
Compact MPH-files include all settings but have no built meshes and solution data to save space (a few compact MPH-files have no solutions for other reasons). You can open these to study the settings and to mesh and re-solve it. It is also possible to download the full versions — with meshes and solutions — of most of these through Application Library Update (see The Application Library Update Window). In the Application Libraries window these appear with the icon . If you hover the mouse cursor over a compact file in the Application Libraries window, a No solutions stored message appears. If a full MPH-file is available for download, the corresponding node’s context menu includes a Download File With Solution icon ().
There can also be preview files for application library model MPH-files that have not been downloaded.
File Locking
Only one user can open and edit an MPH-file at the same time. If you try to open an MPH-file that is already open in another user’s COMSOL Desktop, that MPH-file is locked, and you get an option to open the MPH-file in a read-only mode (click Open As Read-Only). That means that you can edit the model but you cannot save it unless you save the MPH-file under another name. When an MPH-file is locked, COMSOL creates a separate lock file with the same filename as the MPH-file plus the extension .lock, stored in the same directory as the locked MPH-file. If a lock file remains after all COMSOL Desktop sessions have ended (which can happen if the COMSOL Desktop session is ended in a nonstandard way), you can reset the lock when trying to open the file the next time by clicking Reset Lock and Open.
Model Files for Java
Editable script files that contain sequences of COMSOL commands as Java code (see the COMSOL Multiphysics Programming Reference Manual for more information about these commands). You can compile these Java files and run them as separate applications. Edit the files in a text editor to add additional commands. For parts of the model that appears under a component (such as the geometry, physics, and mesh), the default format is to include the component level in the Java code. If you want do not want to include the component level, clear the Generate code using component syntax check box on the Methods page under Application Builder in the Preferences dialog box.
Model Files for MATLAB
Model files for MATLAB are editable script files (M-files), similar to the model files for Java, for use with MATLAB. A model file for MATLAB contains a sequence of COMSOL commands as an M-file (extension .m). You can run these model files in MATLAB like any other M-file scripts. You can also edit the files in a text editor to include additional COMSOL commands or general MATLAB commands.
Model Files for VBA
Model files for VBA are editable script files (VBA-files), similar to the model files for Java, for use with VBA (Visual Basic for Applications) in Microsoft Excel®. A model file for VBA contains a sequence of COMSOL commands as a VBA-file (extension .vba). You can use these files from Excel® to access settings and data in COMSOL models.