comsol-multiphysics.md 6.81 KB
Newer Older
Lukáš Krupčík's avatar
Lukáš Krupčík committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
COMSOL Multiphysics® 
====================



  

<span><span>Introduction
</span></span>
-------------------------

<span><span>[COMSOL](http://www.comsol.com)</span></span><span><span>
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.</span></span>

-   <span><span>[Structural Mechanics
    Module](http://www.comsol.com/structural-mechanics-module),
    </span></span>

-   <span><span>[Heat Transfer
    Module](http://www.comsol.com/heat-transfer-module),
    </span></span>

-   <span><span>[CFD
    Module](http://www.comsol.com/cfd-module),
    </span></span>

-   <span><span>[Acoustics
    Module](http://www.comsol.com/acoustics-module),
    </span></span>

-   <span><span>and [many
    others](http://www.comsol.com/products)</span></span>

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

<span><span>Execution
</span></span>
----------------------

<span><span>On the Anselm cluster COMSOL is available in the latest
stable version. There are two variants of the release:</span></span>

-   <span><span>**Non commercial**</span></span><span><span> or so
    called </span></span><span><span>**EDU
    variant**</span></span><span><span>, which can be used for research
    and educational purposes.</span></span>

-   <span><span>**Commercial**</span></span><span><span> or so called
    </span></span><span><span>**COM variant**</span></span><span><span>,
    which can used also for commercial activities.
    </span></span><span><span>**COM variant**</span></span><span><span>
    has only subset of features compared to the
    </span></span><span><span>**EDU
    variant**</span></span><span><span> available. <span
    class="internal-link"><span id="result_box" class="short_text"><span
    class="hps">More</span> <span class="hps">about
    licensing</span> will be posted <span class="hps">here
    soon</span>.</span></span>
    </span></span>

<span><span>To load the of COMSOL load the module</span></span>

``` 
$ module load comsol
```

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

``` 
$ module avail comsol
```

<span><span>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
Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
89
(VNC)](https://docs.it4i.cz/anselm-cluster-documentation/software/comsol/resolveuid/11e53ad0d2fd4c5187537f4baeedff33).</span></span>
Lukáš Krupčík's avatar
Lukáš Krupčík committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

``` 
$ xhost +
$ qsub -I -X -A PROJECT_ID -q qprod -l select=1:ncpus=16
$ module load comsol
$ comsol
```

<span><span>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.</span></span>

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

cd /scratch/$USER/ || exit

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

text_nodes < cat $PBS_NODEFILE

module load comsol
# module load comsol/43b-COM

ntask=$(wc -l $PBS_NODEFILE)

comsol -nn $ 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
```

<span><span>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).</span></span>

LiveLink™* *for MATLAB^®^
-------------------------

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

<span><span>LiveLink for MATLAB is available in both
</span></span><span><span>**EDU**</span></span><span><span> and
</span></span><span><span>**COM**</span></span><span><span>
</span></span><span><span>**variant**</span></span><span><span> of the
COMSOL release. On Anselm 1 commercial
(</span></span><span><span>**COM**</span></span><span><span>) license
and the 5 educational
(</span></span><span><span>**EDU**</span></span><span><span>) licenses
of LiveLink for MATLAB (please see the [ISV
Lukáš Krupčík's avatar
add  
Lukáš Krupčík committed
153 154 155
Licenses](../isv_licenses.html)) are available.
Following example shows how to start COMSOL model from MATLAB via
LiveLink in the interactive mode.</span></span>
Lukáš Krupčík's avatar
Lukáš Krupčík committed
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

``` 
$ xhost +
$ qsub -I -X -A PROJECT_ID -q qexp -l select=1:ncpus=16
$ module load matlab
$ module load comsol
$ comsol server matlab
```

<span><span>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.</span></span>

<span><span>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.</span></span>

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

cd /scratch/$USER || exit

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

text_nodes < cat $PBS_NODEFILE

module load matlab
module load comsol/43b-EDU

ntask=$(wc -l $PBS_NODEFILE)

comsol -nn $ server -configuration /tmp -mpiarg -rmk -mpiarg pbs -tmpdir /scratch/$USER &
cd /apps/engineering/comsol/comsol43b/mli
matlab -nodesktop -nosplash -r "mphstart; addpath /scratch/$USER; test_job"
```

This example shows how to run Livelink for MATLAB with following
Lukáš Krupčík's avatar
Lukáš Krupčík committed
201
configuration: 3 nodes and 16 cores per node. Working directory has to
Lukáš Krupčík's avatar
Lukáš Krupčík committed
202 203 204 205 206 207
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.