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.

Difference between Variable and Parameter

Please login with a confirmed email address before reporting spam

Hi everyone,

what exactly is IN COMSOL the difference between a variable and a parameter? I know that Parameters are always global and I can choose whether I want a parameter to be global or not. But what exactly is the difference between a parameter and a variable?

Thanks for your help.

Best regards,
Mika

9 Replies Last Post 4 nov 2015, 01:48 GMT-5

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 20 mar 2015, 02:15 GMT-4
I guess that the value of a parameter is fixed, and variable is varying (sic!) its value. A model has certain independent variables with which you can define new ones, also applied only in certain domains.

Example: I simulate diffusion in two domains that have variables c1 and c2. But if I want to make a plot across the entire geometry, I define that in domain 1, C = c1 and in domain 2, C = c2. Now I can plot variable C at once.

br
Lasse
I guess that the value of a parameter is fixed, and variable is varying (sic!) its value. A model has certain independent variables with which you can define new ones, also applied only in certain domains. Example: I simulate diffusion in two domains that have variables c1 and c2. But if I want to make a plot across the entire geometry, I define that in domain 1, C = c1 and in domain 2, C = c2. Now I can plot variable C at once. br Lasse

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: 9 years ago 20 mar 2015, 03:01 GMT-4
Hi

my understanding is that a Parameter is a "static" variable, define once at the beginning/initialisation of the solver process and not changing during the solver process, while the "variable" (that often is a field over (x,y,z,t) and not a only a scalar or a function of time, or frequency ...) is or might change.
However, some variables might only be used in the post-processing and be of no specific use in the solving process, unfortunately these are also defined "high" up in the tree, and not under a (logical for me) "Definition node" at the "Results" or "Data Set" level, hence clearly defined as post-processing variables to work on the resulting Data Sets

