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.

Referencing of variables and material properties in Version 5.2

Please login with a confirmed email address before reporting spam

Hello fellow Comsol-ians and Comsol-masters,

I am working with Comsol 5.2 for my Bachelor’s thesis and I am trying to model hydrogen flow through porous materials. I like it but I have a little problem:
so far, I have been unable to use dependent variables or defined material properties in my analytic functions, because Comsol says it cannot evaluate the variable. I have tried introducing the variable with some random value in the global Parameters, I have tried different syntax (along the lines of <name>.<variable_name> and the usual comp1.mat4.def.rho etc), but it refuses to work. Also, Comsol says it can’t evaluate comp1.T, which is really strange because it should know T! I mean, that’s the temperature! :-/
I wanted to attach my model, but I am getting a file extension error (it is only a small 192 kB .mph file) when I try to upload it here. But maybe you know the answer anyway? I would be very grateful for your help :-)

Greetings,
Sophie

3 Replies Last Post 1 dic 2016, 08:10 GMT-5
Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 29 nov 2016, 07:57 GMT-5
Hi,

You can call an analytic function with a material property (such as mat1.def.rho) or a dependent variable (such as T) when you use it in your model to represent some part of the model's properties. In the definition of the analytic function, however, you use symbolic arguments to define the function's expression ("x", for example, as in the default settings). From the documentation: "Analytic functions have the ability to bind arguments during function calls. In other words, they do not require the actual argument names in an expression when writing the function. For example, you can define a function f(x) = x^2 with the input argument x and the expression x^2 and then call it as f(T), where T is the temperature in a heat transfer model."

Best regards,
Magnus Ringh, COMSOL
Hi, You can call an analytic function with a material property (such as mat1.def.rho) or a dependent variable (such as T) when you use it in your model to represent some part of the model's properties. In the definition of the analytic function, however, you use symbolic arguments to define the function's expression ("x", for example, as in the default settings). From the documentation: "Analytic functions have the ability to bind arguments during function calls. In other words, they do not require the actual argument names in an expression when writing the function. For example, you can define a function f(x) = x^2 with the input argument x and the expression x^2 and then call it as f(T), where T is the temperature in a heat transfer model." Best regards, Magnus Ringh, COMSOL

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 1 dic 2016, 07:44 GMT-5
Thank you very much, Magnus, for your fast help! I hadn't even thought that this could be the problem, but now it works!! :-)

Is it possible that you can't call upon an analytic function within another analytic function (both on the local level)? I was doing that, too, and am thinking now that it might have been another reason why it wasn't working.

Your help was (and is) much appreciated! :-)

Good day!
Sophie
Thank you very much, Magnus, for your fast help! I hadn't even thought that this could be the problem, but now it works!! :-) Is it possible that you can't call upon an analytic function within another analytic function (both on the local level)? I was doing that, too, and am thinking now that it might have been another reason why it wasn't working. Your help was (and is) much appreciated! :-) Good day! Sophie

Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago 1 dic 2016, 08:10 GMT-5
Hi again,

Yes, you can call one analytic function from another, keeping in mind to call it using a symbolic argument that is defined in the calling function. Also, you cannot have two analytic functions calling each other; doing so introduces a circular function dependency. Other than that, an analytic function call from another analytic function is supported and shouldn't be a problem.

Best regards,
Magnus Ringh, COMSOL
Hi again, Yes, you can call one analytic function from another, keeping in mind to call it using a symbolic argument that is defined in the calling function. Also, you cannot have two analytic functions calling each other; doing so introduces a circular function dependency. Other than that, an analytic function call from another analytic function is supported and shouldn't be a problem. Best regards, Magnus Ringh, COMSOL

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.