Skip to content
Snippets Groups Projects
Commit 15779630 authored by Jan Siwiec's avatar Jan Siwiec
Browse files

Update comsol-multiphysics.md

parent a7ef5dd2
Branches
Tags
No related merge requests found
Pipeline #40270 passed with warnings
...@@ -2,7 +2,11 @@ ...@@ -2,7 +2,11 @@
## Introduction ## Introduction
[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 (modules) such as electrical, mechanical, fluid flow, and chemical applications. [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 (modules)
such as electrical, mechanical, fluid flow, and chemical applications.
* [Structural Mechanics Module][b], * [Structural Mechanics Module][b],
* [Heat Transfer Module][c], * [Heat Transfer Module][c],
...@@ -34,7 +38,8 @@ To prepare COMSOL jobs in the interactive mode, we recommend using COMSOL on the ...@@ -34,7 +38,8 @@ To prepare COMSOL jobs in the interactive mode, we recommend using COMSOL on the
Example for Karolina: Example for Karolina:
```console ```console
$ salloc -A PROJECT_ID -p qexp --nodes=1 --ntasks=128 --cpus-per-task=1 --x11 $srun --account=PROJECT_ID --partition=qcpu --nodes=1 --ntasks=128 --cpus-per-task=1 --x11
$ ml av COMSOL $ ml av COMSOL
------------------------------ /apps/modules/phys ----------------------------- ------------------------------ /apps/modules/phys -----------------------------
...@@ -59,43 +64,57 @@ you need to run COMSOL with additional parameters: ...@@ -59,43 +64,57 @@ you need to run COMSOL with additional parameters:
$ comsol -3drend sw $ comsol -3drend sw
``` ```
To run COMSOL in batch mode without the COMSOL Desktop GUI environment, utilize the following (`comsol.pbs`) job script and execute it via the `salloc` command: To run COMSOL in batch mode without the COMSOL Desktop GUI environment,
utilize the following (`comsol.slurm`) job script and execute it via the `salloc` command:
```bash ```bash
#!/bin/bash #!/bin/bash
#SBATCH --nodes=3 --ntasks-per-node=128 --cpus-per-task=1 #SBATCH --nodes=3
#SBATCH -p qcpu #SBATCH --ntasks-per-node=128
#SBATCH -N JOB_NAME #SBATCH --cpus-per-task=1
#SBATCH -A PROJECT_ID #SBATCH --partition=qcpu
#SBATCH --job-name=JOB_NAME
#SBATCH --account=PROJECT_ID
cd /scratch/project/PROJECT_ID/ || exit cd /scratch/project/PROJECT_ID/ || exit
echo Time is `date` echo Time is `date`
echo Directory is `pwd` echo Directory is `pwd`
echo '**PBS_NODEFILE***START*******' echo '**SLURM_JOB_NODELIST***START*******'
cat $PBS_NODEFILE scontrol show hostname $SLURM_JOB_NODELIST
echo '**PBS_NODEFILE***END*********' echo '**SLURM_JOB_NODELIST***END*********'
text_nodes < cat $PBS_NODEFILE # Assign the number of tasks
ntask=$(scontrol show hostname $SLURM_JOB_NODELIST | wc -l)
# Load COMSOL module
ml COMSOL/5.2.0-EDU ml COMSOL/5.2.0-EDU
ntask=$(wc -l $PBS_NODEFILE) # Run COMSOL with SLURM options
comsol -3drend sw -nn ${ntask} batch -configuration /tmp \
comsol -3drend sw -nn ${ntask} batch -configuration /tmp –mpiarg –rmk –mpiarg pbs -tmpdir /scratch/project/PROJECT_ID/ -inputfile name_input_f.mph -outputfile name_output_f.mph -batchlog name_log_f.log –mpiarg –rmk –mpiarg slurm \
-tmpdir /scratch/project/PROJECT_ID/ \
-inputfile name_input_f.mph \
-outputfile name_output_f.mph \
-batchlog name_log_f.log
``` ```
A working directory has to be created before sending the (comsol.pbs) job script into the queue. The input file (name_input_f.mph) has to be in the working directory or a full path to the input file has to be specified. The appropriate path to the temp directory of the job has to be set by the `-tmpdir` command option. A working directory has to be created before sending the (`comsol.slurm`) job script into the queue.
The input file (name_input_f.mph) has to be in the working directory
or a full path to the input file has to be specified.
The appropriate path to the temp directory of the job has to be set by the `-tmpdir` command option.
### Starting a COMSOL Server ### Starting a COMSOL Server
Starting a COMSOL server on a compute node and then connecting to it through a COMSOL Desktop GUI environment is a convenient way of running calculations from GUI. To do so, you first need to submit a job with which you'll start the COMSOL server, for example: Starting a COMSOL server on a compute node and then connecting to it
through a COMSOL Desktop GUI environment is a convenient way of running calculations from GUI.
To do so, you first need to submit a job with which you'll start the COMSOL server, for example:
!!! Note !!! Note
You may be prompted to provide username and password. These can be different from your IT4Innovations credentials, and will be used during the authentication when trying to connect to the server from GUI. You may be prompted to provide username and password. These can be different from your IT4Innovations credentials, and will be used during the authentication when trying to connect to the server from GUI.
```bash ```bash
$ salloc -A PROJECT_ID -p qcpu_exp --nodes=1 --ntasks=36 --cpus-per-task=1 $ salloc --account=PROJECT_ID --partition=qcpu_exp --nodes=1 --ntasks=36 --cpus-per-task=1
salloc: Granted job allocation 694746 salloc: Granted job allocation 694746
salloc: Waiting for resource configuration salloc: Waiting for resource configuration
salloc: Nodes cn58 are ready for job salloc: Nodes cn58 are ready for job
...@@ -115,42 +134,51 @@ COMSOL is a software package for the numerical solution of partial differential ...@@ -115,42 +134,51 @@ COMSOL is a software package for the numerical solution of partial differential
LiveLink for MATLAB is available in both **EDU** and **COM** **variant** of the COMSOL release. On the clusters there is 1 commercial (**COM**) and 5 educational (**EDU**) licenses of LiveLink for MATLAB (see the [ISV Licenses][3]). The following example shows how to start COMSOL model from MATLAB via LiveLink in the interactive mode. LiveLink for MATLAB is available in both **EDU** and **COM** **variant** of the COMSOL release. On the clusters there is 1 commercial (**COM**) and 5 educational (**EDU**) licenses of LiveLink for MATLAB (see the [ISV Licenses][3]). The following example shows how to start COMSOL model from MATLAB via LiveLink in the interactive mode.
```console ```console
salloc -A PROJECT_ID -p qcpu_exp --nodes=1 --ntasks=128 --cpus-per-task=1 --x11 salloc --account=PROJECT_ID --partition=qcpu_exp --nodes=1 --ntasks=128 --cpus-per-task=1 --x11
$ ml <matlab_module> and <comsol_module> $ ml <matlab_module> and <comsol_module>
$ comsol -3drend sw server MATLAB $ comsol -3drend sw server MATLAB
``` ```
On the first start of the LiveLink for MATLAB (client-MATLAB/server-COMSOL connection), the login and password is requested; this information is not requested again. On the first start of the LiveLink for MATLAB (client-MATLAB/server-COMSOL connection), the login and password is requested; 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 `salloc` command. To run LiveLink for MATLAB in batch mode with (`comsol_matlab.slurm`) job script,
you can utilize/modify the following script and execute it via the `sbatch` command.
```bash ```bash
#!/bin/bash #!/bin/bash
#SBATCH --nodes=3 --ntasks-per-node=128 --cpus-per-task=1 #SBATCH --nodes=3
#SBATCH -p qcpu #SBATCH --ntasks-per-node=128
#SBATCH -N JOB_NAME #SBATCH --cpus-per-task=1
#SBATCH -A PROJECT_ID #SBATCH --partition=qcpu
#SBATCH --job-name=JOB_NAME
#SBATCH --account=PROJECT_ID
cd /scratch/project/PROJECT_ID || exit cd /scratch/project/PROJECT_ID || exit
echo Time is `date` echo Time is `date`
echo Directory is `pwd` echo Directory is `pwd`
echo '**PBS_NODEFILE***START*******' echo '**SLURM_JOB_NODELIST***START*******'
cat $PBS_NODEFILE scontrol show hostname $SLURM_JOB_NODELIST
echo '**PBS_NODEFILE***END*********' echo '**SLURM_JOB_NODELIST***END*********'
text_nodes < cat $PBS_NODEFILE # Assign the number of tasks
ntask=$(scontrol show hostname $SLURM_JOB_NODELIST | wc -l)
# Load modules
ml <matlab_module> and <comsol_module> ml <matlab_module> and <comsol_module>
ntask=$(wc -l $PBS_NODEFILE) # Run with Slurm options
comsol -3drend sw -nn ${ntask} server -configuration /tmp -mpiarg -rmk -mpiarg slurm -tmpdir /scratch/project/PROJECT_ID &
comsol -3drend sw -nn ${ntask} server -configuration /tmp -mpiarg -rmk -mpiarg pbs -tmpdir /scratch/project/PROJECT_ID &
cd $EBROOTCOMSOL/mli cd $EBROOTCOMSOL/mli
matlab -nodesktop -nosplash -r "mphstart; addpath /scratch/project/PROJECT_ID; test_job" matlab -nodesktop -nosplash -r "mphstart; addpath /scratch/project/PROJECT_ID; test_job"
``` ```
This example shows how to run LiveLink for MATLAB with the following configuration: 3 nodes and 128 cores per node. A working directory has to be created before submitting (comsol_matlab.pbs) job script into the queue. The input file (test_job.m) has to be in the working directory or a full path to the input file has to be specified. The MATLAB command option (`-r ”mphstart”`) created a connection with a COMSOL server using the default port number. This example shows how to run LiveLink for MATLAB with the following configuration:
3 nodes and 128 cores per node. A working directory has to be created
before submitting (`comsol_matlab.slurm`) job script into the queue.
The input file (`test_job.m`) has to be in the working directory
or a full path to the input file has to be specified.
The MATLAB command option (`-r ”mphstart”`) created a connection with a COMSOL server using the default port number.
[1]: licensing-and-available-versions.md [1]: licensing-and-available-versions.md
[2]: ../../../general/accessing-the-clusters/graphical-user-interface/vnc.md [2]: ../../../general/accessing-the-clusters/graphical-user-interface/vnc.md
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment