
clc
clear
close all
addpath(''); %add your own comsol path
model = mphopen('model.mph');
c = 0;
frange = 10.^[-8:1:4];%the simulated frecquency range
[sigm,diel] = complexc(frange);%calculate the add-on effective complex conductivity for grains

k = 0.0775;
for f = frange;
c = c+1;
model.param().set("f", f);
model.param().set("si", sigm);
model.param().set("d", diel(c));
model.study('std3').run; 
Rc = mphglobal(model,'bnd1/bnd2','dataset','dset1');
pha(c)= angle(Rc);
mag(c)= abs(Rc);
[re(c),im(c)] = mag2con(mag(c),pha(c),k);%calculate the in-phase and quadrature conductivity
end