There is one major exception to the list above: a parameter might be changed by a "parametric Sweep" and therefore might be used to define geometry (while a variable CAN NOT be used to define a geometrical shape.

Why: the logic above applies: a "Parametric Sweep" changes a Parameter and then relaunches a full solver analysis, rereading and defining all parameters and starts the solver fully from scratch down the node tree geometry, material, mesh, physics ...

I use the variables to define geometry, constants and to perform my preliminary checking analytical validations of the results. Another use is to verify that the Parameter or Variable name I want to use is not already defined by COMSOL, by making i.e. tst = eps => if I get a value then "eps" is a COMSOL defined name (this might not be sufficient, as certain variables are only defined by COMSOL ad hoc during the solving process or during the model tree analysis, once you have arrived further "down" in the tree structure

--
Good luck
Ivar
Hi my understanding is that a Parameter is a "static" variable, define once at the beginning/initialisation of the solver process and not changing during the solver process, while the "variable" (that often is a field over (x,y,z,t) and not a only a scalar or a function of time, or frequency ...) is or might change. However, some variables might only be used in the post-processing and be of no specific use in the solving process, unfortunately these are also defined "high" up in the tree, and not under a (logical for me) "Definition node" at the "Results" or "Data Set" level, hence clearly defined as post-processing variables to work on the resulting Data Sets There is one major exception to the list above: a parameter might be changed by a "parametric Sweep" and therefore might be used to define geometry (while a variable CAN NOT be used to define a geometrical shape. Why: the logic above applies: a "Parametric Sweep" changes a Parameter and then relaunches a full solver analysis, rereading and defining all parameters and starts the solver fully from scratch down the node tree geometry, material, mesh, physics ... I use the variables to define geometry, constants and to perform my preliminary checking analytical validations of the results. Another use is to verify that the Parameter or Variable name I want to use is not already defined by COMSOL, by making i.e. tst = eps => if I get a value then "eps" is a COMSOL defined name (this might not be sufficient, as certain variables are only defined by COMSOL ad hoc during the solving process or during the model tree analysis, once you have arrived further "down" in the tree structure -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 20 mar 2015, 04:30 GMT-4
Thanks for the help.

But I still think I didn't understand it right.

@ Lasse you said for diffusion you have two variable c1 and c2. Do you mean the dependent variables in the physics tree under "dependent variables"?

If so, I was talking about the variables I can define under the definitions node.

Generally I know that a parameter is a fixed value and a variable can change. But I don't understand the usage of the definitions -> variables subnode.

Thanks for your help
Thanks for the help. But I still think I didn't understand it right. @ Lasse you said for diffusion you have two variable c1 and c2. Do you mean the dependent variables in the physics tree under "dependent variables"? If so, I was talking about the variables I can define under the definitions node. Generally I know that a parameter is a fixed value and a variable can change. But I don't understand the usage of the definitions -> variables subnode. Thanks for your help

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 20 mar 2015, 06:15 GMT-4
Yes, I mean independent variables in the physics node. And the I used definitions -> variables subnode for defining the variable C. I could give also other examples.
Yes, I mean independent variables in the physics node. And the I used definitions -> variables subnode for defining the variable C. I could give also other examples.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 20 mar 2015, 06:27 GMT-4
Thanks for your help, really appreciate it.
Thanks for your help, really appreciate it.

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: 9 years ago 20 mar 2015, 06:32 GMT-4
Hi

Is it the definition/confusion of a global variable, a field variable, a scalar time dependent a scalar alone ... that is not clear ?
Because It took me some time to sort this out with COMSOL.

In my understanding:

1) under "Global - Definition - Variables" you define variables that are INDEPENDENT of the spatial dimension (x,y,z) but these variables might be dependent on time or any other (sweeping) parameter "t, Param, freq ...), or other global variables.

2) under "Component - Definition - Variables" you define variables that "live" on the/specific ENTITIES (= Domains, Boundaries, ...) these might be fields or variables with or without a spatial and /or time dependence var(x,y,z,t), or dependence on other local or global Variables or Parameters.
You can also make global variables here by i.e. integrating over the spatial domain i.e. you can define a global variable "Length = intop1(1)", as the operator intop1 is defined over a given Domain or Boundary it will give back a volume, surface or respective length depending on your space dimension of the model, and will be defined by default on all entities in your model.
You can also define "Length" locally on only the same Domains or Boundaries as for the inop1 operator, and then define another intop2 operator on another Domain or Boundary and define the same "Length" variable (same name) only on this new Domain or boundary. Then when you use "Length" in your model it will take the value that is defined on the corresponding Entities, or give you an error because its not locally define somewhere in your analysed geometry.

The use of variables and fields in COMSOL are somewhat tricky/confusing in the beginning, because of the implicit suppression of the (x,y,z,t) writing, these spatial variables are defined by your Entity selection higher up in the nodes.

It's the same for node fields where you fill in values or expressions, these are mostly expressed as "densities" to be understood as what applies directly to a dx*dy*dz volume of the Domain entity (respective surface for boundaries) and we humans mostly work in "total field/flux" mode, that is the integration over the selected entities of any density value. You can check your entries by being systematic with the units, this helps to understand which value to put where.
Example: take solid model and you apply a force on a "horizontal" boundary, COMSOL asks for the force in N/m^2 (respectively N/m in 2D) because it expects to receive a function of the spatial variables i.e "5[N]+3[N/m]*x" a variable force along the boundary. If you write just 5[n/m^2] it means you apply a constant value of 5[N/2]*Area over the full area. COMSOL has added the total force entry mode where you define a force value that has no spatial (x,y,z) dependence (but might depend on other variables "t, Param, ...") and it divides the force by the surface and distributes this average "density" value uniformly over the boundary. Check the Equation View and you will quickly understand (turn on under "File - Preferences" ...)
--
Good luck
Ivar
Hi Is it the definition/confusion of a global variable, a field variable, a scalar time dependent a scalar alone ... that is not clear ? Because It took me some time to sort this out with COMSOL. In my understanding: 1) under "Global - Definition - Variables" you define variables that are INDEPENDENT of the spatial dimension (x,y,z) but these variables might be dependent on time or any other (sweeping) parameter "t, Param, freq ...), or other global variables. 2) under "Component - Definition - Variables" you define variables that "live" on the/specific ENTITIES (= Domains, Boundaries, ...) these might be fields or variables with or without a spatial and /or time dependence var(x,y,z,t), or dependence on other local or global Variables or Parameters. You can also make global variables here by i.e. integrating over the spatial domain i.e. you can define a global variable "Length = intop1(1)", as the operator intop1 is defined over a given Domain or Boundary it will give back a volume, surface or respective length depending on your space dimension of the model, and will be defined by default on all entities in your model. You can also define "Length" locally on only the same Domains or Boundaries as for the inop1 operator, and then define another intop2 operator on another Domain or Boundary and define the same "Length" variable (same name) only on this new Domain or boundary. Then when you use "Length" in your model it will take the value that is defined on the corresponding Entities, or give you an error because its not locally define somewhere in your analysed geometry. The use of variables and fields in COMSOL are somewhat tricky/confusing in the beginning, because of the implicit suppression of the (x,y,z,t) writing, these spatial variables are defined by your Entity selection higher up in the nodes. It's the same for node fields where you fill in values or expressions, these are mostly expressed as "densities" to be understood as what applies directly to a dx*dy*dz volume of the Domain entity (respective surface for boundaries) and we humans mostly work in "total field/flux" mode, that is the integration over the selected entities of any density value. You can check your entries by being systematic with the units, this helps to understand which value to put where. Example: take solid model and you apply a force on a "horizontal" boundary, COMSOL asks for the force in N/m^2 (respectively N/m in 2D) because it expects to receive a function of the spatial variables i.e "5[N]+3[N/m]*x" a variable force along the boundary. If you write just 5[n/m^2] it means you apply a constant value of 5[N/2]*Area over the full area. COMSOL has added the total force entry mode where you define a force value that has no spatial (x,y,z) dependence (but might depend on other variables "t, Param, ...") and it divides the force by the surface and distributes this average "density" value uniformly over the boundary. Check the Equation View and you will quickly understand (turn on under "File - Preferences" ...) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 20 mar 2015, 08:00 GMT-4
Thanks for your help. I think it's a bit less confusing now. Really appreciated.
Thanks for your help. I think it's a bit less confusing now. Really appreciated.

Please login with a confirmed email address before reporting spam

Posted: 9 years ago 2 nov 2015, 22:50 GMT-5
Hi Ivar,

Your detailed explaination about the variables relieves my confusion about them a lot. Thanks! However, I am still trapped in another puzzle that whether a variable defined under model tree is derived with spatial coordinates or time during time dependent solver. For example, I define a physical property like density rho which is only a function of dependent variable w. the time derivative of rho is employed to solve another dependent variable u. So in specific time step of solving u, is the time derivative of variable rho solved by chain rule using time derivative of dependent variable w, or equal to zero since rho is a specific value given w is solved?

looking forward to your reply and appreciate it!

yuhong

Hi

Is it the definition/confusion of a global variable, a field variable, a scalar time dependent a scalar alone ... that is not clear ?
Because It took me some time to sort this out with COMSOL.

In my understanding:

1) under "Global - Definition - Variables" you define variables that are INDEPENDENT of the spatial dimension (x,y,z) but these variables might be dependent on time or any other (sweeping) parameter "t, Param, freq ...), or other global variables.

