function out = model % % compwithbead.m % % Model exported on Sep 13 2017, 14:04 by COMSOL 5.3.0.316. import com.comsol.model.* import com.comsol.model.util.* model = ModelUtil.create('Model'); model.modelPath('C:\Users\sayinde\Dropbox\Comsol stuffs new - Copy\compforbeadanalysis'); model.label('compwithbead.mph'); model.comments(['Untitled\n\n']); model.param.set('a', '10'); model.param.set('b', '10'); model.param.set('l', '0.5*a'); model.param.set('h1', '0.2*a'); model.param.set('w', '0.2*a'); model.param.set('r', '(h1^2+(w/2)*(w/2))/(2*h1)'); model.param.set('psi', 'acos((w*w-4*h1^2)/(w*w+4*h1^2))'); model.param.set('t', '0.5'); model.param.set('tb', '(4*h1*w*t)/(2.2143*(w^2+4*h1^2))'); model.param.set('r2', 'r-0.18'); model.param.set('hc', 'l-2*r'); model.param.set('xb', '3.5'); model.param.set('yb', '0'); model.param.set('zb', '-1'); model.component.create('comp1', false); model.component('comp1').geom.create('geom1', 3); model.component('comp1').mesh.create('mesh1'); model.component('comp1').geom('geom1').create('sph1', 'Sphere'); model.component('comp1').geom('geom1').feature('sph1').set('pos', {'xb' '0' 'zb'}); model.component('comp1').geom('geom1').feature('sph1').set('r', 'r'); model.component('comp1').geom('geom1').create('sph2', 'Sphere'); model.component('comp1').geom('geom1').feature('sph2').set('pos', {'xb' '0' 'zb'}); model.component('comp1').geom('geom1').feature('sph2').set('r', 'r2'); model.component('comp1').geom('geom1').create('wp1', 'WorkPlane'); model.component('comp1').geom('geom1').feature('wp1').set('quickz', 'zb'); model.component('comp1').geom('geom1').feature('wp1').set('unite', true); model.component('comp1').geom('geom1').create('par1', 'Partition'); model.component('comp1').geom('geom1').feature('par1').set('partitionwith', 'workplane'); model.component('comp1').geom('geom1').feature('par1').selection('input').set({'sph1'}); model.component('comp1').geom('geom1').create('del1', 'Delete'); model.component('comp1').geom('geom1').feature('del1').selection('input').init(3); model.component('comp1').geom('geom1').feature('del1').selection('input').set('par1(1)', [1]); model.component('comp1').geom('geom1').create('wp2', 'WorkPlane'); model.component('comp1').geom('geom1').feature('wp2').set('quickz', 'zb'); model.component('comp1').geom('geom1').feature('wp2').set('unite', true); model.component('comp1').geom('geom1').create('par2', 'Partition'); model.component('comp1').geom('geom1').feature('par2').set('partitionwith', 'workplane'); model.component('comp1').geom('geom1').feature('par2').selection('input').set({'sph2'}); model.component('comp1').geom('geom1').create('del2', 'Delete'); model.component('comp1').geom('geom1').feature('del2').selection('input').init(3); model.component('comp1').geom('geom1').feature('del2').selection('input').set('par2(1)', [1]); model.component('comp1').geom('geom1').create('dif1', 'Difference'); model.component('comp1').geom('geom1').feature('dif1').selection('input').set({'del1'}); model.component('comp1').geom('geom1').feature('dif1').selection('input2').set({'del2'}); model.component('comp1').geom('geom1').create('uni2', 'Union'); model.component('comp1').geom('geom1').feature('uni2').selection('input').set({'dif1'}); model.component('comp1').geom('geom1').create('mir1', 'Mirror'); model.component('comp1').geom('geom1').feature('mir1').set('keep', true); model.component('comp1').geom('geom1').feature('mir1').set('pos', {'0' '0' 'zb-hc/2'}); model.component('comp1').geom('geom1').feature('mir1').selection('input').set({'uni2'}); model.component('comp1').geom('geom1').create('cyl1', 'Cylinder'); model.component('comp1').geom('geom1').feature('cyl1').set('pos', {'xb' '0' 'zb-hc'}); model.component('comp1').geom('geom1').feature('cyl1').set('axis', [0 0 1]); model.component('comp1').geom('geom1').feature('cyl1').set('r', 'r'); model.component('comp1').geom('geom1').feature('cyl1').set('h', 'hc'); model.component('comp1').geom('geom1').create('cyl2', 'Cylinder'); model.component('comp1').geom('geom1').feature('cyl2').set('pos', {'xb' '0' 'zb-hc'}); model.component('comp1').geom('geom1').feature('cyl2').set('r', 'r2'); model.component('comp1').geom('geom1').feature('cyl2').set('h', 'hc'); model.component('comp1').geom('geom1').create('dif2', 'Difference'); model.component('comp1').geom('geom1').feature('dif2').selection('input').set({'cyl1'}); model.component('comp1').geom('geom1').feature('dif2').selection('input2').set({'cyl2'}); model.component('comp1').geom('geom1').create('uni1', 'Union'); model.component('comp1').geom('geom1').feature('uni1').selection('input').set({'dif2'}); model.component('comp1').geom('geom1').create('uni3', 'Union'); model.component('comp1').geom('geom1').feature('uni3').selection('input').set({'mir1' 'uni1' 'uni2'}); model.component('comp1').geom('geom1').create('wp3', 'WorkPlane'); model.component('comp1').geom('geom1').feature('wp3').set('quickplane', 'xz'); model.component('comp1').geom('geom1').feature('wp3').set('unite', true); model.component('comp1').geom('geom1').create('par3', 'Partition'); model.component('comp1').geom('geom1').feature('par3').set('partitionwith', 'workplane'); model.component('comp1').geom('geom1').feature('par3').selection('input').set({'uni3'}); model.component('comp1').geom('geom1').create('del3', 'Delete'); model.component('comp1').geom('geom1').feature('del3').selection('input').init(3); model.component('comp1').geom('geom1').feature('del3').selection('input').set('par3(1)', [1 3 5]); model.component('comp1').geom('geom1').create('blk1', 'Block'); model.component('comp1').geom('geom1').feature('blk1').set('pos', {'0' '-t/2' '0'}); model.component('comp1').geom('geom1').feature('blk1').set('axis', [0 1 0]); model.component('comp1').geom('geom1').feature('blk1').set('base', 'center'); model.component('comp1').geom('geom1').feature('blk1').set('size', {'a' 'b' 't'}); model.component('comp1').geom('geom1').create('cyl3', 'Cylinder'); model.component('comp1').geom('geom1').feature('cyl3').set('pos', {'xb' '-t' 'zb'}); model.component('comp1').geom('geom1').feature('cyl3').set('axis', [0 1 0]); model.component('comp1').geom('geom1').feature('cyl3').set('r', 'r2'); model.component('comp1').geom('geom1').feature('cyl3').set('h', 't*1'); model.component('comp1').geom('geom1').create('blk2', 'Block'); model.component('comp1').geom('geom1').feature('blk2').set('pos', {'xb' '-t/2' 'zb-hc/2'}); model.component('comp1').geom('geom1').feature('blk2').set('base', 'center'); model.component('comp1').geom('geom1').feature('blk2').set('size', {'r2*2' 't' 'hc'}); model.component('comp1').geom('geom1').create('mir2', 'Mirror'); model.component('comp1').geom('geom1').feature('mir2').set('keep', true); model.component('comp1').geom('geom1').feature('mir2').set('pos', {'xb' '0' 'zb-hc/2'}); model.component('comp1').geom('geom1').feature('mir2').selection('input').set({'cyl3'}); model.component('comp1').geom('geom1').create('uni4', 'Union'); model.component('comp1').geom('geom1').feature('uni4').selection('input').set({'blk2' 'cyl3' 'mir2'}); model.component('comp1').geom('geom1').create('dif3', 'Difference'); model.component('comp1').geom('geom1').feature('dif3').selection('input').set({'blk1'}); model.component('comp1').geom('geom1').feature('dif3').selection('input2').set({'uni4'}); model.component('comp1').geom('geom1').create('uni5', 'Union'); model.component('comp1').geom('geom1').feature('uni5').selection('input').set({'del3' 'dif3'}); model.component('comp1').geom('geom1').create('ige1', 'IgnoreEdges'); model.component('comp1').geom('geom1').feature('ige1').selection('input').set('fin(1)', [10 12 13 15 22 23 24 25 30 32 33 34 35 36 38 39 41 42 43 47 48]); model.component('comp1').geom('geom1').create('ige2', 'IgnoreEdges'); model.component('comp1').geom('geom1').feature('ige2').selection('input').set('ige1(1)', [20 23 25 29 32]); model.component('comp1').geom('geom1').create('cmd1', 'CompositeDomains'); model.component('comp1').geom('geom1').feature('cmd1').selection('input').set('ige2(1)', [2 3 4]); model.component('comp1').geom('geom1').run; model.component('comp1').material.create('mat1', 'Common'); model.component('comp1').material('mat1').propertyGroup.create('Enu', 'Young''s modulus and Poisson''s ratio'); model.component('comp1').material('mat1').propertyGroup.create('Murnaghan', 'Murnaghan'); model.component('comp1').material('mat1').propertyGroup.create('Lame', ['Lam' native2unicode(hex2dec({'00' 'e9'}), 'unicode') ' parameters']); model.component('comp1').physics.create('solid', 'SolidMechanics', 'geom1'); model.component('comp1').physics('solid').create('el1', 'EdgeLoad', 1); model.component('comp1').physics('solid').feature('el1').selection.set([28]); model.component('comp1').physics('solid').create('fix1', 'Fixed', 2); model.component('comp1').physics('solid').feature('fix1').selection.set([1]); model.capeopen.label('Thermodynamics Package'); model.component('comp1').material('mat1').label('Structural steel'); model.component('comp1').material('mat1').set('family', 'custom'); model.component('comp1').material('mat1').set('specular', 'custom'); model.component('comp1').material('mat1').set('customspecular', [0.7843137254901961 0.7843137254901961 0.7843137254901961]); model.component('comp1').material('mat1').set('diffuse', 'custom'); model.component('comp1').material('mat1').set('customdiffuse', [0.6666666666666666 0.6666666666666666 0.6666666666666666]); model.component('comp1').material('mat1').set('ambient', 'custom'); model.component('comp1').material('mat1').set('customambient', [0.6666666666666666 0.6666666666666666 0.6666666666666666]); model.component('comp1').material('mat1').set('noise', true); model.component('comp1').material('mat1').set('noisefreq', 1); model.component('comp1').material('mat1').set('lighting', 'cooktorrance'); model.component('comp1').material('mat1').set('fresnel', 0.9); model.component('comp1').material('mat1').set('roughness', 0.3); model.component('comp1').material('mat1').propertyGroup('def').set('relpermeability', {'1' '0' '0' '0' '1' '0' '0' '0' '1'}); model.component('comp1').material('mat1').propertyGroup('def').set('heatcapacity', '475[J/(kg*K)]'); model.component('comp1').material('mat1').propertyGroup('def').set('thermalconductivity', {'44.5[W/(m*K)]' '0' '0' '0' '44.5[W/(m*K)]' '0' '0' '0' '44.5[W/(m*K)]'}); model.component('comp1').material('mat1').propertyGroup('def').set('electricconductivity', {'4.032e6[S/m]' '0' '0' '0' '4.032e6[S/m]' '0' '0' '0' '4.032e6[S/m]'}); model.component('comp1').material('mat1').propertyGroup('def').set('relpermittivity', {'1' '0' '0' '0' '1' '0' '0' '0' '1'}); model.component('comp1').material('mat1').propertyGroup('def').set('thermalexpansioncoefficient', {'12.3e-6[1/K]' '0' '0' '0' '12.3e-6[1/K]' '0' '0' '0' '12.3e-6[1/K]'}); model.component('comp1').material('mat1').propertyGroup('def').set('density', '7850[kg/m^3]'); model.component('comp1').material('mat1').propertyGroup('Enu').set('youngsmodulus', '200e9[Pa]'); model.component('comp1').material('mat1').propertyGroup('Enu').set('poissonsratio', '0.30'); model.component('comp1').material('mat1').propertyGroup('Murnaghan').set('l', ''); model.component('comp1').material('mat1').propertyGroup('Murnaghan').set('m', ''); model.component('comp1').material('mat1').propertyGroup('Murnaghan').set('n', ''); model.component('comp1').material('mat1').propertyGroup('Murnaghan').set('l', '-3.0e11[Pa]'); model.component('comp1').material('mat1').propertyGroup('Murnaghan').set('m', '-6.2e11[Pa]'); model.component('comp1').material('mat1').propertyGroup('Murnaghan').set('n', '-7.2e11[Pa]'); model.component('comp1').material('mat1').propertyGroup('Lame').set('lambLame', ''); model.component('comp1').material('mat1').propertyGroup('Lame').set('muLame', ''); model.component('comp1').material('mat1').propertyGroup('Lame').set('lambLame', '1.15e11[Pa]'); model.component('comp1').material('mat1').propertyGroup('Lame').set('muLame', '7.69e10[Pa]'); model.component('comp1').physics('solid').feature('el1').set('FperLength', [0; 200000; 200000]); model.component('comp1').mesh('mesh1').run; model.study.create('std1'); model.study('std1').create('stat', 'Stationary'); model.sol.create('sol1'); model.sol('sol1').study('std1'); model.sol('sol1').attach('std1'); model.sol('sol1').create('st1', 'StudyStep'); model.sol('sol1').create('v1', 'Variables'); model.sol('sol1').create('s1', 'Stationary'); model.sol('sol1').feature('s1').create('fc1', 'FullyCoupled'); model.sol('sol1').feature('s1').create('d1', 'Direct'); model.sol('sol1').feature('s1').create('i1', 'Iterative'); model.sol('sol1').feature('s1').feature('i1').create('mg1', 'Multigrid'); model.sol('sol1').feature('s1').feature('i1').feature('mg1').feature('pr').create('so1', 'SOR'); model.sol('sol1').feature('s1').feature('i1').feature('mg1').feature('po').create('so1', 'SOR'); model.sol('sol1').feature('s1').feature.remove('fcDef'); model.result.create('pg1', 'PlotGroup3D'); model.result('pg1').create('surf1', 'Surface'); model.result('pg1').feature('surf1').create('def', 'Deform'); model.sol('sol1').attach('std1'); model.sol('sol1').feature('s1').feature('fc1').set('linsolver', 'd1'); model.sol('sol1').feature('s1').feature('d1').label('Suggested Direct Solver (solid)'); model.sol('sol1').feature('s1').feature('i1').label('Suggested Iterative Solver (solid)'); model.sol('sol1').feature('s1').feature('i1').set('nlinnormuse', true); model.sol('sol1').feature('s1').feature('i1').feature('mg1').feature('pr').feature('so1').set('relax', 0.8); model.sol('sol1').feature('s1').feature('i1').feature('mg1').feature('po').feature('so1').set('relax', 0.8); model.sol('sol1').runAll; model.result('pg1').label('Stress (solid)'); model.result('pg1').feature('surf1').set('expr', 'solid.mises'); model.result('pg1').feature('surf1').set('unit', 'N/m^2'); model.result('pg1').feature('surf1').set('descr', 'von Mises stress'); model.result('pg1').feature('surf1').set('resolution', 'normal'); model.result('pg1').feature('surf1').feature('def').set('scale', 1352203.1654009258); model.result('pg1').feature('surf1').feature('def').set('scaleactive', false); model.result.create('pg10', 'PlotGroup3D'); model.result('pg10').run; model.result('pg10').create('con4', 'Contour'); model.result('pg10').feature('con4').set('expr', 'v'); model.result('pg10').feature('con4').set('descr', 'Displacement field, Y component'); % model.result('pg2').feature('con1').set('descr', 'Principal stress direction 1, Gauss-point evaluation, x component'); model.result('pg10').feature('con4').label('displacement in y-direction'); model.result('pg10').feature('con4').set('contourtype', 'filled'); figure(4) mphplot(model,'pg10','rangenum',1) model.result('pg10').run; figure(2) mphgeom(model) out = model;