Ivar KJELBERG
COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
25.11.2011, 09:19 GMT-5
Hi
I would consider
a) a new Definitions variable Aaverage = aveop1(...) where aveop1 is an average operator defined in the Definition section
b) a pure postprocessing operation with a postprocessing average data set operation on one of the main or derived data sets
Solution A allows you to handle the variables as global variables for more complex calculations, solution b) does not give you that easily the freedom to combine postporcessing operators values
--
Good luck
Ivar
Hi
I would consider
a) a new Definitions variable Aaverage = aveop1(...) where aveop1 is an average operator defined in the Definition section
b) a pure postprocessing operation with a postprocessing average data set operation on one of the main or derived data sets
Solution A allows you to handle the variables as global variables for more complex calculations, solution b) does not give you that easily the freedom to combine postporcessing operators values
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
25.11.2011, 09:48 GMT-5
This is a solution that works in Matlab:
Since you already have extracted the Data of the plots in matlab you can use the matlab interp1 function to interpolate beween your points.
I assume you have 4 data variables in matlab.
x1 : xvaluesplot 1
x2 : xvaluesplot 2
y1: yvaluesplot 1
y2: yvaluesplot 2
so basically make a new vector of your variables like x=1:100 (x should run from the start to the end of your plot with a desired step size)
then calculate the average on every point of the new x seperation (you can use a finer seperation if you like)
y=(interp1(x1,y1,x) + interp1(x2,y2,x))/2
you can plot the average between your plots by plot(x,y)
Cheers
Robert
This is a solution that works in Matlab:
Since you already have extracted the Data of the plots in matlab you can use the matlab interp1 function to interpolate beween your points.
I assume you have 4 data variables in matlab.
x1 : xvaluesplot 1
x2 : xvaluesplot 2
y1: yvaluesplot 1
y2: yvaluesplot 2
so basically make a new vector of your variables like x=1:100 (x should run from the start to the end of your plot with a desired step size)
then calculate the average on every point of the new x seperation (you can use a finer seperation if you like)
y=(interp1(x1,y1,x) + interp1(x2,y2,x))/2
you can plot the average between your plots by plot(x,y)
Cheers
Robert
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
25.11.2011, 13:20 GMT-5
Dear Ivar
I appreciate your reply. I understand the second solution but I have a question about the first one:
you mentioned that I should define this "Average = aveop1(...)" but by doing this, can I get an average in specific part of model?
I thought we can only use this if we want to average a parameter in a specific location.
However, in My case the parameters are "Electric fields" which have been measured along a cut line that I defined. So basically I have 2 Cut lines in different location of model and I have the electric field in the points along this line.
Do you think Is it possible to use the operator in this case?? Have you seen any examples which use this method?
Best
Bahar
Dear Ivar
I appreciate your reply. I understand the second solution but I have a question about the first one:
you mentioned that I should define this "Average = aveop1(...)" but by doing this, can I get an average in specific part of model?
I thought we can only use this if we want to average a parameter in a specific location.
However, in My case the parameters are "Electric fields" which have been measured along a cut line that I defined. So basically I have 2 Cut lines in different location of model and I have the electric field in the points along this line.
Do you think Is it possible to use the operator in this case?? Have you seen any examples which use this method?
Best
Bahar
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
25.11.2011, 13:28 GMT-5
Dear Robert
Thanks a lot for the reply and complete description. At first I tought since the steps of these two sets of X s (and hence f(x)) are different I can not use interpolation. But Now by reading your reply I think it should work! I am going to try that and post the results here :)
Best
Bahar
Dear Robert
Thanks a lot for the reply and complete description. At first I tought since the steps of these two sets of X s (and hence f(x)) are different I can not use interpolation. But Now by reading your reply I think it should work! I am going to try that and post the results here :)
Best
Bahar
Ivar KJELBERG
COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
26.11.2011, 03:39 GMT-5
Hi Bahar
You are right that if you define a "Data Set Cut line" on the results, you cannot use that with an operator defined in the Definition node, as these only apply to existing Entities = domain, boundaries, ...
So either you make an internal bondary along a line or polyline ... in the geoemtry section (it's static) or you use the Postprocessing operators.
Unfortunately, from mxy knowledge, there is no "postprocessing variables" that can be defined in the Result section.
Perhaps COMSOL developers are hearing their ears sing now, hopefully, a suggestion for you here !! :)
A nice thing with COMSOL, often I see my whishes being exhausted in the new releases, provided the message passes.
So a "Result -Average" can (from my knowledge) only be dumped into a table, or a plot, and from there to a file, but NOT to a postprocessing variable.
What I have happened to do, is to dump the "cut-line data set" into a csv format file, then to read it in into an "int()" interpolation operator, and then use that for a second solving process, or furter data reduction, not the most handy way, but it works, from within the GUI.
The matlab approach gives you more freedom
--
Good luck
Ivar
Hi Bahar
You are right that if you define a "Data Set Cut line" on the results, you cannot use that with an operator defined in the Definition node, as these only apply to existing Entities = domain, boundaries, ...
So either you make an internal bondary along a line or polyline ... in the geoemtry section (it's static) or you use the Postprocessing operators.
Unfortunately, from mxy knowledge, there is no "postprocessing variables" that can be defined in the Result section.
Perhaps COMSOL developers are hearing their ears sing now, hopefully, a suggestion for you here !! :)
A nice thing with COMSOL, often I see my whishes being exhausted in the new releases, provided the message passes.
So a "Result -Average" can (from my knowledge) only be dumped into a table, or a plot, and from there to a file, but NOT to a postprocessing variable.
What I have happened to do, is to dump the "cut-line data set" into a csv format file, then to read it in into an "int()" interpolation operator, and then use that for a second solving process, or furter data reduction, not the most handy way, but it works, from within the GUI.
The matlab approach gives you more freedom
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Posted:
1 decade ago
02.12.2011, 12:45 GMT-5
Dear Ivar
Thanks a lot for the complete answer.
I tried tried int() and also used Matlab. I also think in this Case Matlab have more freedom for processing Data. Hopefully Comsol people will think about a way to make it easier in next version!!
Best
Bahar
Dear Ivar
Thanks a lot for the complete answer.
I tried tried int() and also used Matlab. I also think in this Case Matlab have more freedom for processing Data. Hopefully Comsol people will think about a way to make it easier in next version!!
Best
Bahar