Skip to content

Commit b99fb94

Browse files
committed
apps/comsol: Fix code blocks
1 parent 89394e1 commit b99fb94

File tree

1 file changed

+47
-45
lines changed

1 file changed

+47
-45
lines changed

triton/apps/comsol.rst

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COMSOL Multiphysics
1010
.. hint:: Join the other COMSOL users in our Zulip :ref:`chat`: Stream "#triton", topic "Comsol user group".
1111

1212

13-
To check which versions of Comsol are available, run::
13+
To check which versions of Comsol are available, run:
1414

1515
.. code-block:: console
1616
@@ -23,15 +23,15 @@ Best practices of using COMSOL Graphical User Interface in Triton
2323
-----------------------------------------------------------------
2424

2525
1) Connect to triton
26-
26+
2727
- Use :ref:`Open OnDemand<ood>` for the best experience for interactive work on triton.
28-
28+
2929
1) Connect to `<https://ondemand.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.
3030

3131
2) Once you have connected, you can open a terminal (in XFCE the black rectangle in the bottom of the screen).
32-
32+
3333
- You can alternatively open a linux session in `<https://vdi.aalto.fi>`_.
34-
34+
3535
1) Open a terminal, and connect with ssh to triton login node
3636

3737
.. code-block:: console
@@ -61,14 +61,14 @@ Best practices of using COMSOL Graphical User Interface in Triton
6161
$ comsol
6262

6363

64-
64+
6565
Prerequsities of running COMSOL in Triton
6666
-----------------------------------------
6767

6868
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.
69-
69+
7070
- Comsol uses a lot of temp file storage, which by default goes to
71-
``$HOME``. Fix a bit like the following::
71+
``$HOME``. Fix a bit like the following:
7272

7373
.. code-block:: console
7474
@@ -78,23 +78,23 @@ There is a largish but limited pool of floating COMSOL licenses in Aalto Univers
7878
7979
8080
- You may need to enable access to the whole filesystem in *File|Options --> Preferences --> Security*: **File system access:** "*All files*"
81-
81+
8282
.. image:: comsol_preferences_security.jpg
8383
:width: 50%
8484
:alt: Figure showing the comsol security preferences dialog box: File system access: All files is highlighted.
8585

8686
- 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.
87-
88-
8987

9088

9189

92-
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*"
90+
91+
92+
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*"
9393

9494
.. image:: comsol_preferences_cluster.jpg
9595
:width: 50%
9696
:alt: Figure showing the cluster preferences dialog box: Scheduler type: Slurm is highlighted.
97-
97+
9898
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.
9999

100100

@@ -111,40 +111,42 @@ The knowledge base article `Running COMSOL® in parallel on clusters <https://ww
111111

112112
* - COMSOL
113113
- SLURM & MPI
114-
-
114+
-
115115
* - node
116116
- task
117117
- A process, software concept
118118
* - host
119119
- node
120120
- A single computer
121121
* - core
122-
- cpu
122+
- cpu
123123
- A single CPU-core
124124

125125
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.
126126

127-
127+
128128
An example run in a single node
129129
-------------------------------
130130

131-
Use the parameters ``-clustersimple`` and ``-launcher slurm``. Here is a sample batch-job::
131+
Use the parameters ``-clustersimple`` and ``-launcher slurm``. Here is a sample batch-job:
132+
133+
.. code-block:: bash
132134
133-
#!/bin/bash
135+
#!/bin/bash
134136
135-
# Ask for e.g. 20 compute cores
136-
#SBATCH --time=10:00:00
137-
#SBATCH --mem-per-cpu=2G
138-
#SBATCH --cpus-per-task=20
137+
# Ask for e.g. 20 compute cores
138+
#SBATCH --time=10:00:00
139+
#SBATCH --mem-per-cpu=2G
140+
#SBATCH --cpus-per-task=20
139141
140-
cd $WRKDIR/my_comsol_directory
141-
module load comsol/6.3
142+
cd $WRKDIR/my_comsol_directory
143+
module load comsol/6.3
142144
143-
# Details of your input and output files
144-
INPUTFILE=input_model.mph
145-
OUTPUTFILE=output_model_$SLURM_JOB_ID.mph
145+
# Details of your input and output files
146+
INPUTFILE=input_model.mph
147+
OUTPUTFILE=output_model_$SLURM_JOB_ID.mph
146148
147-
comsol batch -clustersimple -launcher slurm -np $SLURM_CPUS_PER_TASK -inputfile $INPUTFILE -outputfile $OUTPUTFILE -tmpdir $TMPDIR
149+
comsol batch -clustersimple -launcher slurm -np $SLURM_CPUS_PER_TASK -inputfile $INPUTFILE -outputfile $OUTPUTFILE -tmpdir $TMPDIR
148150
149151
One would not expect to need ``-np $SLURM_CPUS_PER_TASK``, but in practice COMSOL does not always automatically limit the jobs to the number of cpus per task. Instead, COMSOL assumes all CPUs on the node are reserved for it, and there are more COMSOL process trying to run than there are CPUs available.
150152

@@ -163,7 +165,7 @@ If you have a parameter scan to perform, you can use the Cluster sweep node. The
163165
First set up the cluster preferences, as described above.
164166

165167

166-
Start by opening the graphical user interface to comsol on the login node and open your model. ::
168+
Start by opening the graphical user interface to comsol on the login node and open your model.
167169

168170
.. code-block:: console
169171
@@ -172,17 +174,17 @@ Start by opening the graphical user interface to comsol on the login node and op
172174
$ comsol
173175
174176
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 :download:`example file <ringing_plate_cluster_sweep.mph>`.
175-
176177

177-
For a larger run, COMSOL can then submit the jobs with comsol but without the GUI::
178+
179+
For a larger run, COMSOL can then submit the jobs with comsol but without the GUI:
178180

179181
.. code-block:: console
180182
181183
$ comsol batch -inputfile your_ready_to_run_model.mph -outputfile output_file.mph -study std1 -mode desktop
182184
183185
See also how to `run a parametric sweep from command line? <https://www.comsol.com/support/knowledgebase/1250>`_
184186

