Saving the Model
1
mphsave(model,'<path>/busbar');
In the above command, replace <path> with the directory where you would like to save your model. If a path is not defined, the model is saved in the current working directory. You can use the command pwd to get the current working directory in MATLAB.
The default save format is the COMSOL binary format with the mph extension. To save the model as an M-file use the command:
mphsave(model,'<path>/busbar.m');
Note: mphsave only save model to file. To save a model in Model Manager use the command mmsave.
2
branch = mmgetbranch('<branchname>','<repositoryname>','<databasename>');
where '<branchname>', '<repositoryname>', '<databasename>' are the name of the branch, the repository, and the database where to save the model respectively.
3
mmsave(model,'version','Commit message for the busbar model',branch);
Code for Use with MATLAB®
model = ModelUtil.create('Model');
mphsetparam(model, 'L', '9[cm]', 'Length of the busbar');
mphsetparam(model, 'rad_1', '6[mm]', 'Radius of the fillet');
mphsetparam(model, 'tbb', '5[mm]', 'Thickness');
mphsetparam(model, 'wbb', '5[cm]', 'Width');
mphsetparam(model, 'mh', '6[mm]', 'Maximum element size');
mphsetparam(model, 'htc', '5[W/m^2/K]', 'Heat transfer coefficient');
mphsetparam(model, 'Vtot', '20[mV]', 'Applied electric potential');
comp1 = model.component.create('comp1', true);
geom1 = comp1.geom.create('geom1', 3);
wp1 = geom1.feature.create('wp1', 'WorkPlane');
wp1.set('quickplane', 'xz');
r1 = wp1.geom.feature.create('r1', 'Rectangle');
r1.set('size', {'L+2*tbb' '0.1'});
r2 = wp1.geom.feature.create('r2', 'Rectangle');
r2.set('size', {'L+tbb' '0.1-tbb'});
r2.set('pos', {'0' 'tbb'});
dif = wp1.geom.feature.create('dif', 'Difference');
dif.selection('input').set({'r1'});
dif.selection('input2').set({'r2'});
mphrun(model,'geom');
fil1 = wp1.geom.feature.create('fil1', 'Fillet');
fil1.selection('point').set('dif(1)', 3);
fil1.set('radius', 'tbb');
fil2 = wp1.geom.feature.create('fil2', 'Fillet');
fil2.selection('point').set('fil1(1)', 6);
fil2.set('radius', '2*tbb');
ext1 = geom1.feature.create('ext1', 'Extrude');
ext1.selection('input').set({'wp1'});
ext1.set('distance', {'wbb'});
mphgeom(model)
wp2 = geom1.feature.create('wp2', 'WorkPlane');
wp2.set('planetype', 'faceparallel');
wp2.selection('face').set('ext1(1)', 8);
c1 = wp2.geom.feature.create('c1', 'Circle');
c1.set('r', 'rad_1');
ext2 = geom1.feature.create('ext2', 'Extrude');
ext2.selection('input').set({'wp2'});
ext2.set('distance', {'-2*tbb'});
wp3 = geom1.feature.create('wp3', 'WorkPlane');
wp3.set('planetype', 'faceparallel');
wp3.selection('face').set('ext1(1)', 4);
c2 = wp3.geom.feature.create('c2', 'Circle');
c2.set('r', 'rad_1');
c2.set('pos', {'-L/2+1.5e-2' '-wbb/4'});
copy = wp3.geom.feature.create('copy', 'Copy');
copy.selection('input').set({'c2'});
copy.set('disply', 'wbb/2');
ext3 = geom1.feature.create('ext3', 'Extrude');
ext3.selection('input').set({'wp3.c2' 'wp3.copy'});
ext3.set('distance', {'-2*tbb'});
mphrun(model,'geom');
sel1 = comp1.selection.create('sel1');
sel1.set([2 3 4 5 6 7]);
sel1.label('Ti bolts');
mphviewselection(model,'sel1');
mat1 = comp1.material.create('mat1');
mat1.materialModel('def').set('electricconductivity', {'5.998e7[S/m]'});
mat1.materialModel('def').set('heatcapacity','385[J/(kg*K)]');
mat1.materialModel('def').set('relpermittivity', {'1'});
mat1.materialModel('def').set('density','8700[kg/m^3]');
mat1.materialModel('def').set('thermalconductivity',{'400[W/(m*K)]'});
mat1.label('Copper');
ModelUtil.scanModel('<COMSOL_path>\applications\COMSOL_Multiphysics\Multiphysics\busbar.mph', 'Material','op')
comp1.material.insert('<COMSOL_path>\applications\COMSOL_Multiphysics\Multiphysics\busbar.mph', 'mat2', '');
comp1.material('mat2').selection.named('sel1');
ht = comp1.physics.create('ht', 'HeatTransfer', 'geom1');
hf1 = ht.feature.create('hf1', 'HeatFluxBoundary', 2);
hf1.set('HeatFluxType', 'InwardHeatFlux');
hf1.selection.set([1:7 9:14 16:42]);
hf1.set('h', 'htc');
mphgeom(model,'geom1','facemode','off','facelabels','on')
ec = comp1.physics.create('ec','ConductiveMedia', 'geom1');
pot1 = ec.feature.create('pot1','ElectricPotential', 2);
pot1.selection.set(43);
pot1.set('V0', 'Vtot');
gnd1 = ec.feature.create('gnd1', 'Ground', 2);
gnd1.selection.set([8 15]);
comp1.multiphysics.create('emh','ElectromagneticHeatSource');
comp1.multiphysics('emh').selection.all;
mesh = comp1.mesh.create('mesh');
size = mesh.feature('size');
size.set('hmax', 'mh');
size.set('hmin', 'mh-mh/3');
size.set('hcurve', '0.2');
mesh.feature.create('ftet', 'FreeTet');
mphrun(model, 'mesh');
mphmesh(model)
std = model.study.create('std');
std.feature.create('stat', 'Stationary');
mphrun(model, 'study');
tags = mphtags(model,'result');
feattags = mphtags(model.result(tags{1}));
surf = model.result(tags{1}).feature(feattags{1});
surf.set('rangecoloractive', 'on');
surf.set('rangecolormin', '322.9');
surf.set('rangecolormax', '323.5');
mphplot(model, tags{1}, 'rangenum', 1)
data = model.result.export.create('data', 'Data');
data.setIndex('expr', 'T', 0);
data.set('filename','<filepath>\Temperature.txt');
mphrun(model, 'data');
mphsave(model,'<path>\busbar.m');