clear all; clc; import com.comsol.model.* import com.comsol.model.util.* model = ModelUtil.create('Model'); model.modelPath('Z:\Staff\toenish\private\Comsol examples'); model.modelNode.create('mod1'); model.geom.create('geom1', 2); model.mesh.create('mesh1', 'geom1'); model.physics.create('es', 'Electrostatics', 'geom1'); model.study.create('std1'); model.study('std1').feature.create('stat', 'Stationary'); %% defingin geometry model.geom('geom1').lengthUnit('mm'); %% %ground plate model.geom('geom1').feature.create('r1', 'Rectangle'); model.geom('geom1').feature('r1').set('base', 'corner'); model.geom('geom1').feature('r1').set('pos', {'-10' '-1'}); model.geom('geom1').feature('r1').set('lx', '20'); model.geom('geom1').feature('r1').set('ly', '1'); model.geom('geom1').run('r1'); % HV electrode model.geom('geom1').feature.create('b1', 'BezierPolygon'); model.geom('geom1').feature('b1').set('p', {'0.5' '-0.5' '-2' '-2' '2' '2' '0.5' '0.5'; '10' '10' '11.5' '14' '14' '11.5' '10' '10'}); model.geom('geom1').feature('b1').set('w', {'1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1' '1'}); model.geom('geom1').feature('b1').set('degree', [1 1 1 1 1 1 1]); model.geom('geom1').run('b1'); model.geom('geom1').feature.create('fil1', 'Fillet'); model.geom('geom1').feature('fil1').set('radius', '.5'); model.geom('geom1').feature('fil1').selection('point').set('b1', [1 3 4 5]); model.geom('geom1').runAll; % water box model.geom('geom1').feature.create('r6', 'Rectangle'); model.geom('geom1').feature('r6').set('base', 'corner'); model.geom('geom1').feature('r6').set('pos', {'-12.5' '-1'}); model.geom('geom1').feature('r6').set('lx', '25'); model.geom('geom1').feature('r6').set('ly', '15'); model.geom('geom1').run('r6'); Letter = 'b'; Letter2 = 'fil'; n=2; div_mm=10; r = num2str(1/(div_mm*20)); i=0; j=100; Numb_plus_leter{n} = [Letter, num2str(n)]; fil = [Letter2, num2str(n)]; x1 = num2str(i/div_mm+0.5/(div_mm*10*sqrt(2))+0.5/(div_mm*10)); x3 = num2str((i-1)/div_mm-0.5/(div_mm*10*sqrt(2))-0.5/(div_mm*10)); x2 = num2str(i/div_mm-0.5/(div_mm*10*sqrt(2))+0.5/(div_mm*10)); x4 = num2str((i-1)/div_mm+0.5/(div_mm*10*sqrt(2))-0.5/(div_mm*10)); y1 = num2str(j/div_mm-0.5/(div_mm*10*sqrt(2))+0.5/(div_mm*10)); y3 = num2str((j-1)/div_mm+0.5/(div_mm*10*sqrt(2))-0.5/(div_mm*10)); y2 = num2str(j/div_mm+0.5/(div_mm*10*sqrt(2))+0.5/(div_mm*10)); y4 = num2str((j-1)/div_mm-0.5/(div_mm*10*sqrt(2))-0.5/(div_mm*10)); model.geom('geom1').feature.create(Numb_plus_leter{n}, 'BezierPolygon'); model.geom('geom1').feature(Numb_plus_leter{n}).set('p', {x1 x2 x3 x4 x1 x1; y1 y2 y3 y4 y1 y1}); model.geom('geom1').feature(Numb_plus_leter{n}).set('w', {'1' '1' '1' '1' '1' '1' '1' '1' '1' '1'}); model.geom('geom1').feature(Numb_plus_leter{n}).set('degree', [1 1 1 1 1]); model.geom('geom1').run(Numb_plus_leter{n}); model.geom('geom1').feature.create(fil, 'Fillet'); model.geom('geom1').feature(fil).set('radius', r); model.geom('geom1').feature(fil).selection('point').set(Numb_plus_leter{n}, [1 2 3 4]); model.geom('geom1').runAll; model.geom('geom1').run; model.save('test'); % saves it to server