Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Specific plots in COMSOL

Please login with a confirmed email address before reporting spam

Hello,

I calculated the acoustic modes, in preassure field , of a certain 3D structure and I want to make specific plots that I can't manage to make with COMSOL :

1) For each mode, I calculated and . In the table where the values are displayed, how to calculate the ratio of the 2 columns ?

2) At each point of the domain, I want to know what frequency of the calculated modes gives the maximum value of the pressure field and plots the obtained values of the max on the domain, is it possible to do this?

Thanks in advance,

Romain L.


4 Replies Last Post 2022年12月13日 GMT-5 05:20
Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 2 years ago 2022年11月28日 GMT-5 03:03

1) I understand this as max and average over the domain. You can create variables for this under Definition->Variables, and then just create another variable for the ratio. However, note that p^2 is in general a complex number. Also, since the scale of an eigenmode is arbitrary, taking the ratio of something that has a linear dependence on the amplitude and something that has a quadratic dependence seems suspect.

2) Since eigenmodes have an arbitrary scaling, comparing values between modes is in general not a meaningful operation.

-------------------
Henrik Sönnerlind
COMSOL
1) I understand this as max and average over the domain. You can create variables for this under Definition->Variables, and then just create another variable for the ratio. However, note that p^2 is in general a complex number. Also, since the scale of an eigenmode is arbitrary, taking the ratio of something that has a linear dependence on the amplitude and something that has a quadratic dependence seems suspect. 2) Since eigenmodes have an arbitrary scaling, comparing values between modes is in general not a meaningful operation.

Please login with a confirmed email address before reporting spam

Posted: 2 years ago 2022年11月28日 GMT-5 15:04
Updated: 2 years ago 2022年11月28日 GMT-5 16:17

Thank you for your quick reply.

1) I understand this as max and average over the domain. You can create variables for this under Definition->Variables, and then just create another variable for the ratio. However, note that p^2 is in general a complex number. Also, since the scale of an eigenmode is arbitrary, taking the ratio of something that has a linear dependence on the amplitude and something that has a quadratic dependence seems suspect.

Thanks for the clarification, I managed to implement it. For the problem I am considering the solution has no imaginary part. The ratio (I forgot the square root) is used to find out if a mode is located in a zone of the domain, if the ratio is big then the mode is mostly located. Divided by amounts to normalizing the mode by its L2-norm.

2) Since eigenmodes have an arbitrary scaling, comparing values between modes is in general not a meaningful operation.

In fact, it is not directly on the modes that I want to carry out this operation but on a slightly different problem where scaling has a precise meaning. I used the example of the modes to make it clearer. So, is it possible to plot such a function based on a frequency array in COMSOL ?

Thank you for your quick reply. >1) I understand this as max and average over the domain. You can create variables for this under Definition->Variables, and then just create another variable for the ratio. However, note that p^2 is in general a complex number. Also, since the scale of an eigenmode is arbitrary, taking the ratio of something that has a linear dependence on the amplitude and something that has a quadratic dependence seems suspect. Thanks for the clarification, I managed to implement it. For the problem I am considering the solution has no imaginary part. The ratio \text{max}(|p|) / \sqrt{\text{avg}(p^2)} (I forgot the square root) is used to find out if a mode is located in a zone of the domain, if the ratio is big then the mode is mostly located. Divided by \sqrt{\text{avg}(p^2)} amounts to normalizing the mode by its L2-norm. >2) Since eigenmodes have an arbitrary scaling, comparing values between modes is in general not a meaningful operation. In fact, it is not directly on the modes that I want to carry out this operation but on a slightly different problem where scaling has a precise meaning. I used the example of the modes to make it clearer. So, is it possible to plot such a function f(\bm{x})=\underset{\omega}{\text{max}} |p(\bm{x},\omega)| based on a frequency array in COMSOL ?

Henrik Sönnerlind COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 2 years ago 2022年11月29日 GMT-5 10:33

Assuming that you do not have too many modes, you can plot an expression like (using 4 modes here)

max(with(4,pa),max(with(3,pa),max(with(2,pa),with(1,pa))))

where pa is a variable containing abs(p).

If you have hundreds of modes, it may become a bit boring to write the expression, though. Then you may want to resort to scripting, using model methods or Matlab. You can even use a script just to create the very long expression.

For time-domain analysis there is an operator called timemax() doing this type of max value search, but there is nothing similar built in for eigenmodes.

-------------------
Henrik Sönnerlind
COMSOL
Assuming that you do not have too many modes, you can plot an expression like (using 4 modes here) *max(with(4,pa),max(with(3,pa),max(with(2,pa),with(1,pa))))* where *pa* is a variable containing *abs(p)*. If you have hundreds of modes, it may become a bit boring to write the expression, though. Then you may want to resort to scripting, using model methods or Matlab. You can even use a script just to create the very long expression. For time-domain analysis there is an operator called *timemax()* doing this type of max value search, but there is nothing similar built in for eigenmodes.

Please login with a confirmed email address before reporting spam

Posted: 2 years ago 2022年12月13日 GMT-5 05:20

Thank you very much Henrik, indeed this way of doing things works well. I used a Python script to express the forumula which can, indeed, become long.

Thank you very much Henrik, indeed this way of doing things works well. I used a Python script to express the forumula which can, indeed, become long.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.