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

Increase stiffness by adding more stiffer material in optimization

$
0
0
Please, find the matlab code below. I have a 2D model. The base material (mat1) has the young modulus (E1) of 1 and poisson ratio of 0.3. The compliance is 52.79. In order to reduce the compliance (increase the stiffness) of the model, I added a strip of material (mat2) which young modulus (E2) is 5 and poisson ratio equals 0.3. This reduces the compliance of my model to 50.23. I want to run an optimization using the livelink to add more mat2 to my model in order to minimize the compliance further to 43. How can I use mat2 as the design variable? Thank you

% Matlab code
%.................................................................................

function f = two_materials
%
% two_materials.m
%
% Model exported on Sep 3 2017, 06:19 by COMSOL 5.2.1.152.

import com.comsol.model.*
import com.comsol.model.util.*

model = ModelUtil.create('Model');

model.modelPath('C:\Users\sayinde\Dropbox\demo for diff materials');

model.label('two_materials.mph');

model.comments(['Untitled\n\n']);

model.modelNode.create('comp1');

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

model.mesh.create('mesh1', 'geom1');

model.geom('geom1').create('b1', 'BezierPolygon');
model.geom('geom1').feature('b1').set('p', {'-1.5' '-1.5' '-0.5' '-0.5' '0.6' '0.6' '-1.5'; ...
'0.7' '-0.3' '-0.3' '-0.1' '-0.1' '0.7' '0.7'});
model.geom('geom1').feature('b1').set('w', {'1' '1' '1' '1' '1' '1' '1' '1' '1' '1' ...
'1' '1'});
model.geom('geom1').feature('b1').set('degree', {'1' '1' '1' '1' '1' '1'});
model.geom('geom1').create('b2', 'BezierPolygon');
model.geom('geom1').feature('b2').set('p', {'-1.3' '-1.3' '-0.9' '-0.9' '-1.3'; '0.3' '0.5' '0.5' '0.3' '0.3'});
model.geom('geom1').feature('b2').set('w', {'1' '1' '1' '1' '1' '1' '1' '1'});
model.geom('geom1').feature('b2').set('degree', {'1' '1' '1' '1'});
model.geom('geom1').run;
model.geom('geom1').run('fin');

model.material.create('mat1', 'Common', 'comp1');
model.material.create('mat2', 'Common', 'comp1');
model.material('mat1').selection.set([1]);
model.material('mat1').propertyGroup.create('Enu', 'Young''s modulus and Poisson''s ratio');
model.material('mat2').selection.set([2]);
model.material('mat2').propertyGroup.create('Enu', 'Young''s modulus and Poisson''s ratio');

model.physics.create('solid', 'SolidMechanics', 'geom1');
model.physics('solid').create('fix1', 'Fixed', 1);
model.physics('solid').feature('fix1').selection.set([1]);
model.physics('solid').create('pl1', 'PointLoad', 0);
model.physics('solid').feature('pl1').selection.set([9]);

model.view('view1').axis.set('abstractviewrratio', '0.17300830781459808');
model.view('view1').axis.set('abstractviewlratio', '-0.055711157619953156');
model.view('view1').axis.set('abstractviewxscale', '0.005181347019970417');
model.view('view1').axis.set('abstractviewbratio', '-0.4787564277648926');
model.view('view1').axis.set('xmax', '0.6794240474700928');
model.view('view1').axis.set('xmin', '-1.5255756378173828');
model.view('view1').axis.set('abstractviewyscale', '0.005181347019970417');
model.view('view1').axis.set('ymax', '0.9334676861763');
model.view('view1').axis.set('ymin', '-0.8447578549385071');
model.view('view1').axis.set('abstractviewtratio', '0.20518136024475098');

model.material('mat1').label('E=1 poison =0.3');
model.material('mat1').propertyGroup('Enu').set('youngsmodulus', '1');
model.material('mat1').propertyGroup('Enu').set('poissonsratio', '0.3');
model.material('mat2').label('E=5 poison=0.3');
model.material('mat2').propertyGroup('Enu').set('youngsmodulus', '5');
model.material('mat2').propertyGroup('Enu').set('poissonsratio', '0.3');

model.physics('solid').feature('pl1').set('Fp', {'0'; '-1'; '0'});

model.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').feature.remove('fcDef');

model.result.create('pg1', 'PlotGroup2D');
model.result('pg1').create('surf1', 'Surface');
model.result('pg1').feature('surf1').create('def', 'Deform');

model.sol('sol1').attach('std1');
model.sol('sol1').runAll;

model.result('pg1').label('Stress (solid)');
model.result('pg1').feature('surf1').set('descr', 'von Mises stress');
model.result('pg1').feature('surf1').set('unit', 'N/m^2');
model.result('pg1').feature('surf1').set('expr', 'solid.mises');
model.result('pg1').feature('surf1').set('resolution', 'normal');
model.result('pg1').feature('surf1').feature('def').set('scale', '0.002963085086206459');
model.result('pg1').feature('surf1').feature('def').set('scaleactive', false);

model.sol('sol1').study('std1');

model.study('std1').feature('stat').set('notlistsolnum', 1);
model.study('std1').feature('stat').set('notsolnum', '1');
model.study('std1').feature('stat').set('listsolnum', 1);
model.study('std1').feature('stat').set('solnum', '1');

model.sol('sol1').feature.remove('s1');
model.sol('sol1').feature.remove('v1');
model.sol('sol1').feature.remove('st1');
model.sol('sol1').create('st1', 'StudyStep');
model.sol('sol1').feature('st1').set('study', 'std1');
model.sol('sol1').feature('st1').set('studystep', 'stat');
model.sol('sol1').create('v1', 'Variables');
model.sol('sol1').feature('v1').set('control', 'stat');
model.sol('sol1').create('s1', 'Stationary');
model.sol('sol1').feature('s1').create('fc1', 'FullyCoupled');
model.sol('sol1').feature('s1').feature('fc1').set('termonres', 'auto');
model.sol('sol1').feature('s1').feature('fc1').set('reserrfact', 1000);
model.sol('sol1').feature('s1').feature('fc1').set('linsolver', 'dDef');
model.sol('sol1').feature('s1').feature('fc1').set('termonres', 'auto');
model.sol('sol1').feature('s1').feature('fc1').set('reserrfact', 1000);
model.sol('sol1').feature('s1').feature.remove('fcDef');
model.sol('sol1').attach('std1');
model.sol('sol1').runAll;

model.result('pg1').run;

FA = mphmatrix(model, 'sol1', 'out', {'K','E'});
K = FA.K; % stiffness vector
% solve directly from constrained matrices
MA = mphmatrix(model ,'sol1','Out', {'Kc','Lc','Null','ud','uscale'},'initmethod','sol','initsol','zero');
Uc = MA.Null*(MA.Kc\MA.Lc);
U0 = Uc+MA.ud;
U1 = U0.*MA.uscale;
compliance = U1'*K*U1; % u is the global displacement I want to use to compute the compliance
assignin('base','compliance',compliance)

f = compliance;

mphgeom(model)

end



Viewing all articles
Browse latest Browse all 428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>