2) under "Component - Definition - Variables" you define variables that "live" on the/specific ENTITIES (= Domains, Boundaries, ...) these might be fields or variables with or without a spatial and /or time dependence var(x,y,z,t), or dependence on other local or global Variables or Parameters.
You can also make global variables here by i.e. integrating over the spatial domain i.e. you can define a global variable "Length = intop1(1)", as the operator intop1 is defined over a given Domain or Boundary it will give back a volume, surface or respective length depending on your space dimension of the model, and will be defined by default on all entities in your model.
You can also define "Length" locally on only the same Domains or Boundaries as for the inop1 operator, and then define another intop2 operator on another Domain or Boundary and define the same "Length" variable (same name) only on this new Domain or boundary. Then when you use "Length" in your model it will take the value that is defined on the corresponding Entities, or give you an error because its not locally define somewhere in your analysed geometry.

The use of variables and fields in COMSOL are somewhat tricky/confusing in the beginning, because of the implicit suppression of the (x,y,z,t) writing, these spatial variables are defined by your Entity selection higher up in the nodes.

It's the same for node fields where you fill in values or expressions, these are mostly expressed as "densities" to be understood as what applies directly to a dx*dy*dz volume of the Domain entity (respective surface for boundaries) and we humans mostly work in "total field/flux" mode, that is the integration over the selected entities of any density value. You can check your entries by being systematic with the units, this helps to understand which value to put where.
Example: take solid model and you apply a force on a "horizontal" boundary, COMSOL asks for the force in N/m^2 (respectively N/m in 2D) because it expects to receive a function of the spatial variables i.e "5[N]+3[N/m]*x" a variable force along the boundary. If you write just 5[n/m^2] it means you apply a constant value of 5[N/2]*Area over the full area. COMSOL has added the total force entry mode where you define a force value that has no spatial (x,y,z) dependence (but might depend on other variables "t, Param, ...") and it divides the force by the surface and distributes this average "density" value uniformly over the boundary. Check the Equation View and you will quickly understand (turn on under "File - Preferences" ...)
--
Good luck
Ivar


