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.

Defining time-dependent globals in 4.1

Andrew Prudil Nuclear Materials

Please login with a confirmed email address before reporting spam

Hi,

I'm wondering if there is a way to control the method COMSOL uses to calculate some equations? I have a variable that requires integration over a domain, and I use this variable to define some material properties. This has lead to a VERY slow computation. I believe that COMSOL may be performing the integration each time it evaluates the material properties instead of once per iteration. (IE 1000's of times more than it needs to)

Is it possible for me to define the variable in someway that it will only be calculated once per iteration, stored and then the stored value used for the calculation? I think it would significantly speed up my model if it were possible.

Thanks
-Andrew

2 Replies Last Post 2011年1月24日 GMT-5 11:31
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 2011年1月22日 GMT-5 02:30
Hi

for me this is something I believe only COMSOL can clarify (but we all are certainly interested to know) What I have her is that its evaluated once, but with V4 and all the different solver combinations it might not be always true.

When you say you integrate that means that the value is an average one, and its constant over the domain w.r.t time and not evolving locally ?

There is always this issue between distributed evolution of a varaible (per element) and the gobal averages or integrated value one mut distinguish

--
Good luck
Ivar
Hi for me this is something I believe only COMSOL can clarify (but we all are certainly interested to know) What I have her is that its evaluated once, but with V4 and all the different solver combinations it might not be always true. When you say you integrate that means that the value is an average one, and its constant over the domain w.r.t time and not evolving locally ? There is always this issue between distributed evolution of a varaible (per element) and the gobal averages or integrated value one mut distinguish -- Good luck Ivar

Andrew Prudil Nuclear Materials

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2011年1月24日 GMT-5 11:31
The value of the spatial integral is global, it does not change locally. I'm using an equation (which varies locally) of which one of the inputs is an integral over the spatial domain. It seems that if you define it this way it causes SIGNIFICANT slow down on the assembling equations steps of the solver.

After a session of trial and error, I believe that "equations" are evaluated each and EVERY time they are needed, WITHOUT storing the results. Meaning that if you have values which do not change locally, you may be computing things unnecessarily at each point.

That being said, the this seems to usually account for a small portion of the total solution time. I believe this effect is usually small, except in cases where the computation time for a single evaluation is expensive (like for example integrating over a domain with a large number of mesh points, which results in a significant number of memory calls slowing everything down). These equations only seem to be evaluated between iterations to produce the value (and the derivatives for the Jacobian). Since most of the computation time for my model is in matrix inversion, they have little effect on the speed (with the notable exception of this spatial integral).

SOLUTION
I believe I have found a solution to slow down caused by the integration which is the "Global Variables" (the ODE physics mode). This application mode does not need to be used to solve ODEs, it can be used for other things like computing a value once per iteration. This is what I did, I used the ODE mode to perform the integration and assign it a variable, then I used the resulting variable in the rest of my model. Solved the problem wonderfully.
The value of the spatial integral is global, it does not change locally. I'm using an equation (which varies locally) of which one of the inputs is an integral over the spatial domain. It seems that if you define it this way it causes SIGNIFICANT slow down on the assembling equations steps of the solver. After a session of trial and error, I believe that "equations" are evaluated each and EVERY time they are needed, WITHOUT storing the results. Meaning that if you have values which do not change locally, you may be computing things unnecessarily at each point. That being said, the this seems to usually account for a small portion of the total solution time. I believe this effect is usually small, except in cases where the computation time for a single evaluation is expensive (like for example integrating over a domain with a large number of mesh points, which results in a significant number of memory calls slowing everything down). These equations only seem to be evaluated between iterations to produce the value (and the derivatives for the Jacobian). Since most of the computation time for my model is in matrix inversion, they have little effect on the speed (with the notable exception of this spatial integral). SOLUTION I believe I have found a solution to slow down caused by the integration which is the "Global Variables" (the ODE physics mode). This application mode does not need to be used to solve ODEs, it can be used for other things like computing a value once per iteration. This is what I did, I used the ODE mode to perform the integration and assign it a variable, then I used the resulting variable in the rest of my model. Solved the problem wonderfully.

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.