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.

Time-dependant variables - best practice

Please login with a confirmed email address before reporting spam

Hi all,

I am very confused as to the best way to specify a time-dependant variable and then use it in a model.

For example: I want a rotation angle to vary from 0-360 degrees in 1 second so i have an object spinning at 1 rpm.

I open a time-dependant problem - specify a global variable (phi = 360*t) - then in the "rotation angle" field in my model I use "phi". I get the error "Unknown Model Parameter".

This happens whenever I try to have anything varying with time in my models. The thing that confuses me is that I followed another model from the library (MEMs fluid-structure interaction) that has a time dependant flow rate which I specified in the same way - a time-dependant variable which is then used to specify the value of flow rate in the model. This worked without issue.

Can anyone advise as to how you're supposed to do this in a general way so that I can apply it to any model? (The spinning object is just opne of many cases in which I would like to time-vary a value in the model).

Kind regards,
Dom.

4 Replies Last Post 30 nov 2011, 14:27 GMT-5
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 30 nov 2011, 11:12 GMT-5
Hi

I'm not sure this is the reply, but it could be thatphi is already used by COMSOL, have you tried a more "personal" name such as "phi_" or "phi0" ?

COMSOl does allow to change internal variables, and does not always flag it as an error, as sometimes it's "on purpouse" that a user redefines them, but you better know what you are doing then ...

--
Good luck
Ivar
Hi I'm not sure this is the reply, but it could be thatphi is already used by COMSOL, have you tried a more "personal" name such as "phi_" or "phi0" ? COMSOl does allow to change internal variables, and does not always flag it as an error, as sometimes it's "on purpouse" that a user redefines them, but you better know what you are doing then ... -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30 nov 2011, 13:35 GMT-5
Hi Ivar,

Thanks for the response, but I have this problem whatever I use as a variable name.

It seems to me that this isn't a complecated request, changing something's position with time, or changing the value of a BC with time or something like that.

What seems odd is that when I type the expression "360*t" (for example) into the variables tab it recognises "t" as the time variable fine, and asigns it the correct unit (seconds). So everything seems fine there, but when you try to enter it in a field for say, voltage, or whatever you get this "unknown model parameter" error.

[EDIT - Actually, it works fine for a voltage, but not anything in a geometry node. Perhaps COMSOL won't allow time-varying geometries as such, having to do with remeshing each time-point or something??]

Confusing. Anyone got any ideas?

Dom.
Hi Ivar, Thanks for the response, but I have this problem whatever I use as a variable name. It seems to me that this isn't a complecated request, changing something's position with time, or changing the value of a BC with time or something like that. What seems odd is that when I type the expression "360*t" (for example) into the variables tab it recognises "t" as the time variable fine, and asigns it the correct unit (seconds). So everything seems fine there, but when you try to enter it in a field for say, voltage, or whatever you get this "unknown model parameter" error. [EDIT - Actually, it works fine for a voltage, but not anything in a geometry node. Perhaps COMSOL won't allow time-varying geometries as such, having to do with remeshing each time-point or something??] Confusing. Anyone got any ideas? Dom.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 30 nov 2011, 13:40 GMT-5
Ivar,

I seem to remember one of your responses mentioning that time (t) is not available to COMSOL as a variable until you call the time-dependant solver. Could this be related? If so, how would you get round that, given that I can't start my solver without resolving the unknown model parameter error?

I'm getting pretty good at getting round roadblocks with Comsol these days, but this one has stumped me.
Ivar, I seem to remember one of your responses mentioning that time (t) is not available to COMSOL as a variable until you call the time-dependant solver. Could this be related? If so, how would you get round that, given that I can't start my solver without resolving the unknown model parameter error? I'm getting pretty good at getting round roadblocks with Comsol these days, but this one has stumped me.

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 30 nov 2011, 14:27 GMT-5
Hi

I was just following your idea there, while readingyour question. Indeed, if you add a stationary solver and ten a time dependent one, there is no "t" defined in the first stationary solver run, so for that add a Definition Parameter t=0[s] and off you go

Pls do not forget that time dependent BC work best when the functions are smooth (or derivable, do you say that in English, it's probably a poor French half translation). COMSOl estimtes the derivatives of the solution for next through in the solving process, so if you use boolean conditions or abs(), max() or other non-continuous operators, the solver might have problems and will not converge, or only with difficulties, hence you loose time.

Another point, if you use Parameters for solver "continuation" then these should be without units, and in the BC you just multiply them by a unit dimension

--
Good luck
Ivar
Hi I was just following your idea there, while readingyour question. Indeed, if you add a stationary solver and ten a time dependent one, there is no "t" defined in the first stationary solver run, so for that add a Definition Parameter t=0[s] and off you go Pls do not forget that time dependent BC work best when the functions are smooth (or derivable, do you say that in English, it's probably a poor French half translation). COMSOl estimtes the derivatives of the solution for next through in the solving process, so if you use boolean conditions or abs(), max() or other non-continuous operators, the solver might have problems and will not converge, or only with difficulties, hence you loose time. Another point, if you use Parameters for solver "continuation" then these should be without units, and in the BC you just multiply them by a unit dimension -- 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.