COMSOL Commands on Windows
Use a COMSOL command to start COMSOL products with detailed start-up options.
The general syntax of the COMSOL commands is
<command> [<target>] [<options>] [<target arguments>]
where square brackets indicate optional arguments. There are several different commands (See <command> in the command syntax) that can be combined with optional targets to achieve various results. The table below lists the major available commands and targets (if the Availability column is empty, the command is always available):
Requires a LiveLinkfor MATLAB® license
The commands are available in the bin\win64 subdirectory in the COMSOL installation directory. The COMSOL installer sets up a few of the possible commands on your Start menu and your desktop. In Windows 8, 8.1, and 10, you can click the shortcut COMSOL Launchers on the Apps screen. This makes a folder with shortcuts to all COMSOL commands available.
To create additional customized commands, you can create shortcuts including all argument and put them on your desktop. You can also issue COMSOL commands in a command window. To conveniently access the command in a command window, you need to set up the Windows path to include the path bin\win64 in the COMSOL installation directory.
INI Files
For each launcher file, there is a corresponding .ini file in the same directory. It is sometimes recommended that these files are edited. For example, you can add options to any of the above commands by modifying the corresponding INI file. To change the option opt to value val, add the line
-Dopt = val
to the file comsol.ini. Change the file comsolbatch.ini for comsolbatch, and similarly for the other COMSOL targets.
In general, for a system property or option, you add -D as a command option. For example, to set the system property cs.precmp to val, use the command option -Dcs.precmd = val.
Options
You can enter various options after the COMSOL command and target. Table 22-2 lists the options (See [<options>] in the command syntax) available for all COMSOL commands. Always issue these options between the command and the target (if any).
-3drend ogl | dx9 | sw
-alloc native | scalable
-blas {auto} | mkl | blas | path
-c <path>
-clusterstorage all | single | shared
Cluster storage format. The single format does I/O only from the root node, while the shared format does I/O using distributed I/O operations. The shared format requires that all nodes have access to the same storage area and the same temporary storage area.
Path to a workspace directory for storing internal workspace information. The workspace directory is by default a subdirectory to the preference directory. The workspace directory is cleared when COMSOL is launched. When running in batch or cluster mode, add @process.id to get a unique identifier to the path (for example, -data /tmp/comsol_@process.id).
-docroot <path>
-mpmode throughput | turnaround | owner
-np <no. of cores>
-numafirst <numa number>
-numasets <no. of sets>
Number of NUMA sets.3 -numasets 1 represents the case where there is only one nonuniform memory access node — that is, the entire computer.
-tmpdir <path>
For the -tmpdir option, the COMSOL Multiphysics software uses the specified directory to store temporary files. As an alternative, you can use the COMSOL_TMPDIR environment variable. Use the -prefsdir option to specify the directory where COMSOL Multiphysics stores the preference file.
Remote Desktop and Graphics Rendering
For a Floating Network License, you can access COMSOL Multiphysics with a Windows Remote Desktop connection. This way of accessing COMSOL Multiphysics is only supported with the software rendering graphics option.
Documentation and Application Libraries Root Directories
In a default COMSOL installation, the documentation files are located in the directory doc under the installation root directory. You can use the -docroot option if you want to move the documentation directory to a different location. Similarly, use the -applicationsroot option if you want to move the Application Libraries root directory applications from its default location under the COMSOL installation root. Relocating the documentation and Application Libraries root directories can be useful for administering an Application Library update; see The Application Library Update Window.
Preference Migration
By default, most preference settings are migrated from a previous COMSOL Multiphysics version when you start an instance of a new COMSOL Multiphysics version. To change this behavior, start COMSOL Multiphysics using
comsol.exe -migrateprefs on
to force a migration of preferences from the previous version and then overwrite the current preferences, or
comsol.exe -migrateprefs off
to not migrate any preferences.
Using the automatic preference migration, preferences are only migrated from the most recent previous version, they are only migrated on first launch, and the preference migration is only done once.
Some preferences for settings such as the root directories for documentation and application libraries are not migrated.
It is also possible to import and export preference settings using the Preferences dialog box in the COMSOL Desktop.
Shared-Memory Options
Use the option -np to control the number of cores used. The default is to use all available cores (processing units).
Use the option -numasets to control the number of nonuniform memory access (NUMA) node sets that the COMSOL Multiphysics software should take into account. This is usually the number of processor sockets that the hardware is using. Note that -numasets 1 represents the case where there is only one nonuniform memory access node — that is, the entire computer. If you only set the -np option, the number of sockets is determined automatically so that sufficient number of sockets are used by default. The -np flag, together with the -numasets flag, decides the size of a NUMA set (that is, -np divided by -numasets). The purpose of -numafirst is to decide which processor core number to place the first NUMA set on (that is, the size of the NUMA set times numafirst).
Depending on how loaded the machine is, you can control how COMSOL Multiphysics uses the available processors with the -mpmode option. The following options are available:
Use the option -alloc to specify memory allocator type. The default is to use the native memory allocator for computers with less than eight cores and otherwise the scalable memory allocator. The scalable memory allocator can increase performance significantly for computers with many cores but uses more memory.
You can also specify the number of cores and sockets and the use of the scalable allocators as preferences on the Multicore and Cluster Computing page in the Preferences dialog box. To specify those numbers manually, select the Number of cores and Number of sockets check boxes to enter a number in the associated text fields. By default, all cores are used and the number of sockets are set automatically. If you lower the number of cores, it is good practice to also lower the number of sockets. The preference option for the scalable allocator is called Optimized for multicore. If you want to choose another memory allocator than the default setting, select the Memory allocator check box and the choose Native or Optimized for multicore.
BLAS Options
BLAS is a set of functions for basic linear algebra operations. A large portion of the computational engine in the COMSOL software relies on BLAS. The COMSOL software provides for the following BLAS-related options:
Use a BLAS library specified using the option -blaspath or the environment variable COMSOL_BLAS_PATH.
Both MKL and BLAS are distributed with COMSOL Multiphysics.
If you want to use a different BLAS library than the ones provided by COMSOL, make sure that COMSOL Multiphysics can find the library. The simplest way for COMSOL Multiphysics to find a library is to put it in /lib/win64 or somewhere in the standard search path. Also provide the path to any sublibraries needed by the library. Set the search path to point to the directory where the library is installed. To do so, use the environment variable PATH. Your library must support both the standard FORTRAN LAPACK interface and the standard FORTRAN BLAS interface. If your LAPACK and BLAS interface consists of several libraries, use the path to the LAPACK library.
Application Options
The following options are used to specify inputs to an application with command-line options.Find more information about these options in the section The Application Argument Node in the Application Builder Reference Manual.
-appargsfile <filename>
-appargfilelist <filenames>
COMSOL Commands for Applications
In additions to the options in Table 22-2, the standalone COMSOL command supports the following options on Windows:
-edit <file>
-open <file>
-run <file>
For example, use comsol -open myapp.mph to open an application. Applications can be run or edited with the two other options.
Changing The Background Color of the Graphics Window
To change the default blue color scheme for the background of the 3D Graphics window, you can start the COMSOL Multiphysics software with the following command-line option:
-Dcs.canvascolor=255,0,0,0,255,0
In this example, the background becomes red and green. The first three numbers are the RGB (red, green, blue) values for the top color, and the last three numbers are the RGB values for the bottom color, with interpolated hues in between those two colors. All numbers are between 0 and 255 (inclusive). This option is also available when running COMSOL Multiphysics on Linux and Macintosh.
COMSOL Multiphysics Server Commands
Use a COMSOL Multiphysics server command to start a COMSOL process ready to process computational requests. A COMSOL Multiphysics server listens for TCP/IP connections from COMSOL Multiphysics clients. A COMSOL Desktop can become a COMSOL Multiphysics client by connecting to a COMSOL Multiphysics server. The LiveLink™ for MATLAB® also needs to connect to a COMSOL Multiphysics server.
The Windows syntax for the COMSOL Multiphysics server command is
comsolmphserver [<options>] [<target arguments>]
The following target arguments are available for a COMSOL Multiphysics server command:
-login {info} | force | never | auto
Ask for login information. info means that only missing information is asked for. force resets the password. never requires that the login information is available. auto automatically creates a new username and password.
-multi {auto} | on | off
-passwd reset | nostore
-port <port>
Specify a TCP/IP port, <port>, to listen for attempts to connect. The <port> is the server port, or 0 for a random free port.
-user <user>
Accessing the COMSOL Multiphysics Server Computer
The server computer can be accessed in several ways. You can log in to a machine that is dedicated to a single person. You can also connect to the server computer by using Remote Desktop. Start the COMSOL Multiphysics server from the Start menu. If several people want to access a single Windows computer to run the COMSOL Multiphysics server, you must use Windows Terminal Server or another tool that allows multiple users to log in on the same Windows server. In some Windows versions, Microsoft® provides a Telnet Server with which you can log in through a terminal window. When using a terminal window to log in on Windows, use the comsolmphserver command to start the COMSOL Multiphysics server.
Login Information
When a COMSOL Multiphysics server is started for the first time, you are asked for a username and password. Select a username and a password, which COMSOL Multiphysics then uses in communications between the COMSOL Multiphysics client and the server. You must also specify a matching username and password in the Connect to Server dialog box. The software writes this login information in the subdirectory .comsol/v55/login.properties in your Windows home directory.
Client-Server Security Issues
COMSOL Multiphysics can operate in a client-server mode where COMSOL Multiphysics runs as a separate client and a server. COMSOL uses a TCP/IP connection to send data between the server and the client.
Always make sure that untrusted users cannot access the COMSOL login information. Protect the file .comsol/v55/login.properties in your home directory. This is important when running COMSOL Multiphysics in client-server mode. Alternatively, start the COMSOL Multiphysics server with the -passwd nostore option, and clear the Remember username and password check box when connecting to the server. This ensures that your login information is not stored on file.
Once a COMSOL Multiphysics server is started, a person with access to your login information could potentially connect to your COMSOL Multiphysics server. When a COMSOL Multiphysics client connects or disconnects from a remote computer, the COMSOL Multiphysics server displays a message. The connection from the client to the server is made with the TCP protocol.
The server and client are mutually authenticated using a challenge handshake authentication protocol, which means that login information cannot be easily obtained by someone eavesdropping on the network communication. The TCP connection between the client and the server is otherwise not encrypted. If you require encryption of the TCP connection, you can use third-party software based on protocols such as SSH or IPSEC.
To enhance security, you can limit the address range that can access the COMSOL Multiphysics server, both in your firewall and by changing the COMSOL Multiphysics server configuration. To limit the allowed address range in the server, edit the file <COMSOL Installation Directory>\bin\tomcat\conf\server.xml and find the lines:
<!-- To restrict access to the COMSOL server you can uncomment the block below.
and follow the instructions. The default port for the COMSOL Multiphysics server is 2036. You can change this by using the option -port <port> when launching COMSOL and COMSOL Multiphysics server.
Documentation Security Issues
To serve the COMSOL Desktop with documentation, COMSOL opens a separate documentation server on the client computer when you open the documentation.
To enhance security, you can limit the address range that can access the documentation server, both in your firewall and by changing the documentation server configuration. To limit the allowed address range in the server, edit the file <COMSOL Installation Directory>\doc\help\conf\server.xml and find the lines:
<!-- To restrict access to the documentation server you can uncomment the block below.
and follow the instructions. The default port for the documentation server is 8090. You can change this by using the option -docport <docport> when launching COMSOL Multiphysics.
COMSOL Multiphysics Client Commands
Use a COMSOL Multiphysics client command to start a COMSOL Desktop with a the Connect to Server dialog box open.
The syntax for the COMSOL Multiphysics client command is
comsolmphclient [<options>] [<target arguments>]
The following target arguments are available for a COMSOL Multiphysics client command:
-open <file>
-port <port>
-server <server name>
COMSOL Batch Commands
Use the COMSOL batch command to run COMSOL jobs without a user interface. Run both Model MPH-files and model files for Java with the COMSOL batch command. Model files for Java need to be compiled before running.
The Windows syntax for the COMSOL batch command is
comsolbatch [<options>] [<target arguments>]
Its detailed target arguments are:
-alivetime <seconds>
-batchlog <filename>
-checklicense <filename>
-classpathadd <classpath>
-inputfile <filename>
-job <job tag>
-jobfile <filename>
Specify a text file using the following format:
<inputfile0> <outputfile0>
<inputfile1>
<outputfile1>
<inputfile2>
<outputfile2>
-methodcall <tag>       -inputfile <filename>
Run a method call with the given tag. The file in <filename> contains the method call. See the documentation for model.methodCall() in the COMSOL Multiphysics Programming Reference Manual for additional input arguments that can be used from batch commands with -methodcall for passing input values as arguments to a method call.
-mode {batch} | desktop
Do not compute the model. This option is useful if you, for example, just want to run -clearsolution or -clearmesh on a model that already includes a solution or mesh and then save it, without a solution or mesh, without computing the model first.
-outputfile <filename>
-paramfile <filename>
-pindex <parameter indices>
-plist <parameter value>
-pname <parameter name>
Add extra command-line arguments using -prodargs followed by the arguments last in the call to COMSOL batch.
-stoptime <time to stop>
-study <study tag>
Stopping and Canceling a Batch Job
You can stop a batch job using the following command:
comsolbatch -stop <level> -inputfile <filename>
where <level> is the level to stop the process on. Set the level to a high value in order to stop as soon as possible. By default, it is set to 100. The -inputfile option indicates the filename of the model that another process is running. The inputfile arguments should be consistent with the one specified to launch another process. That is, either the same inputfile arguments should be provided or the -inputfile should be the same as the -outputfile specified to launch another process.
You can cancel a batch job using the following command:
comsolbatch -cancel -inputfile <filename>
The -inputfile option indicates the filename of the model that another process is running. The inputfile arguments should be consistent with the one specified to launch another process. That is, either the same inputfile arguments should be provided or the -inputfile should be the same as the -outputfile specified to launch another process.
Example
To use the COMSOL Batch mode to solve a model, run the following command:
comsolbatch -inputfile in.mph -outputfile out.mph -study std1
This command starts COMSOL Batch, solves the model in the Model MPH-file with the given filename (in.mph in this example) using the active solver settings in the model, and stores the solution in the out.mph. You can also use multiple sets of input files and output files, stored in a file using the -jobfile option.
The -study option directs COMSOL Multiphysics to run a certain study. The study is identified by its tag. In the COMSOL Desktop, select Show Name and Tag under Model Builder Node Label to see the tags of the jobs under Study within curly braces in the Model Builder. In the model object, determine the tags of the jobs by the command model.study().tags(). You can determine the name of each study by model.study(<tag>).name() using one of the job tags.
The -job option works similar to the -study option. It directs COMSOL Multiphysics to start a certain job. The job is identified by its tag. In the model object, determine the tags of the jobs by the command model.batch().tags(). You can determine the name of each job by model.batch(<tag>).name() using one of the job tags.
The -usebatchlic option makes COMSOL use batch licenses for the job. This option is equivalent to the Use batch license check box available in the Cluster Computing and Cluster Sweep study nodes. Using batch licenses for a cluster computing or cluster sweep job means that you can continue working in the COMSOL Desktop while the job is running using only a single FNL license.
For the -recover option, the working directory (where all .log, and .status files are generated) will contain the recovery file, which contains information about the recovery folder in the case that the COMSOL software stops working. If the -recover option is specified, the model from the recovery directory will be opened. If opening that model succeeds, a continue operation will be performed; otherwise, the input filename model will be simulated.
Ignoring Batch and Cluster Computing Settings
When -mode is batch (the default), all Batch and Cluster Computing settings are ignored: that is, Batch and Cluster Computing features will not start any batch jobs as they will do when you click Compute in the COMSOL Desktop.
When -mode is desktop, Batch and Cluster Computing settings will be used. This case corresponds to clicking Compute in the COMSOL Desktop. All paths in the Batch and Cluster Computing nodes must correspond to paths that you would set up in the COMSOL Desktop if you started it and clicked Compute instead of running the COMSOL batch command.
About Providing Parameters
You can provide parameters as parameter names and corresponding values using the -pname and -plist arguments, respectively. For example, -pname a,b -plist 1,2 corresponds to
model.param().set("a",1);
model.param().set("b",2);
which means that any global parameters with the same names are overwritten by these new values. The model will then use these new values. Also note that the model is saved with a new name that contains the parameter tuple. Parametric sweeps will work as if you set the global parameters a to 1 and b to 2 and then compute a parametric sweep. Multiple tuples (such as -plist 1,2,3,4) will be saved in multiple files.
The COMSOL Batch Commands for Updating Images in PowerPoint Presentations
The comsolpowerpointbatch command updates linked images in PowerPoint® presentations. The command is available on Windows only, and it requires that PowerPoint is installed. The command syntax is
comsolpowerpointbatch [<options>] [<target arguments>]
The following optional target arguments are available:
-update <path1;path2;path3>
-outputfolder <folder path>
-batchlog <filename>
-applications <path1;path2;path3>
-applicationnames <shortName1,shortName2,shortName3>
-applicationpaths <path1;path2;path3>
The COMSOL Compile Command
The comsolcompile command compiles a model file for Java for use by the COMSOL batch command or for loading class files into the GUI. With COMSOL Compiler, you can also use it to compile COMSOL applications into standalone executable applications. The Windows syntax for the COMSOL compile command is
comsolcompile [<options>] [<target arguments>] <file>.java
The Java file is mandatory. The following optional target arguments are available:
-classpathadd <classpath>
-jdkroot <path>
To compile an application in an MPH-file into a standalone executable application using COMSOL Compiler, use
comsolcompile <full path to MPH-file> [<compile arguments>]
The following arguments are available:
-icon <path>
-runtime default | ask | <path>
Specify where to store the runtime when running the application. The default option is the platform’s default location. The ask option asks the user for the location of the runtime when running the application. The <path> option provides a location where the runtime should be unpacked and stored. Only specify a path when compiling for a single platform.
-splash <path>
Options not given are taken from the application’s Compiler node, except for -outputdir and -platforms.
COMSOL Cluster Commands
All COMSOL cluster commands require a floating network license.
To start a COMSOL Desktop running in distributed mode interactively on a Windows cluster, type
mpiexec -n <number of nodes> comsolcluster.exe <options> [<target arguments>]
To start a COMSOL Multiphysics server running in distributed mode, for interactive use from a COMSOL Multiphysics client, on a Windows cluster, type
mpiexec -n 1 comsolmphserver.exe [<options>] <target arguments>] -cluster on : -n <number of nodes-1> comsolclustermphserver.exe <options> [<target arguments>]
Note that all options and target arguments need to be repeated twice, when using the above command.
To start a cross-platform COMSOL Desktop running in distributed mode interactively on a Windows cluster, type
mpiexec -n <number of nodes> comsolclusterxpl.exe <options> [<target arguments>]
To start a COMSOL batch command running in distributed mode on a Windows cluster, type
mpiexec -n <number of nodes> comsolclusterbatch.exe <options> [<target arguments>]
The following cluster commands are available:
The preferred way of starting COMSOL jobs is from the Job Configurations node in the COMSOL Desktop’s model tree.
Micromixer — Cluster Version: Application Library path COMSOL_Multiphysics/Tutorials/micromixer_cluster
If you need to start COMSOL cluster jobs from the command line, the preferred way is to use the comsolclusterbatch command because the comsolclustermphserver and comsolcluster commands require TCP/IP access from your client computer to the cluster node where COMSOL Multiphysics runs.
The Windows Configuration
Make sure that the Windows HPC Server working directory is set to point to the comsol command directory (<path to COMSOL install directory>
\bin\win64). The install directory must be shared between the nodes on your cluster. In some network configurations, the firewall prevents you from starting MPI on a shared executable. To register the executable with the firewall, use the clusrun command to execute the hpcfwutil command on all nodes (for instance, to register comsolclusterbatch) use clusrun /all hpcfwutil register comsolclusterbatch.exe <shared path to COMSOL install directory>\bin\win64\comsolclusterbatch.exe
Using Microsoft MPI and SMPD on Standalone Computers
If you do not have Windows HPC Server installed on your Windows computers, you can still use the COMSOL cluster commands if you install COMSOL and Microsoft MPI on each computer that you want to use in the cluster. On each computer, you must then run the command
smpd
which is located in the Microsoft MPI installation subfolder Bin, as the user that will run the MPI job. You can then start the distributed mode by replacing the previous mpiexec -n <number of nodes> syntax with
mpiexec -hosts <number of nodes> <list of computer names>
Here the mpiexec command is located in the same folder as smpd, and the local node should be listed first in the list of computer names if you want to run interactively. To start COMSOL Desktop in distributed mode, use the syntax
mpiexec -hosts <number of nodes> <list of computer names> comsolcluster.exe <options> [<target arguments>]
Example of the COMSOL Batch Command
Schedule a job with the command
mpiexec -n -1 comsolclusterbatch.exe -np 2 -inputfile <filename>
to run a COMSOL batch job on a number of computational nodes given by mpiexec. For further information about the mpiexec command and Windows HPC Server, consult the documentation that was shipped with the product and the online manuals.
Example of the COMSOL Multiphysics Server Command
When a COMSOL Multiphysics server cluster job is created, a preference directory must be set and be reachable from all nodes to avoid problems with the server login; see The COMSOL Commands and Login Information. The preferences can be generated by starting COMSOL Multiphysics server once on the head node using the following command:
comsolmphserver.exe -prefsdir <prefsdir>
where <prefsdir> is a preference directory common to all nodes.
When the COMSOL Multiphysics server is started on the cluster, the port number is written to standard output, so a standard output file and a standard error file must be set for the cluster job. To start a COMSOL Multiphysics server, schedule a job with the following command:
mpiexec -n 1 comsolmphserver.exe -np 2 -prefsdir <prefsdir> -cluster on :
-n <number of nodes-1> comsolclustermphserver.exe -np 2 -prefsdir <prefsdir>
You must be able to access the cluster node where the COMSOL Multiphysics server runs from the COMSOL Multiphysics client computer.
COMSOL MPI Options
The COMSOL cluster target arguments specify what MPI library to use and what Scalapack version to use. There are several implementations of MPI. COMSOL by default uses the Windows HPC Server libraries. The COMSOL software also supports most MPI implementations based on MPICH2. It is recommended that the default library is used. In addition, the COMSOL software includes a compatibility mode, which you activate by adding the option -mpi mpich2. When using this option, both the variables PATH and LD_LIBRARY_PATH must include the MPI implementation. It is also possible to use other MPI libraries based on MPICH2 using the option -mpipath <path to shared library>. The following options are available for COMSOL cluster commands:
-mpi {auto} | mpich2 | whpc2008 | user | path
-mpipath <file>
-scalapack {auto} | mpich2 | whpc2008 | user | path
The Cluster Computing study allows you to set up a batch job for submission to a Windows HPC Server job scheduler. There are several settings that you can configure in the comsol.ini file to get default settings:
-Dcs.scheduler=<IP or network address>
-Dcs.clusteruser=<Username on cluster>
-Dcs.rundir=<Where the model file is located on the cluster>
-Dcs.comsoldir=<Installation path to comsol on the cluster>
Additionally you can configure the following commands to get default settings:
-Dcs.precmd=<Command line>
-Dcs.postcmd=<Command line>
These two lines add commands prior to the comsol command and after the comsol command, respectively. You can add {nn} or {perhost} to any of these pre- and postcommands, which configures the Cluster Computing study to use the number of nodes and number of nodes on each host from the corresponding settings for the Cluster Computing study. For more information, see Cluster Computing.
COMSOL MATLAB Command
Use the COMSOL matlab command to access the COMSOL API through MATLAB. Enter the following command:
comsolmphserver matlab
which launches a COMSOL Multiphysics server in a console window, starts MATLAB, and connects MATLAB to the COMSOL Multiphysics server.
The following options are available for the comsolmphserver matlab command:
-host <hostname>
-mlroot <path>
-port <hostname>