
Filter by Topic
Release
Popular Topics
 List all discussions
integration over frequency but keeping spatial dependency
Thread index  Previous thread  Next thread  Start a new discussion 
October 7, 2013 8:18am UTC
integration over frequency but keeping spatial dependency
Dear community,
Using the rf module I perform a frequency sweep. Now, I want to integrate the calculated absorption profile over the frequency, but keep the spatial dependency, ie no integration over the volume. Can anyone give me a tip/hint on how to do this?
Integration in 'derived values' in the 'results' part always seems to be a spatial integration (volume/surface/line) but not over other variables like frequency.
I also tried to make a global variable my_var=integrate(ewdf.Qe, freq,freqmin,freqmax) (with ewdf.Qe being the absorbed power, freqmin/freqmax minimal/maximal frequency I use) but that does not seem to be right. Comsol does not give an error message and calculates this variable, but when i plot it it is a different graph when I choose another frequency in the frequency list in the plotting window. This shouldn't be since I want to integrate over frequency and thus my_var should be frequency independent.
Any hints are very welcome,
Thanks and best regards,
Alex
Reply  Reply with Quote  Send private message  Report Abuse
October 7, 2013 3:51pm UTC in response to alex
Re: integration over frequency but keeping spatial dependency
Hi,
A silly but effective trick:
1. Generate the table (freq appears at first column).
2. Save it as a text file.
3. Create an interpolation function, choosing the last text file. Say that you name it int1.
4. Update the model (with F5).
5. In "Results / Derived Values", just type (for one of the values of the parameter, for instance the first one):
integrate(int1(f), f, f1, f2)
where f1 and f2 are the lower and upper bounds of the integral.
But copying or exporting the table and integrating it in an external software (MATLAB, or even Excel) is extremely easy, you can resolve that numerical integration in few minutes.
Regards,
Jesus.
Reply  Reply with Quote  Send private message  Report Abuse
October 7, 2013 8:35pm UTC in response to Jesus Lucio
Re: integration over frequency but keeping spatial dependency
Hi Jesus,
thanks for your reply.
Yes, I was also thinking of exporting and evaluating the integral outside of comsol. But the thing is: I'd export quite alot of points (3D and rather large computational domain with large fraction of the absorbing medium). The exportfile for one frequency is already >300MB, exporting 2 frequencies already gives me the "Java Heap error" . I know i can change the java heap size somehow, but still I ususally have frequency sweeps of 50100 freqs, so it just would be too much data which I think could be avoided if it was possible to handle all of this inside comsol.
I need:
b=b(x,y,z)=integral a(f,x,y,z) df
(lower intlimit: min_freq, upper intlimit max_freq, a=Absorption).
Any other suggestions on how to handle this? I have seen that a timeintegral operator exists. Maybe there is a similar operator for frequency instead of time?
Best regards,
Alex
Reply  Reply with Quote  Send private message  Report Abuse
October 8, 2013 12:13pm UTC in response to alex
Re: integration over frequency but keeping spatial dependency
Hi,
Sorry for the misunderstanding. I had thought of a Global variable. But you explained it quite clear.
You could try to define an "algebraic" or ODE equation distributed over all the domain (or a PDE with all coefficients except f set to 0), for a variable b, with the expression (for f):
a  d(b, freq) .
If that works, after the solution you would have b(x, y, z), i.e., the integration of "a" over frequency.
Perhaps that could work.
Reply  Reply with Quote  Send private message  Report Abuse
October 8, 2013 3:45pm UTC in response to Jesus Lucio
Re: integration over frequency but keeping spatial dependency
Hi,
Thanks for your suggestion, very much appreciated!
I tried your suggestion (ODE equation "a  d(b, freq)"), but it seems that either
...when adding an additional study to evaluate that additional ODE: comsol does not know about 'a' (=Absorption=efwd.Qe) during solving, it gives the error message "cannot evaluate expression" and "cannot evaluate variable efwd.Qe".
...when adding an additional study step in the same study in which the electric fields are solved: comsol just gives zero for the variable i look for
I am wondering if there is any way to let comsol do the integration after solving. It shouldn't involve an additional solving step, since it does not need solve again, just evaluate / process the solutions.
Best regards
Reply  Reply with Quote  Send private message  Report Abuse
October 8, 2013 6:31pm UTC in response to alex
Re: integration over frequency but keeping spatial dependency
Hi, Alex,
I didn't mean to add a study, but to add a physics like "PDE Coefficient Form". And by "a" I meant your integrand variable (absorption?). I have tried something similar (in a simple 2D model), and it seems to work. I added a "Coefficient Form PDE" with dependent variable "b", and with coefficients all set to zero, except:
f (source term), set to "d(b,freq)  absor", where "absor" is your integrand (absorption?), and
a (absorption coefficient), set to a very small value, say 0.00001 . Try with lower values.
Once you have the solution (also for "b"), you can just compute (for instance show as a color plot) "b(freq2)  b(freq1)".
Regards,
Jesus.
Reply  Reply with Quote  Send private message  Report Abuse
October 10, 2013 11:22am UTC in response to Jesus Lucio
Re: integration over frequency but keeping spatial dependency
Hi Jesus,
yes, i got you, sorry for the confusion.
Thanks for your suggestions. Your approach looked very promising, and I tried it out / several things based on your approach. But I see some problems:
First, when including an additional PDE, solving time is more than doubled compared to only solving for the EM fields (ok, i could live with this).
It still feels somehow wrong: why does the variable i am after need to be solved for? Basically it should just be a simple algorithm: Adding all the absorption profiles (multiplicated with delta frequency) together, or in other words, get the area under the graph of the absorption profile plotted agains frequency (for each spatial point though to keep the spatial dependency).
Second, the results I get by the suggested approach are wrong: b(f2)b(1) (with f2>f1) can be positive or negative depending on f1 and f2. Since b basically is the summed up abosrption it should always be the same sign (+/ depending on convention)
Any further comments very welcome!
Best regards,
Alex
Reply  Reply with Quote  Send private message  Report Abuse
October 11, 2013 10:58am UTC in response to alex
Re: integration over frequency but keeping spatial dependency
Hi, Alex
If you could upload your file (better, a 2D simplified version of it), perhaps we could help you.
Regards,
Jesus.
Reply  Reply with Quote  Send private message  Report Abuse
Rules and guidelines