COMSOL

Revision as of 17:00, 17 May 2024 by Roberpj (talk | contribs)
Other languages:

Introduction

COMSOL is a general-purpose software for modelling engineering applications. We would like to thank COMSOL, Inc. for allowing its software to be hosted on our clusters via a special agreement.

Logo comsol blue 1571x143.png

We recommend that you consult the documentation included with the software under File > Help > Documentation prior to attempting to use COMSOL on one of our clusters. Links to the COMSOL blog, Knowledge Base, Support Centre and Documentation can be found at the bottom of the COMSOL home page. Searchable online COMSOL documentation is also available here.

Licensing

We are a hosting provider for COMSOL. This means that we have COMSOL software installed on our clusters, but we do not provide a generic license accessible to everyone. Many institutions, faculties, and departments already have licenses that can be used on our clusters. Alternatively, you can purchase a license from CMC for use anywhere in Canada. Once the legal aspects are worked out for licensing, there will be remaining technical aspects. The license server on your end will need to be reachable by our compute nodes. This will require our technical team to get in touch with the technical people managing your license software. If you have purchased a CMC license and will be connecting to the CMC license server, this has already been done. Once the license server work is done and your ~/.licenses/comsol.lic has been created, you can load any COMSOL module and begin using the software. If this is not the case, please contact our technical support.

Configuring your own license file

Our module for COMSOL is designed to look for license information in a few places, one of which is your /home folder. If you have your own license server, you can write the information to access it in the following format:

File : comsol.lic

SERVER <server> ANY <port>
USE_SERVER


Where <server> is your license server hostname and <port> is the flex port number of the license server: Put this file in the $HOME/.licenses/ folder.

Local license setup

For researchers wanting to use a new local institutional license server, firewall changes will need to be done to the network on both the Alliance (system/cluster) side and the institutional (server) side. To arrange this, send an email to technical support containing 1) the COMSOL lmgrd TCP flex port number (typically 1718 default) and 2) the static LMCOMSOL TCP vendor port number (typically 1719 default) and finally 3) the fully qualified hostname of your COMSOL license server. Once this is complete, create a corresponding comsol.lic text file as shown above.

CMC license setup

Researchers who own a COMSOL license subscription from CMC should use the following preconfigured public IP settings in their comsol.lic file:

  • Béluga: SERVER 10.20.73.21 ANY 6601 (IP changed May 18, 2022)
  • Cedar: SERVER 172.16.0.101 ANY 6601
  • Graham: SERVER 199.241.167.222 ANY 6601
  • Narval: SERVER 10.100.64.10 ANY 6601
  • Niagara: SERVER 172.16.205.198 ANY 6601

If initial license checkout attempts fail, contact <cmcsupport@cmc.ca> to verify they have your username on file.

Installed products

To check which modules and products are available for use, start COMSOL in graphical mode and then click Options -> Licensed and Used Products on the upper pull-down menu. For a more detailed explanation, click here. If a module/product is missing or reports being unlicensed, contact technical support as a reinstall of the CVMFS module you are using may be required.

Installed versions

To check the full version number of a comsol module either start comsol in gui mode and inspect the lower right corner messages window OR more simply login to a cluster and run the following commands:

[login-node:~] salloc --time=0:01:00 --nodes=1 --cores=1 --mem=1G --account=def-someuser
[login-node:~] module load comsol/6.2
[login-node:~] comsol batch -version
COMSOL Multiphysics 6.2.0.290

which in this case corresponds to COMSOL 6.2 Update 1. Note that only the first installation a new comsol release on a cluster uses the abbreviated 6.X format for the module version number. Further product-updates will all use the full version number by default. You must therefore manually load the latest module version to take advantage of all the latest features and bug fixes that are available since the software for the current module you are using will never be updated directly. Lastly, to check which comsol versions are available in the standard environment you have loaded [ StdEnv/2020 or StdEnv/2023 ] run the module avail comsol command. Or to check which comsol versions are available in ALL of the available standard environments use the more powerful module spider comsol command.

Submit jobs

Single compute node

Sample submission script to run a COMSOL job with eight cores on a single compute node:

File : mysub1.sh

#!/bin/bash
#SBATCH --time=0-03:00             # Specify (d-hh:mm)
#SBATCH --account=def-group        # Specify (some account)
#SBATCH --mem=32G                  # Specify (set to 0 to use all memory on each node)
#SBATCH --cpus-per-task=8          # Specify (set to 32or44 graham, 32or48 cedar, 40 beluga, 48or64 narval to use all cores)
#SBATCH --nodes=1                  # Do not change
#SBATCH --ntasks-per-node=1        # Do not change

INPUTFILE="ModelToSolve.mph"       # Specify input filename
OUTPUTFILE="SolvedModel.mph"       # Specify output filename

module load StdEnv/2020
module load comsol/6.1.0.357       # Specify a version

comsol batch -inputfile ${INPUTFILE} -outputfile ${OUTPUTFILE} -np $SLURM_CPUS_ON_NODE


Depending on the complexity of the simulation, COMSOL may not be able to efficiently use very many cores. Therefore, it is advisable to test the scaling of your simulation by gradually increasing the number of cores. If near-linear speedup is obtained using all cores on a compute node, consider running the job over multiple full nodes using the next Slurm script.

Multiple compute nodes

Sample submission script to run a COMSOL job with eight cores distributed evenly over two compute nodes. Ideal for very large simulations (that exceed the capabilities of a single compute node), this script supports restarting interrupted jobs, allocating large temporary files to /scratch and utilizing the default comsolbatch.ini file settings. There is also an option to modify the Java heap memory described below the script.


