function out = almost_infinite_2D_axisym_TE_4(param) % Putting all the parameters in the variables r0 = param.beam.radius; R = param.mirror.radius; H = param.mirror.height; dt = param.COMSOL.simulation_time_step; fmod = param.COMSOL.fmod; t_end = param.COMSOL.simulation_end_time; p0 = param.constant.F0/(pi*r0^2);% The amplitude of Osc. pressure T_amb = param.constant.T_amb; trange = ['range(0,' num2str(dt) ',' num2str(t_end) ')'];% the time steps import com.comsol.model.* import com.comsol.model.util.* model = ModelUtil.create('Model'); model.modelPath('C:\Users\ligo\Documents\MATLAB\Deep Chatterjee 2013\COMSOL Projects'); model.name('2D_almost_infinte_TE_for_COMSOL.mph'); %%Parameters model.param.set('r0', [num2str(r0) '[cm]']); model.param.set('fmod', [num2str(fmod) '[Hz]']); model.param.set('T_amb', [num2str(T_amb) '[K]']); model.param.set('Rad', [num2str(R) '[m]']); model.param.set('H', [num2str(H) '[m]']); model.param.set('p0', [num2str(p0) '[Pa]']); %%Making Geometry model.modelNode.create('mod1'); disp('## Making Geometry'); model.geom.create('geom1', 2); model.geom('geom1').axisymmetric(true); model.geom('geom1').feature.create('r1', 'Rectangle'); model.geom('geom1').feature('r1').set('size', {'Rad' 'H'}); model.geom('geom1').run; model.material.create('mat2'); %%Adding Physics disp('## Adding Physics'); model.physics.create('ht', 'HeatTransfer', 'geom1'); model.physics('ht').feature('solid1').feature.create('pw1', 'PressureWork', 2); model.physics.create('solid', 'SolidMechanics', 'geom1'); model.physics('solid').feature('lemm1').feature.create('te1', 'ThermalExpansion', 2); model.physics('solid').feature.create('bndl1', 'BoundaryLoad', 1); model.physics('solid').feature('bndl1').selection.set([3]); model.physics('solid').feature.create('fix1', 'Fixed', 1); model.physics('solid').feature('fix1').selection.set([2 4]); %%Creating Mesh disp('## Creating Mesh'); model.mesh.create('mesh1', 'geom1'); model.mesh('mesh1').feature.create('dis1', 'Distribution'); model.mesh('mesh1').feature.create('dis2', 'Distribution'); model.mesh('mesh1').feature.create('ftri1', 'FreeTri'); model.mesh('mesh1').feature('dis1').selection.set([3]); model.mesh('mesh1').feature('dis2').selection.set([1]); model.view('view1').axis.set('xmin', '-0.404208779335022'); model.view('view1').axis.set('ymin', '8.727060317993164'); model.view('view1').axis.set('xmax', '1.1469862461090088'); model.view('view1').axis.set('ymax', '10.200899124145508'); % Custom Material values taken from BGV and other papers model.material('mat2').propertyGroup('def').set('thermalconductivity', {'1.38' '0' '0' '0' '1.38' '0' '0' '0' '1.38'}); model.material('mat2').propertyGroup('def').set('density', '2200'); model.material('mat2').propertyGroup('def').set('heatcapacity', '6.7e2'); model.material('mat2').propertyGroup('def').set('youngsmodulus', '7.2e10'); model.material('mat2').propertyGroup('def').set('poissonsratio', '0.17'); model.material('mat2').propertyGroup('def').set('thermalexpansioncoefficient', {'5.5e-7' '0' '0' '0' '5.5e-7' '0' '0' '0' '5.5e-7'}); model.physics('ht').feature('solid1').feature('pw1').set('Ent_src', 'root.mod1.solid.Ent'); model.physics('ht').feature('init1').set('T', 'T_amb'); model.physics('solid').prop('EquationForm').set('form', 'Frequency'); model.physics('solid').prop('EquationForm').set('freq_src', 'userdef'); model.physics('solid').prop('EquationForm').set('freq', 'fmod'); model.physics('solid').feature('lemm1').feature('te1').set('Tref', 'T_amb'); model.physics('solid').feature('lemm1').feature('te1').set('minput_temperature', 'T_amb'); model.physics('solid').feature('bndl1').set('LoadType', 'FollowerPressure'); model.physics('solid').feature('bndl1').set('FollowerPressure', 'p0 * exp(-r^2/r0^2) * cos(2*pi*fmod*t)'); model.mesh('mesh1').feature('size').set('hauto', 4); model.mesh('mesh1').feature('size').set('custom', 'on'); model.mesh('mesh1').feature('size').set('hgrad', '1.15'); model.mesh('mesh1').feature('dis1').set('elemratio', '8'); model.mesh('mesh1').feature('dis1').set('elemcount', '100'); model.mesh('mesh1').feature('dis1').set('type', 'predefined'); model.mesh('mesh1').feature('dis2').set('elemratio', '14'); model.mesh('mesh1').feature('dis2').set('method', 'geometric'); model.mesh('mesh1').feature('dis2').set('elemcount', '120'); model.mesh('mesh1').feature('dis2').set('type', 'predefined'); model.mesh('mesh1').feature('dis2').set('reverse', true); model.mesh('mesh1').run; model.study.create('std1'); model.study('std1').feature.create('time', 'Transient'); %%Solvers 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('t1', 'Time'); model.sol('sol1').feature('t1').feature.create('fc1', 'FullyCoupled'); model.sol('sol1').feature('t1').feature.create('d1', 'Direct'); model.sol('sol1').feature('t1').feature.remove('fcDef'); model.study('std1').feature('time').set('initstudyhide', 'on'); model.study('std1').feature('time').set('initsolhide', 'on'); model.study('std1').feature('time').set('notstudyhide', 'on'); model.study('std1').feature('time').set('notsolhide', 'on'); model.study('std1').feature('time').set('tlist', trange); model.sol('sol1').attach('std1'); model.sol('sol1').feature('st1').name('Compile Equations: Time Dependent'); model.sol('sol1').feature('st1').set('studystep', 'time'); model.sol('sol1').feature('v1').set('control', 'time'); model.sol('sol1').feature('v1').feature('mod1_u').set('scalemethod', 'manual'); model.sol('sol1').feature('v1').feature('mod1_u').set('scaleval', '1e-2*11.180339887498949'); model.sol('sol1').feature('t1').set('maxorder', '2'); model.sol('sol1').feature('t1').set('eventtol', '0.001'); model.sol('sol1').feature('t1').set('maxstepbdf', '0'); model.sol('sol1').feature('t1').set('tlist', 'range(0,(10/fmod-0)/199,10/fmod)'); model.sol('sol1').feature('t1').set('atolmethod', {'mod1_u' 'unscaled' 'mod1_T' 'global'}); model.sol('sol1').feature('t1').set('complex', true); model.sol('sol1').feature('t1').set('tstepsbdf', 'strict'); disp('## Running Solver'); model.sol('sol1').runAll; out = model;