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.

Problems for calling variables when defining another variable

Please login with a confirmed email address before reporting spam

Hello,

I am having problems with defining variable. I am building a heat transfer model and I need to define the specific heat for the material because certain material does not exist in the material library.

I try to define the specific heat in local variable, and it is a piecewise function. When temperature is over the freezing point, c_p=c_u, otherwise, there is c_p=c_f+B/T^2. And for this model, the temperature T is a built-in variable, and I defined c_u and c_f in local variables, but while I am defining the piecewise function, I am not able to call c_u and c_f directly, but I can't put in all c_u, c_f and T in Arguments because I need T to be used for defining intervals for this function. So I tried to define c_u and c_f and all other related variables as global variables, but since T is only a variable for this model, so it still did not work.

I'd appreciate any help! Thank you very much!

Best regards, Shengyue Shan


2 Replies Last Post 16 août 2018, 09:28 UTC−4

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 16 août 2018, 05:04 UTC−4

Hi,

How about using if statement instead of piecewise function?

c_p=if(T>Tf,c_u,c_f+B/T^2) in local variables. Tf is freezing point Temperature.

if T is over Tf, c_p equals c_u, otherwise, c_p is c_f+B/T^2.

Hi, How about using if statement instead of piecewise function? c_p=if(T>Tf,c_u,c_f+B/T^2) in local variables. Tf is freezing point Temperature. if T is over Tf, c_p equals c_u, otherwise, c_p is c_f+B/T^2.

Please login with a confirmed email address before reporting spam

Posted: 6 years ago 16 août 2018, 09:28 UTC−4

Hi,

How about using if statement instead of piecewise function?

c_p=if(T>Tf,c_u,c_f+B/T^2) in local variables. Tf is freezing point Temperature.

if T is over Tf, c_p equals c_u, otherwise, c_p is c_f+B/T^2.

Thank you very much! I will try it!

>Hi, > >How about using if statement instead of piecewise function? > >c_p=if(T>Tf,c_u,c_f+B/T^2) in local variables. Tf is freezing point Temperature. > >if T is over Tf, c_p equals c_u, otherwise, c_p is c_f+B/T^2. Thank you very much! I will try it!

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.