File : script-dis.sh

#!/bin/bash
#SBATCH --time=0-03:00             # Specify (d-hh:mm)
#SBATCH --account=def-account      # Specify (some account)
#SBATCH --mem=16G                  # Specify (set to 0 to use all memory on each node)
#SBATCH --cpus-per-task=4          # Specify (set to 32or44 graham, 32or48 cedar, 40 beluga, 48or64 narval to use all cores)
#SBATCH --nodes=2                  # Specify (the number of compute nodes to use for the job)
#SBATCH --ntasks-per-node=1        # Do not change

INPUTFILE="ModelToSolve.mph"       # Specify input filename
OUTPUTFILE="SolvedModel.mph"       # Specify output filename

module load StdEnv/2020
module load comsol/6.1.0.357       # Specify a version

RECOVERYDIR=$SCRATCH/comsol/recoverydir
mkdir -p $RECOVERYDIR

cp -f ${EBROOTCOMSOL}/bin/glnxa64/comsolbatch.ini comsolbatch.ini
cp -f ${EBROOTCOMSOL}/mli/startup/java.opts java.opts

# export I_MPI_COLL_EXTERNAL=0      # Uncomment this line on narval 

comsol batch -inputfile $INPUTFILE -outputfile $OUTPUTFILE -np $SLURM_CPUS_ON_NODE -nn $SLURM_NNODES \
-recoverydir $RECOVERYDIR -tmpdir $SLURM_TMPDIR -comsolinifile comsolbatch.ini -alivetime 15 \
# -recover -continue                # Uncomment this line to restart solving from latest recovery files


Note 1: If your multiple node job crashes on startup with a java segmentation fault, try increasing the java heap by adding the following two sed lines after the two cp -f lines. If it does not help, try further changing both 4g values to 8g. For further information see Out of Memory.

sed -i 's/-Xmx2g/-Xmx4g/g' comsolbatch.ini
sed -i 's/-Xmx768m/-Xmx4g/g' java.opts

Note 2: On Narval, jobs may run slow when submitted with comsol/6.0.0.405 to multiple nodes using the above Slurm script. If this occurs, use comsol/6.0 instead and open a ticket to report the problem. The latest comsol/6.1.X modules have not been tested on Narval yet.

Note 3: On Graham, there is a small chance jobs will run slow or hang during startup when submitted to a single node with the above script-smp.sh script. If this occurs, use the multiple node script-dis.sh script instead adding #SBATCH --nodes=1 and then open a ticket to report the problem.

Graphical use

COMSOL can be run interactively in full graphical mode using either of the following methods.

On cluster nodes

Suitable to interactively run computationally intensive test jobs using ALL available cores and memory reserved by salloc on a single cluster node:

1) Connect to a compute node (3-hour time limit) with TigerVNC.
2) Open a terminal window in vncviewer and run:
export XDG_RUNTIME_DIR=${SLURM_TMPDIR}
3) Start COMSOL Multiphysics 5.6 (or newer versions).
module load StdEnv/2020
module load comsol/6.1.0.357
comsol (uses all available cores by default)
4) Start COMSOL Multiphysics 5.5 (or older versions).
module load StdEnv/2016
module load comsol/5.5
comsol (uses all available cores by default)

On VDI nodes

Suitable interactive use on gra-vdi includes: running compute calculations with maximum of 12 cores, creating or modifying simulation input files, performing post-processing or data visualization tasks. Since each gra-vdi server is shared with many other users, we request you limit your COMSOL usage to 12 cores as shown below (especially when running long calculations) to not overload the system and potentially inconvenience others. For interactive and shorter meshing calculation, using 16 cores should be fine. If you need more cores when working in graphical mode, then use COMSOL on a cluster compute node (as shown above) where you can reserve up to all available cores and memory on a node and have exclusive use of the resource.

1) Connect to gra-vdi (no time limit) with TigerVNC.
2) Open a terminal window in vncviewer.
3) Start COMSOL Multiphysics 6.2 (or newer versions).
module load CcEnv StdEnv/2023
module avail comsol
module load comsol/6.2
comsol -np 12 (limits use to 12 cores)
4) Start COMSOL Multiphysics 6.2 (or older versions).
module load CcEnv StdEnv/2020
module avail comsol
module load comsol/6.1.0.357
comsol -np 12 (limits use to 12 cores)
5) Start COMSOL Multiphysics 5.5 (or older versions).
module load CcEnv StdEnv/2016
module avail comsol
module load comsol/5.5
comsol -np 12 (limits use to 12 cores)

Note: If all the upper menu items are greyed out immediately after COMSOL starts in GUI mode and therefore not clickable, then your ~/.comsol maybe corrupted. To fix the problem rename (or remove) your entire ~/.comsol directory and try starting COMSOL again. This could occur if you previously loaded a COMSOL module from the local SnEnv on gra-vdi.

Parameter sweeps

Batch sweep

When working interactively in the COMSOL GUI, parametric problems may be solved using the Batch Sweep approach. Multiple parameter sweeps maybe carried out as shown in this video. Speedup due to Task Parallism may also be realized.

Cluster sweep

To run a parameter sweep on a cluster, a job must be submitted to the scheduler from the command line using sbatch slurmscript. For a discussion regarding additional required arguments, see a and b for details. Support for submitting parametric simulations to the cluster queue from the graphical interface using a Cluster Sweep node is not available at this time.