Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.

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.

Function to return larger of two arguments

Please login with a confirmed email address before reporting spam

Hey Comsolers,
I have an equation that depends on one of two variables (x and y), whichever one is larger at the spatial location in the geometry where the equation is being evaluated. The values of these variables at any given spatial location depend on input parameters and other things so that I cannot simply use variable x up to a certain point and then use y after that. Is there a built in MAX(x,y) function or is there another way to do this?

Thanks,
Bryan

4 Replies Last Post Nov 17, 2016, 7:21 a.m. EST

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Nov 15, 2016, 7:26 p.m. EST
Yes, there is a max(a,b) function. COMSOL is case-sensitive, so MAX(a,b) may not work.

--
Steven Conrad, MD PhD
LSU Health
Yes, there is a max(a,b) function. COMSOL is case-sensitive, so MAX(a,b) may not work. -- Steven Conrad, MD PhD LSU Health

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Nov 16, 2016, 12:31 p.m. EST
I was under the impression that max(a,b) would give me the value of b at the location of the maximum of a, which isn't quite what I want to do.
I was under the impression that max(a,b) would give me the value of b at the location of the maximum of a, which isn't quite what I want to do.

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Nov 16, 2016, 1:40 p.m. EST
According to the reference manual, it will give the maximum of the two arguments. I've attached a snip of the reference manual. I also tested the function in a COMSOL model, and it behaves as I described. It can be used with global or solution (spacially aware) arguments, so you can use it to find the max of two variables in your geometry. I'm using 5.2a, but I doubt the function would have changed from 4.4

--
Steven Conrad, MD PhD
LSU Health
According to the reference manual, it will give the maximum of the two arguments. I've attached a snip of the reference manual. I also tested the function in a COMSOL model, and it behaves as I described. It can be used with global or solution (spacially aware) arguments, so you can use it to find the max of two variables in your geometry. I'm using 5.2a, but I doubt the function would have changed from 4.4 -- Steven Conrad, MD PhD LSU Health


Gunnar Andersson COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 7 years ago Nov 17, 2016, 7:21 a.m. EST

I was under the impression that max(a,b) would give me the value of b at the location of the maximum of a, which isn't quite what I want to do.


If you create a Component Coupling of type Maximum, then you get this behavior. The function max() behaves the way Steve describes.
[QUOTE] I was under the impression that max(a,b) would give me the value of b at the location of the maximum of a, which isn't quite what I want to do. [/QUOTE] If you create a Component Coupling of type Maximum, then you get this behavior. The function max() behaves the way Steve describes.

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.