> On Tue, 3 Jul 2007, matt wrote:
>> I have the following data for a lossy material (nylon), and I'd like to
>> find the parameters for meep's lorentzian model which fit the data:
>>
>> frequency (hz)  real(eps) imag(eps)
>> 60      3.7     -.0666
>> 1e3     3.5     -.0651
>> 1e6     3.14    -.068452
>> 1e8     3.0     -.06
>> 3e9     2.84    -.033228
>> 2.5e10  2.73    -.028665
>>
>> There was an indication in a previous post that this is simple
>> [...]
>
> I'm not sure it's quite so simple, because most off-the-shelf fitting
> programs only fit a real-valued function, whereas here you have to fit a
> complex-valued function.  In general, you have to use a nonlinear
> optimization program to do the fit (to minimize the sum-of-squares errors
> or whatever error criterion you prefer).
>
> I don't have any off-the-shelf code to do this for the Lorentzian problem
> (although of course there are lots of off-the-shelf nonlinear optimization
> routines), but perhaps someone on the list does.
>
> Steven
>

Here is a snippet to coax MatLab into fitting a complex valued function (a 
single Lorentzian):
------------------
%Example data:
freq=[1 5 8 10 12 15 20];
epsre=[1.10 1.13 1.19 1.00 0.86 0.93 0.97];
epsim=[0.0031 0.026 0.13 0.33 0.11 0.026 0.0064];
epsilon=epsre+i*epsim;

%Plot it:
plot(freq,real(epsilon),'bo', freq,imag(epsilon),'ro');

lorentzian=inline('p(1)+p(2)*p(3)^2./(p(3)^2-f.^2-i*f*p(4))','p','f');
%p(1) - epsilon_infinity
%p(2) - Delta epsilon_n
%p(3) - w_n
%p(4) - gamma_n
fitfunc=inline('[real(p(1)+p(2)*p(3)^2./(p(3)^2-f.^2-i*f*p(4)))-re,imag(p(1)+p(2)*p(3)^2./(p(3)^2-f.^2-i*f*p(4)))-im]','p','f','re','im');
p=[0.9 0.15 8 2];  %initial guess
p=lsqnonlin(fitfunc,p,[],[],[],freq,real(epsilon),imag(epsilon));
disp(p)  %show the answer

%Plot the result:
f=1:0.01:20;
hold on; plot(f,real(lorentzian(p,f)),'b', f,imag(lorentzian(p,f)),'r');
------------

Unfortunately, Matt's data do not look like a Lorentzian, so it won't fit 
very well if you try it on his data.  Of course it is possible to add more 
Lorentzians, but quite a few Lorentzians would be needed to span the wide 
frequency range and since there are only few data points in Matt's table, a 
multiple Lorentzian fit would start doing funny things in between the data 
points (as if fitting a high order polynomial to scant data).
Perhaps you can interpolate the table a bit to alleviate this, and fix the 
w_n at the original frequency ordinates, only fitting the Delta epsilons and 
gammas?

Best regards,
m.


_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to