function out = model % % test_one.m % % Model exported on Oct 6 2015, 10:39 by COMSOL 5.1.0.180. import com.comsol.model.* import com.comsol.model.util.* model = ModelUtil.create('Model'); model.modelPath('C:\Users\gk676.UNISIEGEN\Documents\MATLAB\Test'); model.comments(['Untitled\n\n']); model.modelNode.create('comp1'); model.geom.create('geom1', 2); model.mesh.create('mesh1', 'geom1'); model.geom('geom1').create('r1', 'Rectangle'); model.geom('geom1').run('r1'); model.physics.create('tds', 'DilutedSpecies', 'geom1', {'c'}); model.geom('geom1').run; model.physics('tds').prop('TransportMechanism').set('Convection', false); model.physics('tds').prop('ShapeProperty').set('boundaryFlux_concentration', false); model.physics('tds').feature('cdm1').set('D_c', {'1e-4[m^2/s]' '0' '0' '0' '1e-4[m^2/s]' '0' '0' '0' '1e-4[m^2/s]'}); model.physics('tds').feature.create('fl1', 'Fluxes', 1); model.physics('tds').feature('fl1').selection.set([2 3]); model.physics('tds').feature.create('conc1', 'Concentration', 1); model.physics('tds').feature('conc1').selection.set([3]); model.physics('tds').feature('conc1').setIndex('species', true, 0); model.physics('tds').feature('conc1').setIndex('c0', '0.21', 0); model.physics('tds').feature.create('conc2', 'Concentration', 1); model.physics('tds').feature('conc2').setIndex('species', true, 0); model.physics('tds').feature('conc2').selection.set([2]); model.mesh('mesh1').run; model.study.create('std1'); model.study('std1').create('time', 'Transient'); model.study('std1').feature('time').activate('tds', true); model.study('std1').feature('time').set('tlist', 'range(0,10,60)'); model.sol.create('sol1'); model.sol('sol1').study('std1'); model.study('std1').feature('time').set('notlistsolnum', 1); model.study('std1').feature('time').set('notsolnum', '1'); model.study('std1').feature('time').set('listsolnum', 1); model.study('std1').feature('time').set('solnum', '1'); model.sol('sol1').create('st1', 'StudyStep'); model.sol('sol1').feature('st1').set('study', 'std1'); model.sol('sol1').feature('st1').set('studystep', 'time'); model.sol('sol1').create('v1', 'Variables'); model.sol('sol1').feature('v1').set('control', 'time'); model.sol('sol1').create('t1', 'Time'); model.sol('sol1').feature('t1').set('tlist', 'range(0,10,60)'); model.sol('sol1').feature('t1').set('plot', 'off'); model.sol('sol1').feature('t1').set('plotgroup', 'Default'); 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('atolglobalmethod', 'scaled'); model.sol('sol1').feature('t1').set('atolglobal', 0.001); model.sol('sol1').feature('t1').set('maxorder', 2); model.sol('sol1').feature('t1').set('control', 'time'); model.sol('sol1').feature('t1').create('fc1', 'FullyCoupled'); model.sol('sol1').feature('t1').feature('fc1').set('jtech', 'once'); model.sol('sol1').feature('t1').feature('fc1').set('damp', 0.9); model.sol('sol1').feature('t1').feature('fc1').set('maxiter', 8); model.sol('sol1').feature('t1').create('d1', 'Direct'); model.sol('sol1').feature('t1').feature('d1').set('linsolver', 'pardiso'); model.sol('sol1').feature('t1').feature('fc1').set('linsolver', 'd1'); model.sol('sol1').feature('t1').feature('fc1').set('jtech', 'once'); model.sol('sol1').feature('t1').feature('fc1').set('damp', 0.9); model.sol('sol1').feature('t1').feature('fc1').set('maxiter', 8); model.sol('sol1').feature('t1').feature.remove('fcDef'); model.sol('sol1').attach('std1'); %To create the surface plot model.result.create('pg1', 'PlotGroup2D'); model.result('pg1').label('Concentration (tds)'); model.result('pg1').set('oldanalysistype', 'noneavailable'); model.result('pg1').set('data', 'dset1'); model.result('pg1').feature.create('surf1', 'Surface'); model.result('pg1').feature('surf1').label('Surface 1.1'); model.result('pg1').feature('surf1').set('oldanalysistype', 'noneavailable'); model.result('pg1').feature('surf1').set('descractive', true); model.result('pg1').feature('surf1').set('data', 'parent'); model.sol('sol1').runAll; % to run the solution 1 model.result('pg1').run; %to run the plot group1 %mphgetu transfers the solution vector to Matlab b = mphgetu(model); %Redefining the solution vector b(1)=1; b(2)=1; b(3)=1; %Overwriting the previous solution vector and creatign a new data set model.sol('sol1').setU(b) model.sol('sol1').createSolution() model.result('pg1').run out = model; mphsave(model, 'test_one.mph');