Running COMSOL Multiphysics > The COMSOL Commands > COMSOL Commands on Macintosh

COMSOL Commands on Macintosh
Use the comsol command to start COMSOL products with detailed start-up options.
The general syntax of the COMSOL command is
comsol [<target>] [<options>] [<target arguments>]
where square brackets indicate optional arguments. The comsol command can be combined with optional targets to achieve various results. The following table lists the command and targets:
Requires LiveLinkfor MATLAB® license
The comsol command is located in the bin folder in the COMSOL installation directory.
INI Files
There is a number of .ini files in the maci64 subdirectory in the bin directory. It is sometimes recommended that you edit these files. 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 comsol batch, and similarly for the other COMSOL targets.
Options
You can enter various options after the COMSOL command and target. Table 21-14 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).
-docroot <path>
-np <no. of cores>
-mpmode throughput | turnaround | owner
-blas {auto} | mkl | acml | path
-c <path>
-tmpdir <path>
-version <target>
-data <path>
For the -tmpdir option, the COMSOL Multiphysics software uses the specified directory to store temporary files. Use the -prefsdir option to specify the directory where the COMSOL Multiphysics software stores the preference file.
Documentation and Application Libraries Root Directories
In a default COMSOL Multiphysics 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 Multiphysics installation root. Relocating the documentation and Application Libraries root directories can be useful for administering Application Library Update; see The Application Library Update Window.
Shared-Memory Options
Use the option -np to control the number of core and processors used. The default is to use all available cores and processors. You can also specify the number of cores as a preference on the Multicore and Cluster Computing page in the Preferences dialog box. To specify the number of cores manually, select the Number of cores check box to enter a number in the associated text field.
Depending on how loaded your machine is, you can control how COMSOL Multiphysics uses the available processors. The following options are available:
Sometimes you might want to experiment to find the options that work best for your configuration.
BLAS Options
BLAS is a set of functions for basic linear algebra operations. A large portion of the computational engine in COMSOL relies on BLAS. COMSOL provides the following BLAS-related options:
Table 21-29: COMSOL BLAS Options
Use a BLAS library specified using the option -blaspath or the environment variable COMSOL_BLAS_PATH.
MKL is distributed along with COMSOL Multiphysics.
If you want to use a different BLAS library than the default, 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/maci64 or somewhere in the standard search path. You must also provide the path to any sublibraries needed by the library. You can also set the search path to point to the directory where the library is installed. To do so, use the environment variable DYLD_LIBRARY_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.
COMSOL Commands
In additions to the options in Table 21-14, the standalone COMSOL command supports the following option:
-open <file>
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 syntax for the COMSOL Multiphysics server command is
comsol [<options>] server [<target arguments>]
The following target arguments are available for a COMSOL Multiphysics server command:
-user <user>
-port <port>
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.
Accessing the COMSOL Multiphysics Server Computer
To access the computer running the COMSOL Multiphysics server, simply log in on the server computer by using ssh or a similar command, then enter the comsol server command.
Login Information
When you start a COMSOL Multiphysics server for the first time, you are asked for a username and password. Select a username and a password, which the COMSOL software then uses in communications between the COMSOL Multiphysics client and the server. You must also specify a matching username and password on the settings page in the Model Navigator, which opens when you start the COMSOL Multiphysics client. The software writes this login information in the file login.properties. The login information is located in Library/Preferences/COMSOL/v52a/login.properties in your home directory.
Client-Server Security Issues
COMSOL 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 Library/Preferences/COMSOL/v52a/login.properties. This is important when using the COMSOL Multiphysics client-server configuration. Alternatively, start the COMSOL Multiphysics server with the -passwd nostore option, and clear Remember Password when connecting to the server. This ensures that your login information is not stored on file.
Once you start a COMSOL Multiphysics server, 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/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
comsol [<options>] mphclient [<target arguments>]
The following target arguments are available for a COMSOL Multiphysics client command.
-port <port>
-server <server name>
COMSOL Batch Commands
Use the COMSOL batch command to run COMSOL jobs without a GUI. You can 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 syntax for the COMSOL batch command is
comsol [<options>] batch [<target arguments>]
Its detailed target arguments are:
-inputfile <file name>
-outputfile <file name>
-job <job tag>
-study <study tag>
-pname <parameter name>
-plist <parameter value>
-batchlog <file name>
-checklicense <filename>
Example
To use the COMSOL Multiphysics software in batch mode to solve a model, run the following command:
comsol batch -inputfile in.mph -outputfile out.mph -study std1
This command starts COMSOL in batch mode, 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 out.mph.
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 COMSOL Compile Command
The COMSOL compile command compiles a model file for Java for use by the COMSOL batch command or for loading class files into the GUI. The syntax for the COMSOL compile command is
comsol [<options>] compile [<target arguments>] <file>.java
The Java file is mandatory. The following optional target arguments are available‘
-jdkroot <path>
-classpathadd <classpath>
COMSOL MATLAB Command
Use the COMSOL MATLAB command to access the COMSOL API through MATLAB. Type:
comsol mphserver matlab [<options>]
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 comsol mphserver matlab command:
-mlroot <path>
-host <hostname>
-port <hostname>