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.

Combining different variables into one

Please login with a confirmed email address before reporting spam

Hello all, i am quite new in the COMSOL world so i dont know all the possibilities that go with it and i would like to know if somebody can tell me how to combine expressions for different time steps in time dependent problems into one.
for example i want to use a smoothed step function from 0 to t1 and then from t1 to t2 a cosine function, so similar like the IF and ELSEIF operators in MATLAB. so again, form 0 to t1 i need to use one expression and from t2 to t3 another.

thank you in advance :)

1 Reply Last Post 11 lug 2013, 04:22 GMT-4
Magnus Ringh COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 11 lug 2013, 04:22 GMT-4
Hi,

You can use an "if" function directly in COMSOL when defining a variable, material property, or PDE coefficient, for example:

if(t<t1,step1(t),cos(t))

means that COMSOL will use step1(t) (a smoothed step function that you have added to the model) from the simulation start time up until t1 and then switch to cos(t) (the cosine function, which is a built-in mathematical function). t1 is typically defined as a parameter.

You can also use a Boolean expression:

step1(t)*(t<t1)+cos(t)*(t>=t1)

which is equivalent, and can be expanded to additional "time segments." You may want to call the functions using t[1/s] to make the input unitless.

Best regards,
Magnus Ringh, COMSOL

Hi, You can use an "if" function directly in COMSOL when defining a variable, material property, or PDE coefficient, for example: if(t

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.