comsol-multiphysics.md 5.25 KB
Newer Older
Lukáš Krupčík's avatar
Lukáš Krupčík committed
1 2 3 4
# COMSOL Multiphysics

## Introduction

David Hrbáč's avatar
David Hrbáč committed
5
[COMSOL][a] is a powerful environment for modelling and solving various engineering and scientific problems based on partial differential equations. COMSOL is designed to solve coupled or multiphysics phenomena. For many standard engineering problems COMSOL provides add-on products such as electrical, mechanical, fluid flow, and chemical applications.
Lukáš Krupčík's avatar
Lukáš Krupčík committed
6

David Hrbáč's avatar
David Hrbáč committed
7 8 9 10 11
* [Structural Mechanics Module][b],
* [Heat Transfer Module][c],
* [CFD Module][d],
* [Acoustics Module][e].
* and [many others][f]
Lukáš Krupčík's avatar
Lukáš Krupčík committed
12 13 14 15 16 17 18 19 20

COMSOL also allows an interface support for equation-based modelling of partial differential equations.

## Execution

On the clusters COMSOL is available in the latest stable version. There are two variants of the release:

* **Non commercial** or so called **EDU variant**, which can be used for research and educational purposes.

David Hrbáč's avatar
David Hrbáč committed
21
* **Commercial** or so called **COM variant**, which can used also for commercial activities. **COM variant** has only subset of features compared to the **EDU variant** available. More about licensing [here][1].
Lukáš Krupčík's avatar
Lukáš Krupčík committed
22 23 24 25 26 27 28 29 30 31

To load the of COMSOL load the module

```console
$ ml COMSOL
```

By default the **EDU variant** will be loaded. If user needs other version or variant, load the particular version. To obtain the list of available versions use

```console
David Hrbáč's avatar
David Hrbáč committed
32
$ ml av COMSOL
Lukáš Krupčík's avatar
Lukáš Krupčík committed
33 34
```

David Hrbáč's avatar
David Hrbáč committed
35
If user needs to prepare COMSOL jobs in the interactive mode it is recommend to use COMSOL on the compute nodes via PBS Pro scheduler. In order run the COMSOL Desktop GUI on Windows is recommended to use the [Virtual Network Computing (VNC)][2].
Lukáš Krupčík's avatar
Lukáš Krupčík committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

Example for Salomon:

```console
$ xhost +
$ qsub -I -X -A PROJECT_ID -q qprod -l select=1:ppn=24
$ ml COMSOL
$ comsol
```

To run COMSOL in batch mode, without the COMSOL Desktop GUI environment, user can utilized the default (comsol.pbs) job script and execute it via the qsub command.

```bash
#!/bin/bash
#PBS -l select=3:ppn=24
#PBS -q qprod
#PBS -N JOB_NAME
#PBS -A PROJECT_ID

cd /scratch/work/user/$USER/ || exit   # on Anselm use: /scratch/$USER

echo Time is `date`
echo Directory is `pwd`
echo '**PBS_NODEFILE***START*******'
cat $PBS_NODEFILE
echo '**PBS_NODEFILE***END*********'

text_nodes < cat $PBS_NODEFILE

Lukáš Krupčík's avatar
Lukáš Krupčík committed
65 66
ml COMSOL
# ml COMSOL/51-EDU
Lukáš Krupčík's avatar
Lukáš Krupčík committed
67 68 69 70 71 72 73 74 75 76 77 78

ntask=$(wc -l $PBS_NODEFILE)

comsol -nn ${ntask} batch -configuration /tmp –mpiarg –rmk –mpiarg pbs -tmpdir /scratch/.../$USER/ -inputfile name_input_f.mph -outputfile name_output_f.mph -batchlog name_log_f.log
```

Working directory has to be created before sending the (comsol.pbs) job script into the queue. Input file (name_input_f.mph) has to be in working directory or full path to input file has to be specified. The appropriate path to the temp directory of the job has to be set by command option (-tmpdir).

## LiveLink for MATLAB

COMSOL is the software package for the numerical solution of the partial differential equations. LiveLink for MATLAB allows connection to the COMSOL API (Application Programming Interface) with the benefits of the programming language and computing environment of the MATLAB.

David Hrbáč's avatar
David Hrbáč committed
79
LiveLink for MATLAB is available in both **EDU** and **COM** **variant** of the COMSOL release. On the clusters 1 commercial (**COM**) license and the 5 educational (**EDU**) licenses of LiveLink for MATLAB (see the [ISV Licenses][3]) are available. Following example shows how to start COMSOL model from MATLAB via LiveLink in the interactive mode (on Anselm use 16 threads).
Lukáš Krupčík's avatar
Lukáš Krupčík committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

```console
$ xhost +
$ qsub -I -X -A PROJECT_ID -q qexp -l select=1:ppn=24
$ ml MATLAB
$ ml COMSOL
$ comsol server MATLAB
```

At the first time to launch the LiveLink for MATLAB (client-MATLAB/server-COMSOL connection) the login and password is requested and this information is not requested again.

To run LiveLink for MATLAB in batch mode with (comsol_matlab.pbs) job script you can utilize/modify the following script and execute it via the qsub command.

```bash
#!/bin/bash
#PBS -l select=3:ppn=24
#PBS -q qprod
#PBS -N JOB_NAME
#PBS -A PROJECT_ID

cd /scratch/work/user/$USER || exit   # on Anselm use: /scratch/$USER

echo Time is `date`
echo Directory is `pwd`
echo '**PBS_NODEFILE***START*******'
cat $PBS_NODEFILE
echo '**PBS_NODEFILE***END*********'

text_nodes < cat $PBS_NODEFILE

Lukáš Krupčík's avatar
Lukáš Krupčík committed
110 111
ml MATLAB
ml COMSOL/51-EDU
Lukáš Krupčík's avatar
Lukáš Krupčík committed
112 113 114 115 116 117 118 119

ntask=$(wc -l $PBS_NODEFILE)

comsol -nn ${ntask} server -configuration /tmp -mpiarg -rmk -mpiarg pbs -tmpdir /scratch/work/user/$USER/work &
cd /apps/cae/COMSOL/51/mli
matlab -nodesktop -nosplash -r "mphstart; addpath /scratch/work/user/$USER/work; test_job"
```

120
This example shows how to run LiveLink for MATLAB with following configuration: 3 nodes and 16 cores per node. Working directory has to be created before submitting (comsol_matlab.pbs) job script into the queue. Input file (test_job.m) has to be in working directory or full path to input file has to be specified. The Matlab command option (-r ”mphstart”) created a connection with a COMSOL server using the default port number.
David Hrbáč's avatar
David Hrbáč committed
121 122 123 124 125 126 127 128 129 130 131

[1]: licensing-and-available-versions.md
[2]: ../../../general/accessing-the-clusters/graphical-user-interface/x-window-system.md
[3]: ../../isv_licenses.md

[a]: http://www.comsol.com
[b]: http://www.comsol.com/structural-mechanics-module
[c]: http://www.comsol.com/heat-transfer-module
[d]: http://www.comsol.com/cfd-module
[e]: http://www.comsol.com/acoustics-module
[f]: http://www.comsol.com/products