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 coupling - how to use in function

Please login with a confirmed email address before reporting spam

I need to create function of force
Fx(x0,y0) which evaluates to

Fx(x0,y0)=\int_domain c*((x-x0)^2+(y-y0) ^2 ...

where "c" is concentration of specie in diffusion model.

1. I created integral coupling named "integral" (which will evaluate integral - I hope)

2. Then I declared in definitions analytical function Fx of parameters x0,y0
evaluating to

integral(c*((x-x0)^2+(y-y0) ^2)

which calculate integral of dependent field "c".

3. Then in model I used Fx(x,y).

But when I tried to solve model, I obtained error

Undefined variable
- Variable: c
- Function name: Fx

I tried to use mod1.chds.c instead c but it does not solve my problem.

Is there any way to calculate this integral and use it in function?

Jakub

7 Replies Last Post 07.10.2010, 04:09 GMT-4
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 06.10.2010, 14:44 GMT-4
Hi

from what I understand your issue is that the "c" variable seems not to be defined where you evaluate the integral.

First you must check where the c is defined (domain/boundary ...), then where the integral is performed, global or on a domain or a boundary ... and do both match ? (if not you have it wrong)

To find all the internal variables of COMSOL it's slightly cumbersome, you must read through quite some unsorted lists (turn on the preferences equtions to see them in the sub-nodes).

Furthermore, as you tried, you must use the full name, if called from outside of its local physics or node level

--
Good luck
Ivar
Hi from what I understand your issue is that the "c" variable seems not to be defined where you evaluate the integral. First you must check where the c is defined (domain/boundary ...), then where the integral is performed, global or on a domain or a boundary ... and do both match ? (if not you have it wrong) To find all the internal variables of COMSOL it's slightly cumbersome, you must read through quite some unsorted lists (turn on the preferences equtions to see them in the sub-nodes). Furthermore, as you tried, you must use the full name, if called from outside of its local physics or node level -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 06.10.2010, 21:26 GMT-4
The integration variables are scalar variables in COMSOL Multiphysics. That's why you get the error message.

Maybe you can extrude the concentration [c] into a higher geomtry dimension, then projection integrated into the present subdomain by your function.
The integration variables are scalar variables in COMSOL Multiphysics. That's why you get the error message. Maybe you can extrude the concentration [c] into a higher geomtry dimension, then projection integrated into the present subdomain by your function.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.10.2010, 00:09 GMT-4
c variable is dependent variable of my model (at picture it is mod2) so I assume it is defined on domain and boundary.

integration1 (Integral) is defined on domain (second picture).

function Fx is used in domain weak contribution (third picture).

So I think all should be OK, but it does not work.

I also attached model if it can help. I am using Solver3 (stationary). Model is developed so there is a lot of unused variables etc.


Jakub
c variable is dependent variable of my model (at picture it is mod2) so I assume it is defined on domain and boundary. integration1 (Integral) is defined on domain (second picture). function Fx is used in domain weak contribution (third picture). So I think all should be OK, but it does not work. I also attached model if it can help. I am using Solver3 (stationary). Model is developed so there is a lot of unused variables etc. Jakub


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.10.2010, 00:15 GMT-4

The integration variables are scalar variables in COMSOL Multiphysics. That's why you get the error message.


I do not understand how it relate with error, I am trying to integrate scalar values.


Maybe you can extrude the concentration [c] into a higher geomtry dimension, then projection integrated into the present subdomain by your function.

Do You mean extrude to 3D and then integrate in one dimension using projection coupling back to 2D? But I need every point of domain to be my x0,y0 reference point and I do not know how to distinguish x,y and x0,y0 in projection integral.

Can you give me an example?

[QUOTE] The integration variables are scalar variables in COMSOL Multiphysics. That's why you get the error message. [/QUOTE] I do not understand how it relate with error, I am trying to integrate scalar values. [QUOTE] Maybe you can extrude the concentration [c] into a higher geomtry dimension, then projection integrated into the present subdomain by your function. [/QUOTE] Do You mean extrude to 3D and then integrate in one dimension using projection coupling back to 2D? But I need every point of domain to be my x0,y0 reference point and I do not know how to distinguish x,y and x0,y0 in projection integral. Can you give me an example?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.10.2010, 00:25 GMT-4

The integration variables are scalar variables in COMSOL Multiphysics. That's why you get the error message.

I do not understand how it relate with error, I am trying to integrate scalar values.


If you mean that integral is scalar and force should be vector, I divided force to x and y component so Fx is x component and it is scalar
[QUOTE] The integration variables are scalar variables in COMSOL Multiphysics. That's why you get the error message. I do not understand how it relate with error, I am trying to integrate scalar values. [/QUOTE] If you mean that integral is scalar and force should be vector, I divided force to x and y component so Fx is x component and it is scalar

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.10.2010, 04:00 GMT-4
Hi,

The expression that you have defined is perfectly valid in the physics settings of a model, so you should use it directly in an edit field for a force component, for example.

Analytic functions do not recognize any other arguments than the ones that you define in their Settings windows and any global parameters that you have defined. That is why you get errors when using dependent variables and integration operators, for example, in an analytic function definition.

Magnus Ringh, COMSOL
Hi, The expression that you have defined is perfectly valid in the physics settings of a model, so you should use it directly in an edit field for a force component, for example. Analytic functions do not recognize any other arguments than the ones that you define in their Settings windows and any global parameters that you have defined. That is why you get errors when using dependent variables and integration operators, for example, in an analytic function definition. Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 07.10.2010, 04:09 GMT-4

The expression that you have defined is perfectly valid in the physics settings of a model, so you should use it directly in an edit field for a force component, for example.


But x0 and y0 in function are coordinates of point at which I want to calculate force. If I specify expression
integral(c*((x-x0)^2+(y-y0) ^2)
in the weak expression instead using function how to specify that x0,y0 are at point where COMSOL should evaluate expression (I suppose it is sequentially each mesh point) and x,y in expression are varying in integral evaluation through whole domain.
[QUOTE] The expression that you have defined is perfectly valid in the physics settings of a model, so you should use it directly in an edit field for a force component, for example. [/QUOTE] But x0 and y0 in function are coordinates of point at which I want to calculate force. If I specify expression integral(c*((x-x0)^2+(y-y0) ^2) in the weak expression instead using function how to specify that x0,y0 are at point where COMSOL should evaluate expression (I suppose it is sequentially each mesh point) and x,y in expression are varying in integral evaluation through whole domain.

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.