Learn COMSOL-MULTIPHYSICS-SCRIPTING with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
1
Create 3D Geometry via Java API
Model model = ModelUtil.create('Model');
model.geom().create('geom1', 3);
model.geom('geom1').create('blk1', 'Block');
model.geom('geom1').feature('blk1').set('size', new double[]{1, 2, 3});
model.geom('geom1').run();
Create a simple 3D block geometry in COMSOL using Java API.
2
Parametric Sweep using MATLAB API
model.param.set('E', '200e9');
model.param.set('nu', '0.3');
model.study('std1').feature('param').set('plistarr', {'200e9','210e9','220e9'});
model.study('std1').run;
Perform a parametric sweep over different material properties.
3
Post-processing Results
Table table = model.result().numerical().create('tbl1', 'Table');
table.set('expr', 'temperature');
table.run();
double[] tempData = table.getReal();
Extract and plot simulation results programmatically.