How can I run COMSOL Multiphysics computations in batch mode?

Solution Number: 980
Title: How can I run COMSOL Multiphysics computations in batch mode?
Platform: All Platforms
Applies to: All Products
Versions: 3.5a, 4.0, 4.0a, 4.1
Created: January 30, 2006
Last Modified: February 24, 2011
Categories: Installation
Keywords:

Problem Description

How can I run COMSOL Multiphysics computations in batch mode?

Solution

COMSOL 4 and later

In COMSOL 4 and later, batch jobs can be submitted directly from the COMSOL Desktop. A batch job will be branched off from the GUI process:

  1. Select Show More Options from the View menu
  2. Right-click Study and add Batch

For a guided tutorial, please open the model library and select COMSOL_Multiphysics/Tutorial_Models/micromixer_batch. This tutorial was added in version 4.0a.

You can also submit a batch job from the command line. Here is an example (Linux)

comsol batch -inputfile in.mph -outputfile out.mph -job b1 -batchlog out.log

For mode details, see the COMSOL Installation and Operations guide, section Running COMSOL.

Using the COMSOL Livelink for MATLAB with batch jobs

If you run COMSOL Multiphysics with MATLAB, you can run your m-file in a session without the COMSOL Desktop. This is corresponds to running COMSOL in batch mode through an m-file.

On the Linux command line:

comsol server matlab "myscript4, exit" -nodesktop

On Windows, specify the target of the COMSOL shortcut to

C:\COMSOL41\bin\comsolserver.exe matlab "myscript4, exit" -nodesktop

  • The command above runs the file myscript4.m. The exit command is used to close the MATLAB session after the m-file run has completed. As an alternative you can insert an exit command in the m-file itself. The exit command is important if you use a job manager or scheduler for several different jobs.

COMSOL 3.5a and earlier

The general syntax for the command for starting COMSOL Batch is

comsol [< options >] batch [< target arguments >]

An example of using the comsol batch command on Linux is

comsol batch -input mymodel.mph

On Windows, run the following command:

comsolbatch.exe -input mymodel.mph

or

comsolbatch64.exe -input mymodel.mph

on 64-bit operating systems.

This command starts COMSOL Batch, solves the model in the Model MPH-file with the given file name using the active solver settings in the model, and stores the solution in the same file. For more command line options, please see the section The COMSOL Command in the COMSOL Installation and Operations Guide, version 3.5a.

Using the MATLAB interface of COMSOL Multiphysics 3.5a and earlier

If you run COMSOL Multiphysics with MATLAB, you can run your m-file in a session without the desktop and the splash screen. This is corresponds running COMSOL in batch mode through an m-file.

On the Linux command line:

comsol matlab -ml -nodesktop -ml -nosplash -mlr "myscript35a, exit"

On Windows, specify the target of the COMSOL shortcut to

c:\COMSOL35a\bin\comsol.exe matlab -ml /nodesktop -ml /nosplash -mlr "myscript35a, exit"

or use comsol64.exe if you have a 64-bit Windows operating system.

  • The command above runs the file myscript35a.m. The exit command is used to close the MATLAB session after the m-file run has completed. As an alternative you can insert an exit command in the m-file itself. The exit command is important if you use a job manager or scheduler for several different jobs.
  • Add a line flreport('off') at the beginning of the script to suppress any Java windows with progress bars during meshing and solving. If you have no display available, the run will crash if a Java window tries to open.

For more command line options, type comsol matlab -h or refer to the COMSOL Installation and Operations Guide, version 3.5a. For more informatin about the COMSOL commands for interfacing to MATLAB, see the COMSOL Multiphysics MATLAB Interface Guide and Reference Guide. All manuals are available from the menu Help->Help Desk.

Related Files

myscript35a.m 1 KB
myscript4.m 1 KB

Feedback

Poor | Excellent
Document quality?



Disclaimer

COMSOL makes every reasonable effort to verify the information you view on this page. Resources and documents are provided for your information only, and COMSOL makes no explicit or implied claims to their validity. COMSOL does not assume any legal liability for the accuracy of the data disclosed. Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark details.