COMSOL Multiphysics

Hint

We are continuing the COMSOL focus days in our daily zoom garage in Spring 2024: someone from COMSOL (the company) plans to join our zoom garage at 13:00 on the following Tuesdays: 2024-01-23, 2024-02-27, 2024-03-26, 2024-04-23, 2024-05-28.

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. 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. However, various settings must be edited in the graphical user interface.

Best practices of using COMSOL Graphical User Interface in Triton

  1. Connect to triton

    • Use Open OnDemand for the best experience for interactive work on triton.

    1. Connect to https://ood.triton.aalto.fi with your browser, log in. (It currently takes a while, please be patient.) Choose “My Interactive Sessions” from top bar, and then “Triton Desktop” from bottom. Launch your session, and once resources become available in triton, the session will be started on one of the interactive session nodes of triton. You can connect to a desktop in your browser with the “Launch Triton Desktop” button.

    2. Once you have connected, you can open a terminal (in XFCE the black rectangle in the bottom of the screen).

  • You can alternatively open a linux session in https://vdi.aalto.fi.

    1. Open a terminal, and connect with ssh to triton login node

    ssh -Y triton.aalto.fi
    

    However, if you use this terminal to start COMSOL, it will be running on the login node, which is a shared resource, and you should be careful not to use too much memory or CPUs.

  1. Start comsol

    1. First make sure you have graphical connection (should print something like “:1.0”)

      echo $DISPLAY
      
    2. then load the comsol module (version of your choice)

      module load comsol/6.1
      
    3. and finally start comsol

      comsol
      

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_recoveries/
    $ ln -sT /scratch/work/$USER/comsol_recoveries/ ~/.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/6.1 intel-parallel-studio/cluster.2020.0-intelmpi

A dictionary of COMSOL HPC lexicon

The knowledge base article Running COMSOL® in parallel on clusters explains the following meanings COMSOL uses:

COMSOL HPC lexicon

COMSOL

SLURM & MPI

node

task

A process, software concept

host

node

A single computer

core

cpu

A single CPU-core

However, COMSOL does not seem to be using the terms in a 100% consistent way. E.g. sometimes in the SLURM context COMSOL may use node in the SLURM meaning.

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/6.1
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 comsol/6.1 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. You can download an example file.

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.