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.

Integration from 0 to y in 2D

Please login with a confirmed email address before reporting spam

Hi community,
I have a function f(x,y) defined on a 2D subdomain x=0..a and y=0..b and I want to calculate at each point (x,y) the Integral I2:
I2(x,y)=int_0^y f(x,y') dy'

In a 1d model, this can be done using an Integration coupling variable and the dest operator :
for example I1(x) = int_0^x f(x') dx' is done by writing as integrand : f*(x<dest(x))

But in 2d if I write f*dest(y) it performs int_0^a int_0^y f(x,y') dy' dx and I don't want my expression to be integrated over x !

I've tried a projection from my 2d domain on a 1d domain x=0..a and then extrude it again on a 2d domain x=0..a y=0..b but it calculates the integral from 0 to b : I3(x,y)=int_0^b f(x,y') dy'

Does any of you have an idea ?

I know that i could define subdomain but I want the value of the integral at every point of the 2d domain so it makes a lot of subdomain to create...

I've attached my model with the post.

Thanks a lot. Best Regards

Thomas Doki-Thonon


6 Replies Last Post Jul 1, 2011, 2:50 a.m. EDT

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 12, 2009, 3:02 p.m. EDT
Hi, why don't you introduce a new general form PDE, call the dependent variable u with the following settings:

Gamma = 0 0
F = uy-f(x,y)

The solution to the PDE, u(x,y) is then the integral that you desire, i.e. u(x,y)=I2(x,y)=int_0^y f(x,y') dy'

To do this with coupling variables you would have to extrude the solution to a 3D prism and then project back to the 2D domain which is tricky and computationally more expensive.

/ Dan
COMSOL Development
Hi, why don't you introduce a new general form PDE, call the dependent variable u with the following settings: Gamma = 0 0 F = uy-f(x,y) The solution to the PDE, u(x,y) is then the integral that you desire, i.e. u(x,y)=I2(x,y)=int_0^y f(x,y') dy' To do this with coupling variables you would have to extrude the solution to a 3D prism and then project back to the 2D domain which is tricky and computationally more expensive. / Dan COMSOL Development

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 13, 2009, 4:50 a.m. EDT
Hi Dan,

Thanks for your answer,

I've tried both methods:

PDE Method
I'm confusing about the PDE Methods. In the attached file i tried to integrate a simple function f(x,y)=y but what i obtain disagree with the analytical integral (plotted in Geom 4)

About the projection/extrusion method :
I think that I've understood what you meant :
1) Extruding 2D surface onto the first parallel face of a 3D Prism
2) Projecting 3D Prism along a direction Perpendicular to the second parallel face of the Prism back on the 2D Surface. Since the extruded Surface are "cut" by the obliqued plane. When I project I get the integral from 0 to y.
Am I right ? Because I didn't manage to create the extrusion and projection.


I think the first method could be perfect for my problem, do see in my file where my mistake is ?
Thanks a ton for your help and answers.
Hi Dan, Thanks for your answer, I've tried both methods: PDE Method I'm confusing about the PDE Methods. In the attached file i tried to integrate a simple function f(x,y)=y but what i obtain disagree with the analytical integral (plotted in Geom 4) About the projection/extrusion method : I think that I've understood what you meant : 1) Extruding 2D surface onto the first parallel face of a 3D Prism 2) Projecting 3D Prism along a direction Perpendicular to the second parallel face of the Prism back on the 2D Surface. Since the extruded Surface are "cut" by the obliqued plane. When I project I get the integral from 0 to y. Am I right ? Because I didn't manage to create the extrusion and projection. I think the first method could be perfect for my problem, do see in my file where my mistake is ? Thanks a ton for your help and answers.


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 13, 2009, 9:36 a.m. EDT
Hi, you need to constrain the value of u on the lower boundary at y=0 to make the solution unique. Enter -u in the R edit field on boundary 2 and you get the correct solution.

/ Dan
Hi, you need to constrain the value of u on the lower boundary at y=0 to make the solution unique. Enter -u in the R edit field on boundary 2 and you get the correct solution. / Dan

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Aug 13, 2009, 9:47 a.m. EDT
Hi Dan,

It works, thanks a lot !

Hi Dan, It works, thanks a lot !

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Dec 15, 2010, 1:07 p.m. EST
Hi, Dan,

Have you ever tried 3D. My application can be simplified as:
? (? u)=exp(int(-a*z'),z'=0 to z)
note: alpha is dependent on u, so, I can not use an analytical form for the right part of the equation.
To this, assume u1, u2
? (? u1)=u2
du2/dz=-a*u2

As one test step to solve the above problem, I tried to solve the second equation alone by assuming the right part is a known function:
du2/dz=f(x,y,z)
The geometry is a cylinder. The top boundary is set to be R=1-u2=0. other boundaries with G=0, R=0.
However, it is quit slow and says "can not find the solution" sometimes.

Is there any special way to do that in 3D?

Thanks in advance
Thanks,
Jiang
Hi, Dan, Have you ever tried 3D. My application can be simplified as: ? (? u)=exp(int(-a*z'),z'=0 to z) note: alpha is dependent on u, so, I can not use an analytical form for the right part of the equation. To this, assume u1, u2 ? (? u1)=u2 du2/dz=-a*u2 As one test step to solve the above problem, I tried to solve the second equation alone by assuming the right part is a known function: du2/dz=f(x,y,z) The geometry is a cylinder. The top boundary is set to be R=1-u2=0. other boundaries with G=0, R=0. However, it is quit slow and says "can not find the solution" sometimes. Is there any special way to do that in 3D? Thanks in advance Thanks, Jiang

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Jul 1, 2011, 2:50 a.m. EDT
Hi all!

I want to use I2(x,b), which is defined as I2(x,b)=int_0^b f(x,y') dy', as a coefficient in a PDE. This PDE has a dependent variable,say 'u'. But, f(x,y) is itself a function of 'u'.

Anybody has an idea how to do it?

Regards,
Tanmay
Hi all! I want to use I2(x,b), which is defined as I2(x,b)=int_0^b f(x,y') dy', as a coefficient in a PDE. This PDE has a dependent variable,say 'u'. But, f(x,y) is itself a function of 'u'. Anybody has an idea how to do it? Regards, Tanmay

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.