%clear all; import com.comsol.model.* import com.comsol.model.util.* % constants width=60; heightSiO2=4; erSiO2=11.7; % Relativni permitivita SiO2 depthSi=20; widthSi=30; heightSi=200; r0Beam=35.9; NX=115; dist=17.5; AirOverlap=90; widthAir=NX*dist+2*(AirOverlap+r0Beam); heightAir=100; depthAir=2*r0Beam+2*AirOverlap; model = ModelUtil.create('Model'); geom1 = model.geom.create('geom1', 3); currentUnit = geom1.lengthUnit(); geom1.lengthUnit('nm'); currentUnit = geom1.lengthUnit(); % ----------------------------------------------------------------------- % vytvoreni SiO2 wp2 = geom1.feature.create('wp2', 'WorkPlane'); wp2.set('planetype', 'quick'); wp2.set('quickplane', 'xy'); %wp2.set('quickz', '0'); r1 = wp2.geom.feature.create('rect1', 'Rectangle'); strsize=sprintf('%f %f',widthAir,depthAir); r1.set('size', strsize); strpos=sprintf('%f %f',(-AirOverlap-r0Beam),... (-AirOverlap-r0Beam)); r1.set('pos', strpos); c1 = wp2.geom.feature.create('circ1', 'Circle'); c1.set('r', r0Beam); c1.set('type', 'solid'); wp2.geom.feature.create('holes2D', 'Array'); wp2.geom.feature('holes2D').selection('input').set('circ1'); strsize=sprintf('%d %d',NX,1); wp2.geom.feature('holes2D').set('size',strsize); strdist=sprintf('%f %f',dist,0); wp2.geom.feature('holes2D').set('displ',strdist); % difference der for i=1:NX strselectionaux=sprintf('holes2D(%d,1)',i); strselection2(i)={strselectionaux}; end wp2.geom.feature.create('unionholes', 'Union'); wp2.geom.feature('unionholes').selection('input').set(strselection2); wp2.geom.feature('unionholes').set('intbnd','off'); % do not keep interior boundaries wp2.geom.feature.create('diffSiO2', 'Difference'); wp2.geom.feature('diffSiO2').selection('input').set('rect1'); wp2.geom.feature('diffSiO2').selection('input2').set('unionholes'); wp2.geom.feature('diffSiO2').set('intbnd','on'); % do not keep interior boundaries wp2.geom.feature('diffSiO2').set('keep','on'); model.save('d:/zlamal/zakazky/COMSOL/Kolibal/matlab model/test5.mph'); %Extrude SiO2 = geom1.feature.create('SiO2All', 'Extrude'); SiO2.selection('input').set('wp2.diffSiO2'); SiO2.set('keep','off'); SiO2.set('distance',heightSiO2); SiO2 = geom1.feature.create('O2All', 'Extrude'); SiO2.selection('input').set({'wp2.unionholes'}); SiO2.set('keep','off'); SiO2.set('distance',heightSiO2); model.save('d:/zlamal/zakazky/COMSOL/Kolibal/matlab model/test5.mph'); % ----------------------------------------------------------------------- % vytvoreni krateru wp1 = geom1.feature.create('wp1', 'WorkPlane'); wp1.set('planetype', 'quick'); wp1.set('quickplane', 'zx'); %wp2.set('quicky', '0'); b1 = wp1.geom.feature.create('b1', 'BezierPolygon'); b1.set('type', 'closed'); b1.set('degree', 1); b1.set('p', {'0' '-1.75' '-4.67' '-7.01' '-9.92' '-13.43' '-16.35' '-18.1' '-19.5' '-19.5' '0' '0'; ... '7.5' '7.5' '8.89' '9.549' '9.9254' '8.89' '7.24' '5.26' '3.29' '0' '0' '7.5'}); wp1.geom.feature.create('csol1', 'ConvertToSolid'); wp1.geom.feature('csol1').selection('input').set({'b1'}); %Revolve the pit = geom1.feature.create('pit', 'Revolve'); pit.selection('input').set({'wp1'}); pit.set('axis',{'1' '0'}); % kopirovani krateru a jeho sjednoceni geom1.feature.create('pits', 'Array'); geom1.feature('pits').selection('input').set('pit'); strsize=sprintf('%d %d %d',NX,1,1); geom1.feature('pits').set('size',strsize); strdist=sprintf('%f %f %f',dist,0,0); geom1.feature('pits').set('displ',strdist); % sjednoceni krateru geom1.feature.create('unionpits2', 'Union'); geom1.feature('unionpits2').selection('input').set({'pits(1,1,1)' 'pits(2,1,1)'}); geom1.feature('unionpits2').set('intbnd','off'); % do not keep interior boundaries for i=3:NX strname=sprintf('unionpits%d',i); geom1.feature.create(strname, 'Union'); strselection1=sprintf('unionpits%d',i-1); strselection2=sprintf('pits(%d,1,1)',i); union={strselection1 strselection2}; geom1.feature(strname).selection('input').set(union); geom1.feature(strname).set('intbnd','off'); % do not keep interior boundaries end % ----------------------------------------------------------------------- % ----------------------------------------------------------------------- % ted Air geom1.feature.create('Air', 'Block'); strsize=sprintf('%f %f %f',widthAir,depthAir,heightAir); geom1.feature('Air').set('size', strsize); strpos=sprintf('%f %f %f',(-AirOverlap-r0Beam),... (-AirOverlap-r0Beam),heightSiO2); geom1.feature('Air').set('pos', strpos); % ----------------------------------------------------------------------- %To run the sequence, enter fprintf('run\n'); %model.geom('geom1').run; %Finally, to view the geometry enter fprintf('run ukoncen\n'); %mphgeom(model,'geom1'); model.save('test.mph');