COMSOL Forums: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/
Most recent forum messagesFri, 11 Oct 2013 14:58:47 +0000COMSOL Forums: integration over frequency but keeping spatial dependencyhttp://www.comsol.com/shared/images/logos/comsol_logo.gif
http://www.comsol.com/community/forums/general/thread/39845/
Re: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108875
Hi, Alex<br />
<br />
If you could upload your file (better, a 2D simplified version of it), perhaps we could help you.<br />
<br />
Regards,<br />
Jesus.Fri, 11 Oct 2013 14:58:47 +000039845.1381503527.108875Re: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108839
Hi Jesus,<br />
<br />
yes, i got you, sorry for the confusion. <br />
<br />
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: <br />
<br />
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).<br />
<br />
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).<br />
<br />
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)<br />
<br />
Any further comments very welcome!<br />
Best regards,<br />
AlexThu, 10 Oct 2013 15:22:52 +000039845.1381418572.108839Re: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108745
Hi, Alex,<br />
<br />
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:<br />
<br />
f (source term), set to "d(b,freq) - absor", where "absor" is your integrand (absorption?), and<br />
a (absorption coefficient), set to a very small value, say 0.00001 . Try with lower values.<br />
<br />
Once you have the solution (also for "b"), you can just compute (for instance show as a color plot) "b(freq2) - b(freq1)".<br />
<br />
Regards,<br />
Jesus.Tue, 08 Oct 2013 22:31:14 +000039845.1381271474.108745Re: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108734
Hi, <br />
<br />
Thanks for your suggestion, very much appreciated!<br />
<br />
I tried your suggestion (ODE equation "a - d(b, freq)"), but it seems that either <br />
<br />
...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". <br />
<br />
...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<br />
<br />
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.<br />
<br />
Best regardsTue, 08 Oct 2013 19:45:01 +000039845.1381261501.108734Re: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108725
Hi,<br />
Sorry for the misunderstanding. I had thought of a Global variable. But you explained it quite clear.<br />
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):<br />
a - d(b, freq) . <br />
If that works, after the solution you would have b(x, y, z), i.e., the integration of "a" over frequency.<br />
<br />
Perhaps that could work.Tue, 08 Oct 2013 16:13:15 +000039845.1381248795.108725Re: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108677
Hi Jesus, <br />
<br />
thanks for your reply. <br />
<br />
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 export-file 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 50-100 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.<br />
<br />
I need:<br />
<br />
b=b(x,y,z)=integral a(f,x,y,z) df <br />
<br />
(lower int-limit: min_freq, upper int-limit max_freq, a=Absorption).<br />
<br />
Any other suggestions on how to handle this? I have seen that a time-integral operator exists. Maybe there is a similar operator for frequency instead of time?<br />
<br />
Best regards, <br />
AlexTue, 08 Oct 2013 00:35:12 +000039845.1381192512.108677Re: integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108657
Hi,<br />
<br />
A silly but effective trick:<br />
1. Generate the table (freq appears at first column). <br />
2. Save it as a text file.<br />
3. Create an interpolation function, choosing the last text file. Say that you name it int1.<br />
4. Update the model (with F5).<br />
5. In "Results / Derived Values", just type (for one of the values of the parameter, for instance the first one):<br />
integrate(int1(f), f, f1, f2)<br />
where f1 and f2 are the lower and upper bounds of the integral.<br />
<br />
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.<br />
<br />
Regards,<br />
Jesus.Mon, 07 Oct 2013 19:51:32 +000039845.1381175492.108657integration over frequency but keeping spatial dependency
http://www.comsol.com/community/forums/general/thread/39845/#p108623
Dear community,<br />
<br />
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? <br />
<br />
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. <br />
<br />
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.<br />
<br />
Any hints are very welcome,<br />
Thanks and best regards,<br />
AlexMon, 07 Oct 2013 12:18:18 +000039845.1381148298.108623