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.
Volume Integral of different space dependent variables [Solved]
Posted 21 oct. 2014, 08:08 UTC−4 Materials, Parameters, Variables, & Functions Version 5.1 6 Replies
Please login with a confirmed email address before reporting spam
I am looking to calculate the following integral:
D(x1,y1,z1)=int(exp(-mu*r)*c(x,y,z) dx dy dz)
Where:
int is my volume integral (on x,y,z corresponding to my domain)
mu is an attenuation coefficient
r is the distance between points (x,y,z) and (x1,y1,z1)
c is the concentration
For information, my concentration is solved via a PDE and is thus defined in my whole domain (which is simply a block).
I tried different things but I am not able to calculate the distance r. If you have any suggestion it would be helpful.
Thanks in advance!
Christophe Gueibe
Please login with a confirmed email address before reporting spam
if I catch you right:
the "int() and dxdydz are "implicit" when you call up un integration operator or a post-processing "Derived Variable" operator.
Then the concentration is a dependent field variable so when you write "c" you write in fact
c(x,y,z) or even c(x,y,z,t)
over the defined Boundary (surface in 3D) or Domain (volume in 3D)
remains the "r" that you can either get via a spherical or cylindrical coordinate system definition with x1,y1,z1 as origin and a reference to the "sys2.r" or just as
sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2)
You can also define a local variable r=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2) over your Domain(s) and/or Boundary(ies) and use that
check the doc, in COMSOL you can write out equations in most if not all GUI field entries
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Yes I am calling an integration operator on the Domain (in my case a volume because of the 3D).
And yes, it is in fact c(x,y,z,t) (my concentration is a time dependent variable).
The thing is that I want D over my whole Domain, so x1,y1,z1 should also be defined on the whole Domain.
I looked into the Doc but I didn't find how I could call a variable (such as r=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2)), defined on my Domain, which is dependent on something else than the usual (x,y,z,t).
What I mean is that I want to call r(x1,y1,z1) with x1,y1,z1 defined everywhere in my Domain. For this I could use a mapped system to translate the coordinate to (x1,y1,z1) (as the origin) but then I have first to defined the variables x1,y1,z1 but there I don't see how to do it in order to represent my whole Domain.
I am still not completly used to Comsol but to give maybe a clear idea on what kind of result I want, if I would write it in Matlab for instance I would:
- Use a For loop to vary my x1,y1,z1 (going all over my domain)
- Use a For loop to calculate the integral for one x1,y1,z1 point
Then I would get my D(x1,y1,z1) matrix over the whole domain
Thanks for your time Ivar.
Christophe
Please login with a confirmed email address before reporting spam
well if I got your right, I would say you can "Define" first an "Integration operator" over your domain i.e. "intop1(...)", and then "Define" over your domain, an "Analytical function"
"an1(x1,x2,x3) = intop1( your_equation_with_sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2)) ) "
But it would probably take some time to solve (calculate), so I'm not sure its a good idea to use it in the equations solving process, but as post-processing variable it should work nicely
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
I tried to define the analytical function, but it seems like it's not possible to use an operator in an user defined function (Error message: Operators not allowed in user defined functions.).
I totally agree that doing this in the post-processing will be more convenient but there I still need to Define the x1,y1,z1 variables when calling the r=sqrt((x-x1)^2+(y-y1)^2+(z-z1)^2) variable. One way that I see to do this, is to plot the previous function in a 3D plot but with different coordinates than x,y,z ( x1,y1,z1 instead).
I tried to create a new coordinate system (x1,y1,z1). However, I don't see how to change the coordinate system in a 3D plot (it is always the x,y,z system). Is it possible to use other variables than x,y,z to plot in 3D?
Thanks for your time,
Christophe
Please login with a confirmed email address before reporting spam
I was helped by Comsol's support for my problem. Should anyone try to solve this kind of integral, there is a "destination" operator that can be used for coupling expressions in integrals (see "The dest operation" in the user guide).
For my example, I just defined the intop1() operator on my volume, then in my 3D plot I entered the following expression for my integral:
intop1(exp(-mu*sqrt((dest(x)-x)^2+(dest(y)-y)^2+(dest(z)-z)^2))*c)
Thanks to the support and thank you also Ivar ;)
Christophe
Please login with a confirmed email address before reporting spam
Hello Ivar,
Thanks for the response. I looked at your solution and it makes a lot of sense. However, I don't understand how to apply this for a study in the frequency domain. I solved for the electric field/ electric potential for 8 time points, each giving me the correct and expected potential maps (3D); my geometry is certainly not symmetry nor homogeneous. I did the following and the result is all zeros:
Created a new study (Study 2) under comp1, added a parametric sweep and deleted step 1 of study 2. I went to global parameters and added a parameter Param with expression "1" . Back in the parametric sweep, I added the parameter "Param" with range(0,0.1,1) in the value list.
Under derived values, I added a volume integration, data set: study 2/ parametric solutions 1. Selection: domain1 (one of the domains I'm interested. Expression: withsol('sol1',ec.normE)<=Param, unit: cm^3, integration method on auto and data series operation to none since I want to see the value for each of the 8 time points I solved for in study 1.
My goal is to probe for each time point, the volume in cm^3 of each selected domain that has an electric field <= to a list of values defined in the list Param.
Any suggestions would be helpful.
Thank you in advance!
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.
Suggested Content
- KNOWLEDGE BASE Controlling the Time Dependent Solver Timesteps
- FORUM Volume Integral
- FORUM Volume integral
- KNOWLEDGE BASE Computing Time and Space Integrals
- BLOG Overview of Integration Methods in Space and Time