function out = model % % loaded_knee.m % % Model exported on Dec 20 2012, 03:13 by COMSOL 4.2.1.110. import com.comsol.model.* import com.comsol.model.util.* model = ModelUtil.create('Model'); model.modelPath('C:\Program Files\COMSOL\COMSOL42a\models\COMSOL_Multiphysics\Structural_Mechanics'); model.name('loaded_knee.mph'); model.comments(['Topology Optimization of a Loaded Knee Structure\n\nThis model uses the solid isotropic material with penalization (SIMP) model to find the optimal distribution of a given amount of material forming an L-shaped frame. The optimality criterion is minimum compliance for the load case where the frame''s upper boundary is fixed and a downward load is applied along its right end.\n\nThe model requires the Optimization Module.']); model.param.set('F_load', '700[kN/m]', 'Applied load'); model.param.set('A_frac', '0.45', 'Fraction of area to use for distributing material'); model.param.set('p', '3', 'SIMP penalization parameter'); model.modelNode.create('mod1'); model.geom.create('geom1', 2); model.geom('geom1').feature.create('sq1', 'Square'); model.geom('geom1').feature.create('sq2', 'Square'); model.geom('geom1').feature.create('dif1', 'Difference'); model.geom('geom1').feature.create('fil1', 'Fillet'); model.geom('geom1').feature.create('pt1', 'Point'); model.geom('geom1').feature.create('pt2', 'Point'); model.geom('geom1').feature('sq1').set('size', '0.45'); model.geom('geom1').feature('sq2').set('pos', {'0.18' '0.18'}); model.geom('geom1').feature('sq2').set('size', '0.27'); model.geom('geom1').feature('dif1').selection('input').set({'sq1'}); model.geom('geom1').feature('dif1').selection('input2').set({'sq2'}); model.geom('geom1').feature('fil1').set('radius', '0.04'); model.geom('geom1').feature('fil1').selection('point').set('dif1(1)', [3]); model.geom('geom1').feature('pt1').set('p', {'0.45'; '0.083'}); model.geom('geom1').feature('pt2').set('p', {'0.45'; '0.097'}); model.geom('geom1').run; model.variable.create('var1'); model.variable('var1').model('mod1'); model.variable('var1').set('E_SIMP', '2e11[Pa]*rho_design^p', 'Penalized Young''s modulus'); model.variable('var1').set('A_designdomain', 'intop1(1)', 'Design domain area'); model.material.create('mat1'); model.material('mat1').propertyGroup.create('Enu', 'Young''s modulus and Poisson''s ratio'); model.material('mat1').propertyGroup.create('Murnaghan', 'Murnaghan'); model.material('mat1').propertyGroup.create('Lame', ['Lam' native2unicode(hex2dec('00e9'), 'Cp1252') ' constants']); model.material('mat1').propertyGroup.create('NeoHookean', 'Neo-Hookean'); model.physics.create('solid', 'SolidMechanics', 'geom1'); model.physics('solid').feature.create('fix1', 'Fixed', 1); model.physics('solid').feature('fix1').selection.set([3]); model.physics('solid').feature.create('bndl1', 'BoundaryLoad', 1); model.physics('solid').feature('bndl1').selection.set([7]); model.physics.create('opt', 'GeneralOptimization', 'geom1'); model.physics('opt').feature.create('cvar1', 'ControlVariableField', 2); model.physics('opt').feature('cvar1').selection.set([1]); model.physics('opt').feature.create('pconstr1', 'PointwiseInequality', 2); model.physics('opt').feature('pconstr1').selection.set([1]); model.physics('opt').feature.create('iconstr1', 'IntegralInequality', 2); model.physics('opt').feature('iconstr1').selection.set([1]); model.physics('opt').feature.create('iobj1', 'IntegralObjective', 2); model.physics('opt').feature('iobj1').selection.set([1]); model.mesh.create('mesh1', 'geom1'); model.mesh('mesh1').feature.create('ftri1', 'FreeTri'); model.cpl.create('intop1', 'Integration', 'geom1'); model.cpl('intop1').selection.set([1]); model.view('view1').axis.set('xmin', '-0.03199639171361923'); model.view('view1').axis.set('xmax', '0.4819963872432709'); model.view('view1').axis.set('ymin', '-0.04365014284849167'); model.view('view1').axis.set('ymax', '0.4936501383781433'); model.material('mat1').name('Structural steel'); model.material('mat1').propertyGroup('def').set('relpermeability', {'1' '0' '0' '0' '1' '0' '0' '0' '1'}); model.material('mat1').propertyGroup('def').set('heatcapacity', '475[J/(kg*K)]'); model.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.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.material('mat1').propertyGroup('def').set('relpermittivity', {'1' '0' '0' '0' '1' '0' '0' '0' '1'}); model.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.material('mat1').propertyGroup('def').set('density', '7850[kg/m^3]'); model.material('mat1').propertyGroup('Enu').set('youngsmodulus', '200e9[Pa]'); model.material('mat1').propertyGroup('Enu').set('poissonsratio', '0.33'); model.material('mat1').propertyGroup('Murnaghan').set('l', '-3.0e11[Pa]'); model.material('mat1').propertyGroup('Murnaghan').set('m', '-6.2e11[Pa]'); model.material('mat1').propertyGroup('Murnaghan').set('n', '-7.2e11[Pa]'); model.material('mat1').propertyGroup('Murnaghan').set('lambLame', '1.5e11[Pa]'); model.material('mat1').propertyGroup('Murnaghan').set('muLame', '7.5e10[Pa]'); model.material('mat1').propertyGroup('Lame').set('lambLame', '1.5e11[Pa]'); model.material('mat1').propertyGroup('Lame').set('muLame', '7.5e10[Pa]'); model.material('mat1').propertyGroup('NeoHookean').set('mu', '7.5e10[Pa]'); model.material('mat1').propertyGroup('NeoHookean').set('lambda', '1.5e11[Pa]'); model.physics('solid').prop('Type2D').set('Type2D', 'PlaneStress'); model.physics('solid').prop('d').set('d', '0.01'); model.physics('solid').feature('lemm1').set('E_mat', 'userdef'); model.physics('solid').feature('lemm1').set('E', 'E_SIMP'); model.physics('solid').feature('bndl1').set('FperLength', {'0'; '-F_load'; '0'}); model.physics('solid').feature('bndl1').set('LoadType', 'ForceLength'); model.physics('opt').feature('cvar1').set('fieldVariableName', 'rho_design'); model.physics('opt').feature('cvar1').set('initialValue', 'A_frac'); model.physics('opt').feature('cvar1').set('order', '1'); model.physics('opt').feature('pconstr1').set('constraintExpression', 'mod1.rho_design'); model.physics('opt').feature('pconstr1').set('lowerBound', '1e-4'); model.physics('opt').feature('pconstr1').set('upperBound', '1'); model.physics('opt').feature('iconstr1').set('constraintExpression', 'mod1.rho_design'); model.physics('opt').feature('iconstr1').set('upperBound', 'mod1.A_designdomain*A_frac'); model.physics('opt').feature('iobj1').set('objectiveExpression', 'solid.Ws'); model.mesh('mesh1').feature('size').set('hmax', '7e-3'); model.mesh('mesh1').feature('size').set('hauto', '4'); model.mesh('mesh1').feature('size').set('hmax', '7e-3'); model.mesh('mesh1').run; model.study.create('std1'); model.study('std1').feature.create('stat', 'Stationary'); model.sol.create('sol1'); model.sol('sol1').study('std1'); model.sol('sol1').attach('std1'); model.sol('sol1').feature.create('st1', 'StudyStep'); model.sol('sol1').feature.create('v1', 'Variables'); model.sol('sol1').feature.create('o1', 'Optimization'); model.sol('sol1').feature('o1').feature.create('s1', 'StationaryAttrib'); model.sol('sol1').feature('o1').feature('s1').feature.create('fc1', 'FullyCoupled'); model.sol('sol1').feature('o1').feature('s1').feature.remove('fcDef'); model.result.numerical.create('gev1', 'EvalGlobal'); model.result.numerical('gev1').set('probetag', 'none'); model.result.numerical.create('gev2', 'EvalGlobal'); model.result.numerical('gev2').set('probetag', 'none'); model.result.create('pg1', 'PlotGroup2D'); model.result('pg1').feature.create('surf1', 'Surface'); model.result('pg1').feature('surf1').feature.create('def', 'Deform'); model.result.create('pg2', 'PlotGroup2D'); model.result('pg2').feature.create('surf1', 'Surface'); model.study('std1').feature('stat').set('optimization', true); model.study('std1').feature('stat').set('plot', 'on'); model.study('std1').feature('stat').set('plotgroup', 'pg2'); model.sol('sol1').feature('st1').name('Compile Equations: Stationary'); model.sol('sol1').feature('st1').set('studystep', 'stat'); model.sol('sol1').feature('v1').set('control', 'stat'); model.sol('sol1').feature('o1').set('plot', 'on'); model.sol('sol1').feature('o1').set('plotgroup', 'pg2'); model.sol('sol1').feature('o1').feature('s1').set('control', 'stat'); model.sol('sol1').feature('o1').feature('s1').set('stol', '1e-6'); model.sol('sol1').runAll; model.result.numerical('gev1').name('Objective value'); model.result.numerical('gev1').set('descr', 'Objective value'); model.result.numerical('gev2').name('Objective value 1'); model.result.numerical('gev2').set('expr', 'opt.iobj1'); model.result.numerical('gev2').set('unit', 'N'); model.result.numerical('gev2').set('descr', 'Objective value'); model.result('pg1').name('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').feature('def').active(false); model.result('pg1').feature('surf1').feature('def').set('scale', '6.193660920062766'); model.result('pg1').feature('surf1').feature('def').set('scaleactive', false); model.result('pg2').feature('surf1').set('expr', '1-rho_design'); model.result('pg2').feature('surf1').set('unit', ''); model.result('pg2').feature('surf1').set('descractive', true); model.result('pg2').feature('surf1').set('descr', 'Distribution of material'); model.result('pg2').feature('surf1').set('colortable', 'GrayScale'); out = model;