Skip to content
NAISS Logo
Allocations Support Training Software naiss.se

Comsol

General information

Installed versions

Resource Version
Arrhenius 6.4

Read information about how to load this software in your environment by searching for Lmod module.

How to use COMSOL on Arrhenius

COMSOL is a multiphysicas simulation software. You can check https://www.comsol.com for more information about the software itself. You need to have a valid license to be able to use it. If your institution hosts a license server for COMSOL, you need to make sure it is reachable from Arrhenius nodes. Please contact our support if your IT department is asking for IP range of Arrhenius nodes.

To check the installed versions, you can run:

module avail COMSOL

Please note that it is very likely for comsol to store a lot of temporary files on your home directory under .comsol folder by default. This can cause the storage to go above quota. You can direct these files to a different directory by specifying proper command line options (see the job scripts below).

How launch COMSOL in graphical mode

First you need to set your license server:

export LM_LICENSE_FILE=<your_license_server>

then you launch COMSOL in an interactive session

srun -A <allocation> --mem 2G -p cpu -t 1:00:00 --x11 comsol

How to run COMSOL in batch mode on CPUs

The following is a sample job sctipt to run COMSOL on 64 CPU cores

#!/bin/bash
#SBATCH -J comsol_cpu
#SBATCH -t 01:00:00
#SBATCH -A <allocation>
#SBATCH -c 64
#SBATCH -p cpu
#SBATCH -e error_file.e%J
#SBATCH -o output_file.o%J


module load COMSOL/6.4

export LM_LICENSE_FILE=<your_license_server>


work_dir=$(pwd)/temp
pref_dir=$work_dir/prefs
conf_dir=$pref_dir/configuration
data_dir=$pref_dir/data
rec_dir=$work_dir/recovery
tmp_dir=$work_dir/tmp


mkdir -p $pref_dir
mkdir -p $rec_dir
mkdir -p $tmp_dir
mkdir -p $conf_dir


comsol batch -np $SLURM_CPUS_PER_TASK -prefsdir $pref_dir -configuration ${conf_dir}/conf.${SLURM_JOBID} -data ${data_dir}/data.${SLURM_JOBID} -recoverydir ${rec_dir} -tmpdir ${tmp_dir} -inputfile input.mph -outputfile output.mph -batchlog my_output_file_$SLURM_JOBID

You can control number of cores by -np option. A single CPU node containing 256 cores should suffice for most of the COMSOL cases. If you think your problem is large enough to scale over several nodes, please contact support and we can assist you with running your case on multiple nodes.

How to run COMSOL in batch mode on GPUs

For using GPUs, you need to open your model in graphical mode and in the solver settings change solver to cuDSS. You also need to check the Multiple GPU box if you intend to use more than one GPU then save the new settings to the model file. The following is a sample job script for running COMSOL on single node using 2 GPUs and 144 CPU OpenMP thrrads (every GPU is given 72 CPU cres):

#!/bin/bash
#SBATCH -J comsol_gpu
#SBATCH -t 01:00:00
#SBATCH -A <allocation>
#SBATCH -p gpu
#SBATCH --gpus=2
#SBATCH -e error_file.e%J
#SBATCH -o output_file.o%J


module load GPU/COMSOL/6.4-bdist

export LM_LICENSE_FILE=<your_license_server>

work_dir=$(pwd)/temp
pref_dir=$work_dir/prefs
conf_dir=$pref_dir/configuration
data_dir=$pref_dir/data
rec_dir=$work_dir/recovery
tmp_dir=$work_dir/tmp


mkdir -p $pref_dir
mkdir -p $rec_dir
mkdir -p $tmp_dir
mkdir -p $conf_dir


comsol batch -np 144 -hwacc gpudouble -clusterstorage shared -prefsdir $pref_dir -configuration ${conf_dir}/conf.${SLURM_JOBID} -data ${data_dir}/data.${SLURM_JOBID} -recoverydir ${rec_dir} -tmpdir ${tmp_dir} -inputfile input.mph -outputfile output.mph -batchlog my_output_file_$SLURM_JOBID

If you think your problem is large enough to scale over several GPUs on multiple nodes (every node has 4 GPUs), please contact support and we can assist you with running your case on multiple nodes.

Using more advanced features of COMSOL

There is possible to run advanced features of COMSOL such as batch/parametric/cluster sweeps on Arrhenius. Please contact support if you are interested in running such cases and we will assist you with a job script.