185-
187+
186188
Since the sweep may take some time to finnish, please consider using `tmux <https://github.com/tmux/tmux/wiki/Getting-Started>`_ or `screen <https://www.gnu.org/software/screen/manual/screen.html#Getting-Started>`_ to keep your session open.
187189

188190

@@ -196,13 +198,13 @@ It is possible to control COMSOL with MATLAB. The `blog post <https://knifelees3
196198
Save a username and password for COMSOL mph server
197199
**************************************************
198200

199-
Before your first use, you need to save the username and password for COMSOL mph server. On the login node, run::
201+
Before your first use, you need to save the username and password for COMSOL mph server. On the login node, run:
200202

201203
.. code-block:: console
202204
203205
$ module load comsol/6.3
204206
$ comsol mphserver
205-
207+
206208
And COMSOL will ask for you to choose a username and password. You can close the comsol server with "close".
207209

208210
Please note, that each instance of the below process uses a COMSOL licence, so this method is not useful for parameter scans.
@@ -233,53 +235,53 @@ Here is an example batch submit script ``comsol_matlab_livelink.sh``:
233235
# and this is an easy way to avoid clashes between multiple jobs.
234236
#SBATCH --nodes=1
235237
#SBATCH --exclusive
236-
237-
238+
239+
238240
module load matlab
239241
module load comsol/6.3
240-
242+
241243
242244
echo starting comsol server in the background
243245
comsol mphserver &
244246
echo comsol is now running
245-
247+
246248
matlab -nodesktop -nosplash -r "runner;exit(0)"
247249
echo matlab closed
248250
249251
250252
The MATLAB process is running the ``runner.m`` script:
251253

252-
.. code-block::
254+
.. code-block:: matlab
253255
254256
disp('Including comsol routines into the path.')
255257
addpath /share/apps/comsol/5.6/mli/
256258
257259
disp('Connecting to COMSOL from MATLAB')
258260
mphstart(2036)
259261
disp('Connection established')
260-
262+
261263
disp('Starting Model Control Script')
262264
263265
script;
264-
266+
265267
disp('Exiting Matlab')
266268
exit(0);
267269
268270
269271
The Model Control Script ``script.m`` could be e.g. the following:
270272

271-
.. code-block::
273+
.. code-block:: matlab
272274
273275
import com.comsol.model.*;
274276
import com.comsol.model.util.*;
275-
model = ModelUtil.create('Model1');
277+
model = ModelUtil.create('Model1');
276278
model.component.create('comp1', true);
277279
%...
278280
279281
280282
The job is submitted with:
281283

282-
.. code-block:: console
284+
.. code-block:: console
283285
284286
$ sbatch comsol_matlab_livelink.sh
285287
@@ -310,6 +312,6 @@ Prerequisities:
310312
:width: 50%
311313
:alt: Figure showing the comsol settings for Cluster Computing within the Job Configurations.
312314

313-
315+
314316
..
315317
/share/apps/spack/envs/fgci-centos7-generic/software/intel-parallel-studio/cluster.2020.0/ttn75qk/compilers_and_libraries_2020.0.166/linux/mpi/intel64/bin/mpirun

0 commit comments

Comments
 (0)