function out = model % % motor.m % % Model exported on Nov 27 2012, 20:40 by COMSOL 4.3.1.115. import com.comsol.model.* import com.comsol.model.util.* model = ModelUtil.create('Model'); model.modelPath('C:\Program Files\COMSOL\COMSOL43a\models\ACDC_Module\Motors_and_Actuators'); model.modelNode.create('mod1'); model.geom.create('geom1', 2); model.mesh.create('mesh1', 'geom1'); model.physics.create('rmm', 'RotatingMachineryMagnetic', 'geom1'); model.study.create('std1'); model.study('std1').feature.create('stat', 'Stationary'); model.study('std1').feature('stat').activate('rmm', true); model.param.set('L', '0.4[m]'); model.param.descr('L', 'Length of generator'); model.param.set('rpm', '60[1/min]'); model.param.descr('rpm', 'Rotational speed of rotor'); model.geom('geom1').feature.create('imp1', 'Import'); model.geom('geom1').feature('imp1').set('filename', 'generator_2d.mphbin'); model.geom('geom1').feature('imp1').importData; model.geom('geom1').feature('fin').set('action', 'assembly'); model.geom('geom1').runAll; model.cpl.create('intop1', 'Integration', 'geom1'); model.geom('geom1').run; model.cpl('intop1').selection.set([5 6 7 8 13 14 15 16]); model.cpl.create('intop2', 'Integration', 'geom1'); model.cpl('intop2').selection.set([3 4 9 10 11 12 17 18]); model.cpl.create('intop3', 'Integration', 'geom1'); model.cpl('intop3').selection.set([8]); model.coordSystem.create('sys2', 'geom1', 'Cylindrical'); model.material.create('mat1'); model.material('mat1').name('Air'); model.material('mat1').set('family', 'air'); model.material('mat1').propertyGroup('def').set('relpermeability', '1'); model.material('mat1').propertyGroup('def').set('relpermittivity', '1'); model.material('mat1').propertyGroup('def').set('dynamicviscosity', 'eta(T[1/K])[Pa*s]'); model.material('mat1').propertyGroup('def').set('ratioofspecificheat', '1.4'); model.material('mat1').propertyGroup('def').set('electricconductivity', '0[S/m]'); model.material('mat1').propertyGroup('def').set('heatcapacity', 'Cp(T[1/K])[J/(kg*K)]'); model.material('mat1').propertyGroup('def').set('density', 'rho(pA[1/Pa],T[1/K])[kg/m^3]'); model.material('mat1').propertyGroup('def').set('thermalconductivity', 'k(T[1/K])[W/(m*K)]'); model.material('mat1').propertyGroup('def').set('soundspeed', 'cs(T[1/K])[m/s]'); model.material('mat1').propertyGroup('def').func.create('eta', 'Piecewise'); model.material('mat1').propertyGroup('def').func('eta').set('funcname', 'eta'); model.material('mat1').propertyGroup('def').func('eta').set('arg', 'T'); model.material('mat1').propertyGroup('def').func('eta').set('extrap', 'constant'); model.material('mat1').propertyGroup('def').func('eta').set('pieces', {'200.0' '1600.0' '-8.38278E-7+8.35717342E-8*T^1-7.69429583E-11*T^2+4.6437266E-14*T^3-1.06585607E-17*T^4'}); model.material('mat1').propertyGroup('def').func.create('Cp', 'Piecewise'); model.material('mat1').propertyGroup('def').func('Cp').set('funcname', 'Cp'); model.material('mat1').propertyGroup('def').func('Cp').set('arg', 'T'); model.material('mat1').propertyGroup('def').func('Cp').set('extrap', 'constant'); model.material('mat1').propertyGroup('def').func('Cp').set('pieces', {'200.0' '1600.0' '1047.63657-0.372589265*T^1+9.45304214E-4*T^2-6.02409443E-7*T^3+1.2858961E-10*T^4'}); model.material('mat1').propertyGroup('def').func.create('rho', 'Analytic'); model.material('mat1').propertyGroup('def').func('rho').set('funcname', 'rho'); model.material('mat1').propertyGroup('def').func('rho').set('args', {'pA' 'T'}); model.material('mat1').propertyGroup('def').func('rho').set('expr', 'pA*0.02897/8.314/T'); model.material('mat1').propertyGroup('def').func('rho').set('dermethod', 'manual'); model.material('mat1').propertyGroup('def').func('rho').set('argders', {'pA' 'd(pA*0.02897/8.314/T,pA)'; 'T' 'd(pA*0.02897/8.314/T,T)'}); model.material('mat1').propertyGroup('def').func.create('k', 'Piecewise'); model.material('mat1').propertyGroup('def').func('k').set('funcname', 'k'); model.material('mat1').propertyGroup('def').func('k').set('arg', 'T'); model.material('mat1').propertyGroup('def').func('k').set('extrap', 'constant'); model.material('mat1').propertyGroup('def').func('k').set('pieces', {'200.0' '1600.0' '-0.00227583562+1.15480022E-4*T^1-7.90252856E-8*T^2+4.11702505E-11*T^3-7.43864331E-15*T^4'}); model.material('mat1').propertyGroup('def').func.create('cs', 'Analytic'); model.material('mat1').propertyGroup('def').func('cs').set('funcname', 'cs'); model.material('mat1').propertyGroup('def').func('cs').set('args', {'T'}); model.material('mat1').propertyGroup('def').func('cs').set('expr', 'sqrt(1.4*287*T)'); model.material('mat1').propertyGroup('def').func('cs').set('dermethod', 'manual'); model.material('mat1').propertyGroup('def').func('cs').set('argders', {'T' 'd(sqrt(1.4*287*T),T)'}); model.material('mat1').propertyGroup('def').addInput('temperature'); model.material('mat1').propertyGroup('def').addInput('pressure'); model.material('mat1').set('family', 'air'); model.material.create('mat2'); model.material('mat2').name('Soft Iron (without losses)'); model.material('mat2').set('family', 'iron'); model.material('mat2').propertyGroup('def').set('electricconductivity', '0[S/m]'); model.material('mat2').propertyGroup('def').set('relpermittivity', '1'); model.material('mat2').propertyGroup.create('BHCurve', 'BH curve'); model.material('mat2').propertyGroup('BHCurve').set('normB', 'BH(normH[m/A])[T]'); model.material('mat2').propertyGroup('BHCurve').func.create('BH', 'Interpolation'); model.material('mat2').propertyGroup('BHCurve').func('BH').set('sourcetype', 'user'); model.material('mat2').propertyGroup('BHCurve').func('BH').set('source', 'table'); model.material('mat2').propertyGroup('BHCurve').func('BH').set('funcname', 'BH'); model.material('mat2').propertyGroup('BHCurve').func('BH').set('table', {'0' '0'; '663.146' '1'; '1067.5' '1.1'; '1705.23' '1.2'; '2463.11' '1.3'; '3841.67' '1.4'; '5425.74' '1.5'; '7957.75' '1.6'; '12298.3' '1.7'; '20462.8' '1.8'; ... '32169.6' '1.9'; '61213.4' '2.0'; '111408' '2.1'; '175070' '2.2'; '261469' '2.3'; '318310' '2.4'}); model.material('mat2').propertyGroup('BHCurve').func('BH').set('interp', 'linear'); model.material('mat2').propertyGroup('BHCurve').func('BH').set('extrap', 'linear'); model.material('mat2').propertyGroup.create('HBCurve', 'HB curve'); model.material('mat2').propertyGroup('HBCurve').set('normH', 'HB(normB[1/T])[A/m]'); model.material('mat2').propertyGroup('HBCurve').func.create('HB', 'Interpolation'); model.material('mat2').propertyGroup('HBCurve').func('HB').set('sourcetype', 'user'); model.material('mat2').propertyGroup('HBCurve').func('HB').set('source', 'table'); model.material('mat2').propertyGroup('HBCurve').func('HB').set('funcname', 'HB'); model.material('mat2').propertyGroup('HBCurve').func('HB').set('table', {'0' '0'; '1' '663.146'; '1.1' '1067.5'; '1.2' '1705.23'; '1.3' '2463.11'; '1.4' '3841.67'; '1.5' '5425.74'; '1.6' '7957.75'; '1.7' '12298.3'; '1.8' '20462.8'; ... '1.9' '32169.6'; '2.0' '61213.4'; '2.1' '111408'; '2.2' '175070'; '2.3' '261469'; '2.4' '318310'}); model.material('mat2').propertyGroup('HBCurve').func('HB').set('interp', 'linear'); model.material('mat2').propertyGroup('HBCurve').func('HB').set('extrap', 'linear'); model.material('mat2').set('family', 'iron'); model.material('mat2').selection.set([2 28]); model.physics('rmm').feature.create('prv1', 'PrescribedRotationalVelocity', 2); model.physics('rmm').feature('prv1').selection.set([19 20 21 22 23 24 25 26 27 28]); model.physics('rmm').feature('prv1').set('rps', 1, 'rpm'); model.physics('rmm').feature.create('al2', 'AmperesLaw', 2); model.physics('rmm').feature('al2').selection.set([20 23 24 27]); model.physics('rmm').feature('al2').set('coordinateSystem', 1, 'sys2'); model.physics('rmm').feature('al2').set('ConstitutiveRelationH', 1, 'RemanentFluxDensity'); model.physics('rmm').feature('al2').set('Br', {'0.84[T]' '0' '0'}); model.physics('rmm').feature('al2').name('Permanent Magnets Outward'); model.physics('rmm').feature.create('al3', 'AmperesLaw', 2); model.physics('rmm').feature('al3').selection.set([21 22 25 26]); model.physics('rmm').feature('al3').set('coordinateSystem', 1, 'sys2'); model.physics('rmm').feature('al3').set('ConstitutiveRelationH', 1, 'RemanentFluxDensity'); model.physics('rmm').feature('al3').set('Br', {'-0.84[T]' '0' '0'}); model.physics('rmm').feature('al3').name('Permanent Magnets Inward'); model.physics('rmm').feature.create('al4', 'AmperesLaw', 2); model.physics('rmm').feature('al4').set('ConstitutiveRelationH', 1, 'HBCurve'); model.physics('rmm').feature('al4').selection.set([2 28]); model.physics('rmm').feature('al4').name('Iron'); model.physics('rmm').feature.create('cont1', 'Continuity', 1); model.physics('rmm').feature('cont1').set('pairs', 1, 'ap1'); model.mesh('mesh1').feature.create('ftri1', 'FreeTri'); model.mesh('mesh1').feature('size').set('hauto', '3'); model.mesh('mesh1').feature('size').set('custom', 'on'); model.mesh('mesh1').feature('size').set('hnarrow', '2'); model.mesh('mesh1').run; model.study('std1').feature.create('time', 'Transient'); model.study('std1').feature('time').set('tlist', 'range(0,0.01,0.25)'); model.variable.create('var1'); model.variable('var1').set('A', 'mod1.intop3(1)'); model.variable('var1').descr('A', 'Cross-sectional area of winding'); model.variable('var1').set('Vi', 'mod1.intop1(L*rmm.Ez/A) -mod1.intop2(L*rmm.Ez/A)'); model.variable('var1').descr('Vi', 'Induced voltage in winding'); model.sol.create('sol1'); model.sol('sol1').study('std1'); model.sol('sol1').feature.create('st1', 'StudyStep'); model.sol('sol1').feature('st1').set('study', 'std1'); model.sol('sol1').feature('st1').set('studystep', 'stat'); model.sol('sol1').feature.create('v1', 'Variables'); model.sol('sol1').feature('v1').set('control', 'stat'); model.sol('sol1').feature.create('s1', 'Stationary'); model.sol('sol1').feature('s1').feature.create('fc1', 'FullyCoupled'); model.sol('sol1').feature('s1').feature.remove('fcDef'); model.sol('sol1').feature.create('su1', 'StoreSolution'); model.sol('sol1').feature.create('st2', 'StudyStep'); model.sol('sol1').feature('st2').set('study', 'std1'); model.sol('sol1').feature('st2').set('studystep', 'time'); model.sol('sol1').feature.create('v2', 'Variables'); model.sol('sol1').feature('v2').set('initmethod', 'sol'); model.sol('sol1').feature('v2').set('initsol', 'sol1'); model.sol('sol1').feature('v2').set('initsoluse', 'su1'); model.sol('sol1').feature('v2').set('notsolmethod', 'sol'); model.sol('sol1').feature('v2').set('notsol', 'sol1'); model.sol('sol1').feature('v2').set('notsoluse', 'su1'); model.sol('sol1').feature('v2').set('control', 'time'); model.sol('sol1').feature.create('t1', 'Time'); model.sol('sol1').feature('t1').set('tlist', 'range(0,0.01,0.25)'); model.sol('sol1').feature('t1').set('plot', 'off'); model.sol('sol1').feature('t1').set('plotfreq', 'tout'); model.sol('sol1').feature('t1').set('probesel', 'all'); model.sol('sol1').feature('t1').set('probes', {}); model.sol('sol1').feature('t1').set('probefreq', 'tsteps'); model.sol('sol1').feature('t1').set('rtol', 0.01); model.sol('sol1').feature('t1').set('atolglobalmethod', 'scaled'); model.sol('sol1').feature('t1').set('atolglobal', 0.0010); model.sol('sol1').feature('t1').set('rhoinf', 0.75); model.sol('sol1').feature('t1').set('maxorder', 5); model.sol('sol1').feature('t1').set('minorder', 1); model.sol('sol1').feature('t1').set('control', 'time'); model.sol('sol1').feature('t1').feature.create('fc1', 'FullyCoupled'); model.sol('sol1').feature('t1').feature('fc1').set('initsteph', 1.0E-4); model.sol('sol1').feature('t1').feature('fc1').set('niter', 1); model.sol('sol1').feature('t1').feature('fc1').set('minstep', 1.0E-4); model.sol('sol1').feature('t1').feature('fc1').set('ratelimitactive', false); model.sol('sol1').feature('t1').feature('fc1').set('ntolfact', 0.2); model.sol('sol1').feature('t1').feature('fc1').set('ratelimit', 0.9); model.sol('sol1').feature('t1').feature('fc1').set('jtech', 'once'); model.sol('sol1').feature('t1').feature('fc1').set('ntermauto', 'tol'); model.sol('sol1').feature('t1').feature('fc1').set('ntermconst', 'tol'); model.sol('sol1').feature('t1').feature('fc1').set('minsteph', 1.0E-8); model.sol('sol1').feature('t1').feature('fc1').set('rstep', 10); model.sol('sol1').feature('t1').feature('fc1').set('damp', 1); model.sol('sol1').feature('t1').feature('fc1').set('maxiter', 7); model.sol('sol1').feature('t1').feature('fc1').set('dtech', 'const'); model.sol('sol1').feature('t1').feature('fc1').set('initstep', 1); model.sol('sol1').feature('t1').feature('fc1').set('initsteph', 1.0E-4); model.sol('sol1').feature('t1').feature('fc1').set('niter', 1); model.sol('sol1').feature('t1').feature('fc1').set('minstep', 1.0E-4); model.sol('sol1').feature('t1').feature('fc1').set('ratelimitactive', false); model.sol('sol1').feature('t1').feature('fc1').set('ntolfact', 0.2); model.sol('sol1').feature('t1').feature('fc1').set('ratelimit', 0.9); model.sol('sol1').feature('t1').feature('fc1').set('jtech', 'once'); model.sol('sol1').feature('t1').feature('fc1').set('ntermauto', 'tol'); model.sol('sol1').feature('t1').feature('fc1').set('ntermconst', 'tol'); model.sol('sol1').feature('t1').feature('fc1').set('minsteph', 1.0E-8); model.sol('sol1').feature('t1').feature('fc1').set('rstep', 10); model.sol('sol1').feature('t1').feature('fc1').set('damp', 1); model.sol('sol1').feature('t1').feature('fc1').set('maxiter', 7); model.sol('sol1').feature('t1').feature('fc1').set('dtech', 'const'); model.sol('sol1').feature('t1').feature('fc1').set('initstep', 1); model.sol('sol1').feature('t1').feature.remove('fcDef'); model.sol('sol1').attach('std1'); model.result.create('pg1', 'PlotGroup2D'); model.result('pg1').name('Magnetic flux density'); model.result('pg1').set('frametype', 'spatial'); model.result('pg1').set('data', 'dset1'); model.result('pg1').feature.create('surf1', 'Surface'); model.result('pg1').feature('surf1').name('Surface'); model.result('pg1').feature('surf1').set('data', 'parent'); model.sol('sol1').runAll; model.result('pg1').run; model.result.dataset('dset1').set('frametype', 'spatial'); model.result('pg1').run; model.result('pg1').setIndex('looplevel', '21', 0); model.result('pg1').run; model.result('pg1').run; model.result('pg1').feature.create('con1', 'Contour'); model.result('pg1').feature('con1').set('expr', 'Az'); model.result('pg1').feature('con1').set('descr', 'Magnetic vector potential, Z component'); model.result('pg1').feature('con1').set('coloring', 'uniform'); model.result('pg1').feature('con1').set('color', 'black'); model.result('pg1').feature('con1').set('number', '12'); model.result('pg1').run; model.result.create('pg2', 'PlotGroup1D'); model.result('pg2').run; model.result('pg2').set('titletype', 'manual'); model.result('pg2').set('xlabelactive', 'on'); model.result('pg2').set('ylabelactive', 'on'); model.result('pg2').set('title', 'Induced voltage'); model.result('pg2').set('xlabel', 'Time (s)'); model.result('pg2').set('ylabel', 'Voltage (V)'); model.result('pg2').setIndex('looplevelinput', 'manual', 0); model.result('pg2').feature.create('glob1', 'Global'); model.result('pg2').feature('glob1').set('expr', {'Vi'}); model.result('pg2').feature('glob1').set('descr', {'Induced voltage in winding'}); model.result('pg2').feature('glob1').set('unit', {'V'}); model.result('pg2').run; model.comments(['Generator in 2D\n\nA rotor with permanent magnets and a nonlinear magnetic material is rotating within a stator of the same magnetic material. The generated voltage in windings around the stator is calculated as a function of time. COMSOL Multiphysics models the rotation with assemblies and identity pairs, using a prescribed rotation coordinate transform in Moving Mesh. The nonlinearity of the magnetic material is modeled using an interpolating function defined in a material library.']); model.mesh.clearMeshes; model.sol('sol1').clearSolution; model.sol('sol2').clearSolution; model.name('generator_2d.mph'); model.result('pg2').run; out = model;