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.
Model couplings as inputs to functions
Posted 16.01.2013, 00:19 GMT-5 Version 4.3 7 Replies
Please login with a confirmed email address before reporting spam
I am trying to put in a temperature average over a boundary into an analytical function. This isn't working and is producing an error. I was wondering whether anyone would have any suggestions on how to input an average temperature into a function?
Regards,
Josh
Please login with a confirmed email address before reporting spam
you need to define a coupling average function over the boundary, then make a "Model - Definitions - Variable"
Tave = aveop1(T)
and call Tave in your "Model - Definition - Function".
But if you haven't solved your model once, or at least loaded the initial conditions, the Tave does not yet exist, so you cannot plot your function before Tave has got some value
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
Thank you very much for your reply. I have tried setting the aveop(T) as a variable but I still couldn't get it to run.
Perhaps it was because I hadn't loaded the initial conditions. I am not familiar with loading the initial conditions before solving; how does one go about doing that? Is it a function in the solver?
Thanks Ivar,
Josh
Please login with a confirmed email address before reporting spam
In the last version it is back again (from 3.5 time) as a separate command when right clicking a Study node
in the previous versions (also possible in the latest) select the "Dependent Variables" node in the solver sequence and click "Compute to Selected" this fills in all matrices and loads the initial variables, and make the default plots if not already there, handy also to set the plot while solving to the desired plot entry
--
Good luck
Ivar
Please login with a confirmed email address before reporting spam
The analytic functions use "formal arguments" (default "x"), and you can use basically any suitable argument names. Then, when calling the function in the model you can use any valid (scalar) variable or value as an argument when calling the analytic function. For example, define an analytic function "myfcn" as:
Expression: x^2
Argument: x
which defines the analytic function myfcn(x) = x^2.
Then, if you have also created an Average operator "myavg" you can use, for example,
myfcn(myavg(T))
somewhere in a heat transfer model to use the average of the temperature T as argument to the analytic function (you may want to make sure that the units defined for the function and its argument are compatible with its use in the model).
Best regards,
Magnus Ringh, COMSOL
Please login with a confirmed email address before reporting spam
I am finally back at work so am able to try out your suggestions (I am on the other side of the world).
I have tried both inputting the newly defined variable into the function and already having the variable in the function and neither of them work. If I try to have the variable in the function already then I get the error "undefined variable T_ave in function". If I try to input the variable I get an error saying "undefined value found in the stiffness matrix. There are 3 equations giving NaN/inf in the matrix rows....". All of these errors occur when I load the initial conditions too.
Do you have any ideas? Are there any other ways of inputting the average into a function?
Cheers,
Josh
Please login with a confirmed email address before reporting spam
Thank you for clarifying this for me. It turns out that I have already done this a couple of times before. The problem this time was that I was inputting an average value that was too high for the function to work with.
Thank you very much for your clarification and your help.
Regards,
Josh
Please login with a confirmed email address before reporting spam
where do you define the function ? in the Global function or the model Definition Function ? I would rather choose the second one
--
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.
Suggested Content
- BLOG How to Model Moisture Flow in COMSOL Multiphysics®
- FORUM "Expression" under "Datasets -> a certain dataset" functions or not?
- FORUM Extrusion/projection operation for non-local couplings
- BLOG New Piezoelectric Modeling Interface in COMSOL 5.0
-
KNOWLEDGE BASE
How can I see the equations COMSOL is defining?
How do I implement a user-defined Multiphysics coupling?