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.

Global and Local variables in Parametric Geometries

Please login with a confirmed email address before reporting spam

Hello All,

Is there a way to use a local variable, which is not a part of any parametric sweep, as a parameter for a parametric geometry object?

Another way to ask the question is; is there a way to use a variable, which is dependent on the subdomain variables, as a parameter for a parametric geometry object?

Thanks in advance,
Onur

3 Replies Last Post 22 avr. 2011, 08:42 UTC−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 21 avr. 2011, 09:56 UTC−4
Hi

it depends, I suppose on your model.

I imagine it could work, (must be checked) that a geometrical block, with a side of (0.1[m]+MySide*Param), where Param is a Parameter (without units), running along a range(0,0.1,1) defined in a Parametric sweep, and MySide is a global variable that is NOT depending on x,y,z I believe it should work (provided MySide can be evaluated by COMSOL at solver start).

But normally the "dg" physics is there for geometrical changes inside a solver process

--
Good luck
Ivar
Hi it depends, I suppose on your model. I imagine it could work, (must be checked) that a geometrical block, with a side of (0.1[m]+MySide*Param), where Param is a Parameter (without units), running along a range(0,0.1,1) defined in a Parametric sweep, and MySide is a global variable that is NOT depending on x,y,z I believe it should work (provided MySide can be evaluated by COMSOL at solver start). But normally the "dg" physics is there for geometrical changes inside a solver process -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 22 avr. 2011, 05:18 UTC−4
Hello Ivar,

I believe we have tried to find the solution using the same logic. I have realized that in some physical models the geometry is not updated unless one of the the parameters (in your case "param") is defined in the parametric sweep range. Therefore you need to do something like my_significant_parameter*parametric_sweep_variable, so that you can trigger the geometry update. However, if my_significant_parameter is a local variable, the parametric geometry will not respond to the result of the my_significant_parameter*parametric_sweep_variable. I have found out that, in order to use a local variable in the parametric geometry, you should first declare it in the global definitions and give it an initial value so that Comsol can complete building the geometry. After this, the global declaration is over writing the local variable (this is my guess) and the geometry only follows the parametric_sweep_variable.

Yes, as a second step, I have tried the deformed geometry, however I couldn't stop Comsol complaining about circular variable dependency detection. Do you think it is a probable case with using a local variable which is defined under Model>definitions>variables to cause a circular variable dependency in DG or do you think I should look for ways to modify my model?

Regards,
/Onur
Hello Ivar, I believe we have tried to find the solution using the same logic. I have realized that in some physical models the geometry is not updated unless one of the the parameters (in your case "param") is defined in the parametric sweep range. Therefore you need to do something like my_significant_parameter*parametric_sweep_variable, so that you can trigger the geometry update. However, if my_significant_parameter is a local variable, the parametric geometry will not respond to the result of the my_significant_parameter*parametric_sweep_variable. I have found out that, in order to use a local variable in the parametric geometry, you should first declare it in the global definitions and give it an initial value so that Comsol can complete building the geometry. After this, the global declaration is over writing the local variable (this is my guess) and the geometry only follows the parametric_sweep_variable. Yes, as a second step, I have tried the deformed geometry, however I couldn't stop Comsol complaining about circular variable dependency detection. Do you think it is a probable case with using a local variable which is defined under Model>definitions>variables to cause a circular variable dependency in DG or do you think I should look for ways to modify my model? Regards, /Onur

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 22 avr. 2011, 08:42 UTC−4
Hi

that is a know feature ! (it's written somewhere in the doc):

"External, or full" Parametric Sweep loops around the geometry and the mesh, and restarts all solvers from default initial conditions.

While "internal solver sweep" does NOT loop around the geometry, and the solvers, by default, restarts with previous step for the initial conditions. This is on purpose and I find rather logic (but often overlooked ;)

For changing the geometry I believe DG is the way (so long you do not change the topology, but that also holds for the "external/full" Parametric Sweep. The thing is how to cut the loop, not always easy.

Indeed variables are in fact mostly fields depending (implicit) on domain or BC index, spatial coordinates x,y,z, r ... time "t" or even other dependent or not variables T, p ... This means in fact that most variables are not globally constant and change their mining depending on how they are used, this is indeed easily confusing. And COMSOL itself cannot use such a variable to define the geometry before starting a solver, if the variable depends on the solver results

--
Good luck
Ivar
Hi that is a know feature ! (it's written somewhere in the doc): "External, or full" Parametric Sweep loops around the geometry and the mesh, and restarts all solvers from default initial conditions. While "internal solver sweep" does NOT loop around the geometry, and the solvers, by default, restarts with previous step for the initial conditions. This is on purpose and I find rather logic (but often overlooked ;) For changing the geometry I believe DG is the way (so long you do not change the topology, but that also holds for the "external/full" Parametric Sweep. The thing is how to cut the loop, not always easy. Indeed variables are in fact mostly fields depending (implicit) on domain or BC index, spatial coordinates x,y,z, r ... time "t" or even other dependent or not variables T, p ... This means in fact that most variables are not globally constant and change their mining depending on how they are used, this is indeed easily confusing. And COMSOL itself cannot use such a variable to define the geometry before starting a solver, if the variable depends on the solver results -- Good luck Ivar

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.