Comsol Batch
Creating m File
Comsol Notes
Before Comsol can be used, users must run module load comsol
To run Comsol on the cluster, Comsol inputs must be in the form of Comsol Script (a .m file). Regular Comsol models may be exported as Comsol Script easily. Scripts must not have any plotting.
PBS Example
#PBS -N jobname
#PBS -q route
#PBS -M email@umich.edu
#PBS -V
#PBS -l nodes=1:ppn=4,software=COMSOL,mem=2gb,walltime=4:00:00
#comment
#Run comsol on 4 cpus assuming the solver supports it
echo "I ran on: "
cat $PBS_NODEFILE
#change to input directory
cd $PBS_O_WORKDIR
#run comsol script in batch,
# file is input.m, do not type .m here
comsol -np 4 batch input
Creating m Files
To create a comsol input for batch, users must create an 'm' file. m files are inputs to comsol script/batch and are text representations of a comsol model and solver.
To create an m file, setup a normal comsol problem and save it. Re-open the saved comsol problem and select File->Save As, Change the file type to m file and save. m files are regular text and may need editing, before they will run on the cluster.
Comsol Notes
Comsol LicensingPost Processing:There is a limited number of comsol tokens available. The CAC clusters are aware of this though. In the PBS example #PBS -l software=COMSOL will let the CAC cluster know that it should check that a comsol token is available before starting the job. This will prevent errors with licensing.
Comsol ScriptUse the function flsave() to save a solved FEM structure. Comsol normally calls your object xfem, when you have comsol generate your input for you. So to save xfem to a file output, use: flsave('output', xfem);. flsave writes a file that can be ether read back in in comsol script with fload() or most commonly, can be opened by the gui and post processed as though it had been run on that workstation.
Syntax error, Line 1, Column 1:The comsol input for batch is really a comsol script file. You can test the script on a workstation to verify it does what you wish. All commands in the input .m file is documented by running 'help command' in the comsol script window. Example: 'help flsave'.
Exception: com.femlab.util.FlException: Syntax error. Messages: Syntax error. - Line: 1 - Column: 1 - Type: Parse error
Cannot Find File:This is commonly because your input file starts with a number, eg 12input.m. Do not start input file names with a number. It confuses Comsol.
Exception:
com.femlab.util.FlException: Cannot find file.
Messages:
Cannot find file.
- Built-in function: javaMethod
- Callstack: geomimport 135 glr.jptr.smartRunner(report, 500);
test 18 garr = geomimport('/home/username/model.dxf');
HeadlessException, No X11 DISPLAY variable was set:Your model is using the function geoimport() to import a geometry from an external file. Be sure to copy the requested file to the cluster also, and update your input file as to the files new location. The best action is to place the model.dxf file in this case, into the same directory as you will be running comsol in your script. Then update your input to have just geomimport('model.dxf');.
No X11 DISPLAY variable was set, but this program performed an operation which requires it. (rethrown as com.femlab.util.FlFatalException) Messages: Fatal error. - Type: HeadlessException - Built-in function: newplot - Callstack: postnewplot 22 hAx=newplot(false); postplot 624 ax = postnewplot; test 214 postplot(fem, ...
You are trying to use a function (in this case postplot) that creates graphics on the screen. When running in batch inside PBS there is no screen. Comment out the plotting function lines. Try using flsave() to collect the data to plot later