Hi Ivar, Your detailed explaination about the variables relieves my confusion about them a lot. Thanks! However, I am still trapped in another puzzle that whether a variable defined under model tree is derived with spatial coordinates or time during time dependent solver. For example, I define a physical property like density rho which is only a function of dependent variable w. the time derivative of rho is employed to solve another dependent variable u. So in specific time step of solving u, is the time derivative of variable rho solved by chain rule using time derivative of dependent variable w, or equal to zero since rho is a specific value given w is solved? looking forward to your reply and appreciate it! yuhong [QUOTE] Hi Is it the definition/confusion of a global variable, a field variable, a scalar time dependent a scalar alone ... that is not clear ? Because It took me some time to sort this out with COMSOL. In my understanding: 1) under "Global - Definition - Variables" you define variables that are INDEPENDENT of the spatial dimension (x,y,z) but these variables might be dependent on time or any other (sweeping) parameter "t, Param, freq ...), or other global variables. 2) under "Component - Definition - Variables" you define variables that "live" on the/specific ENTITIES (= Domains, Boundaries, ...) these might be fields or variables with or without a spatial and /or time dependence var(x,y,z,t), or dependence on other local or global Variables or Parameters. You can also make global variables here by i.e. integrating over the spatial domain i.e. you can define a global variable "Length = intop1(1)", as the operator intop1 is defined over a given Domain or Boundary it will give back a volume, surface or respective length depending on your space dimension of the model, and will be defined by default on all entities in your model. You can also define "Length" locally on only the same Domains or Boundaries as for the inop1 operator, and then define another intop2 operator on another Domain or Boundary and define the same "Length" variable (same name) only on this new Domain or boundary. Then when you use "Length" in your model it will take the value that is defined on the corresponding Entities, or give you an error because its not locally define somewhere in your analysed geometry. The use of variables and fields in COMSOL are somewhat tricky/confusing in the beginning, because of the implicit suppression of the (x,y,z,t) writing, these spatial variables are defined by your Entity selection higher up in the nodes. It's the same for node fields where you fill in values or expressions, these are mostly expressed as "densities" to be understood as what applies directly to a dx*dy*dz volume of the Domain entity (respective surface for boundaries) and we humans mostly work in "total field/flux" mode, that is the integration over the selected entities of any density value. You can check your entries by being systematic with the units, this helps to understand which value to put where. Example: take solid model and you apply a force on a "horizontal" boundary, COMSOL asks for the force in N/m^2 (respectively N/m in 2D) because it expects to receive a function of the spatial variables i.e "5[N]+3[N/m]*x" a variable force along the boundary. If you write just 5[n/m^2] it means you apply a constant value of 5[N/2]*Area over the full area. COMSOL has added the total force entry mode where you define a force value that has no spatial (x,y,z) dependence (but might depend on other variables "t, Param, ...") and it divides the force by the surface and distributes this average "density" value uniformly over the boundary. Check the Equation View and you will quickly understand (turn on under "File - Preferences" ...) -- Good luck Ivar [/QUOTE]

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: 9 years ago 4 nov 2015, 01:48 GMT-5
Hi

Interesting question, and I do not have the answer like that. First of all how COMSOL is really considering this "inside, or under the hood" is not known for me. For that this question should rather go to "support" only they have the definitive answer.

I would need to make a few "toy models" to check, If I manage before my demo version ends I'll come back to this one :)

Perhaps you could clarify better by adding the dependent variables: i.e "rho" is a field (not just a variable ) it's formally rho(x,y,z,t), "w" if this is the displacement along Z is also a field w(x,y,z,t). But is your "u depending on rho" linked to your structural physics ? (normally "u" is the displacement along the direction "x". Perhaps you will find your reply if you write this out.
Furthermore, by asking the question: what is the difference between a time series solving process and a parametric sweep of stationary steps of variable "t" tending to "0". You might get further to a reply.

--
Good luck
Ivar
Hi Interesting question, and I do not have the answer like that. First of all how COMSOL is really considering this "inside, or under the hood" is not known for me. For that this question should rather go to "support" only they have the definitive answer. I would need to make a few "toy models" to check, If I manage before my demo version ends I'll come back to this one :) Perhaps you could clarify better by adding the dependent variables: i.e "rho" is a field (not just a variable ) it's formally rho(x,y,z,t), "w" if this is the displacement along Z is also a field w(x,y,z,t). But is your "u depending on rho" linked to your structural physics ? (normally "u" is the displacement along the direction "x". Perhaps you will find your reply if you write this out. Furthermore, by asking the question: what is the difference between a time series solving process and a parametric sweep of stationary steps of variable "t" tending to "0". You might get further to a reply. -- 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.