when to use parameters, variables, and functions

Topics: no topics

Thread index  |  Previous thread  |  Next thread  |  Start a new discussion

RSS FeedRSS feed   |   Email notificationsTurn on email notifications   |   3 Replies   Last post: October 18, 2012 3:10pm UTC
Darin Bellisario

Darin Bellisario

October 17, 2012 5:09pm UTC

when to use parameters, variables, and functions

Hi All,

Considering global values for now.

It seems clear to me when to use parameters - any value that is independent of the independent or dependent variables. But when is it appropriate to use global variables, and global functions?

Thank you for any insight,

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

October 17, 2012 6:27pm UTC in response to Darin Bellisario

Re: when to use parameters, variables, and functions

Hi

this is an interesting issue, as it took me quite some time to get this (more or less) straight. In fact what I find confusing in COMSOL is that most if not all "variables" are in fact fields over (x,y,z,t ...). Even if often we write in a scalar it is "just" means to say that the field is a scalar and is invariant over the spatial and/or time domain.

Global variables was mainly variables that could be changed independetly of the model, or are integrated over the geometry (spatial dimension) of the model"n" .

Model variables are depenent on the specific model, hence are defined over part or all entities (domains, boundaries, edges, points ...

Parameters are constants that is evaluated once at solver run, but these might be overwritten by COMSOL later, this is handy to define some variables, such as "t" for time when you have specific equations dependeing on "t" but you mix time dependent and spatial solvers, and during stationary solvers "t" is not defined by default, only when you run a time dependent solver does COSMOl add in"t", except if you fix it once in the Parameters

So define in the Global section something that is indepedent of your model (geometry), but that you expect to change (as Variables); or what is to remain constant, as Parameter, and define all other variables locally.

Additionally Parameters can drive geometry dimensions and be referred to in the parametric sweep (Variables cannot)

Same principle for functions etc

As I'm not from COMSOL I might well have missed soemthing important, so whoever has other ideas, pls update, so I learn something new too :)

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Darin Bellisario

Darin Bellisario

October 18, 2012 2:54pm UTC in response to Ivar Kjelberg

Re: when to use parameters, variables, and functions

Thanks Ivar, that is hugely helpful, and cleans up my model quite a bit. Now I'm using model variables for simple relations, and only need PDEs/ODEs for differential equations, its a much neater way of organizing things.

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse

Ivar Kjelberg

Ivar Kjelberg

October 18, 2012 3:10pm UTC in response to Darin Bellisario

Re: when to use parameters, variables, and functions

Hi

and I have just noticed that in V4.3a, the doc and help has been greatly updated, it given even more info, it's worth to reread the doc at each release ;)

OK I agree COMSOL could flag regions with updates somewhat, as everything is electronic now, but still the updates are extensive for each new version I see

--
Good luck
Ivar

Reply  |  Reply with Quote  |  Send private message  |  Report Abuse


Rules and guidelines