Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 26527

specifying materials in Matlab

$
0
0
Hello,

I am trying to setup a simple Matlab script to calculate modes of a step-index optical fibre (there is a tutorial model which describes in much detail how to do that in Comsol, but no mention of Matlab). Instead of circular fibre, like in the tutorial, I have a rectangular one. So I start with drawing geometry:

model = ModelUtil.create('Model');

geom=model.geom.create('geom1', 2);

r1=geom.feature.create('r1', 'Rectangle'); % this is the waveguide
r1.set('base', 'center');
r1.setIndex('size', 'Wc', 0);
r1.setIndex('size', 'Hc', 1);

r2=geom.feature.create('r1', 'Rectangle'); % this is the surrounding material (air)
r2.set('base', 'center');
r2.setIndex('size', 'Wf', 0);
r2.setIndex('size', 'Hf', 1);


Now, I am not sure how to specify that the waveguide has one refractive index, and the surrounding rectangle - another? I can try to specify a material:

mat_air=model.material.create('mat_air');
mat_air.name('Air');
mat_air.materialModel.create('RefractiveIndex', 'Refractive index');
mat_air.materialModel('RefractiveIndex').set('n', {'1'});

But how do I specify that this material is associated with rectangle 2 in my case? I am lost now...

Viewing all articles
Browse latest Browse all 26527

Trending Articles