COMSOL Multiphysics

Hint

Join the other COMSOL users in our Zulip Chat: Stream “#triton”, topic “Comsol user group”.

To check which versions of Comsol are available, run:

module spider comsol

Comsol in Triton is best run in Batch-mode, i.e. without the graphical userinterface. Prepare your models on your workstation and bring the ready-to-run models to triton. However, various settings must be edited in the graphical user interface. For this, using vdi.aalto.fi to connect to triton is advisable.

For detailed tutorials from COMSOL, see for example the Comsol Knowledge base articles Running COMSOL® in parallel on clusters and Running parametric sweeps, batch sweeps, and cluster sweeps from the command line.

Prerequsities of running COMSOL in Triton

There is a largish but limited pool of floating COMSOL licenses in Aalto University, so please be careful not launch large numbers of comsol processess that each consume a separate license.

  • Comsol uses a lot of temp file storage, which by default goes to $HOME. Fix a bit like the following:

    $ rm -rf ~/.comsol/
    $ mkdir /scratch/work/$USER/comsol_revoveries/
    $ ln -sT /scratch/work/$USER/comsol_revoveries/ ~/.comsol
    
  • You may need to enable access to the whole filesystem in File|Options –> Preferences –> Security: File system access:All files

    Figure showing the comsol security preferences dialog box: File system access: All files is highlighted.
  • Enable the “Study -> Batch and Cluster” as well as “Study -> Solver and Job Configurations” nodes in the “Show More Options dialog box you can open by right-clicking the study in the Model Builder Tree.

The cluster settings can be saved in comsol settings, not in the model file. The correct settings are entered in File|Options –> Preferences –> Multicore and Cluster Computing. It is enough to choose Scheduler type: “SLURM

Figure showing the cluster preferences dialog box: Scheduler type: Slurm is highlighted.

You can test by loading from the Application Libraries the “cluster_setup_validation” model. The model comes with a documentation -pdf file, which you can open in the Application Libraries dialogue after selecting the model.

COMSOL requires MPICH2 compatible MPI libraries:

$ module purge
$ module load comsol/5.6 intel-parallel-studio/cluster.2020.0-intelmpi

An example run in a single node

Use the parameters -clustersimple and -launcher slurm. Here is a sample batch-job:

#!/bin/bash

# Ask for e.g. 20 compute cores
#SBATCH --time=10:00:00
#SBATCH --mem-per-cpu=2G
#SBATCH --cpus-per-task=20

cd $WRKDIR/my_comsol_directory
module load Java
module load comsol/5.6
module load intel-parallel-studio/cluster.2020.0-intelmpi

# Details of your input and output files
INPUTFILE=input_model.mph
OUTPUTFILE=output_model.mph

comsol batch -clustersimple -launcher slurm -inputfile $INPUTFILE -outputfile $OUTPUTFILE -tmpdir $TMPDIR

Cluster sweep

If you have a parameter scan to perform, you can use the Cluster sweep node. The whole sweep only needs one license even if comsol launches multiple instances of itself.

First set up the cluster preferences, as described above.

Start by loading the correct modules in triton (COMSOL requires MPICH2 compatible MPI libraries). Then open the graphical user interface to comsol on the login node and open your model.

$ module purge
$ module load module load comsol/5.6 intel-parallel-studio/cluster.2020.0-intelmpi
$ comsol

Add a “Cluster Sweep” node to your study and a “Cluster Computing” node into your “Job Configurations” (You may need to first enable them in the “Show more options”. Check the various options. You can try solving a small test case from the graphical user interface. You should see COMSOL submitting jobs to the SLURM queue.

For a larger run, COMSOL can then submit the jobs with comsol but without the GUI:

$ comsol batch -inputfile your_ready_to_run_model.mph -outputfile output_file.mph -study std1 -mode desktop

See also how to run a parametric sweep from command line?

Since the sweep may take some time to finnish, please consider using tmux or screen to keep your session open.

Cluster computing controlled from your windows workstation

The following example shows a working set of settings to use triton as a remote computation cluster for COMSOL.

Prerequisities:

  • Store ssh-keys in pagent so that you can connect to triton with putty without entering the password.

  • Save / install putty executables locally, e.g. in Z:\putty:

    • plink.exe

    • pscp.exe

    • putty.exe

    Figure showing the comsol settings for Cluster Computing.

    In this configuration, sjjamsa is replaced with your username.

    Figure showing the comsol settings for Cluster Computing within the Job Configurations.