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.

piecewise function using mod( ) failed.

Please login with a confirmed email address before reporting spam

Hi,

I am getting trouble with the piecewise function.

I am using Comsol to simulate heat storage in soil. The soil is heated by 70degC for 4 hours everyday and the rest 20 hours no heating. I want to simulate 10 days.

So I define the function T_in as :
if(mod(t,24)<=4,70,T)
in which, t is time in [h], T and Tjin is temperature in [degC]. And T is the temperature of the surrounding soil.
And I define the study time period as:
range(0,1,240)
which is in [h].

However, the result shows that only during 0-4[h] the soil is heated. During 24-28[h], which is the second day, the soil is not heated any more.
So the function failed. Why? I am confused and hoping for your help.

Thanks!

Ren

1 Reply Last Post Sep 9, 2016, 8:00 a.m. EDT
Jeff Hiller COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 8 years ago Sep 9, 2016, 8:00 a.m. EDT
Hello Ren,
Generally speaking, turning terms on or off abruptly is not recommended. The time solver may take a single large step over the entire 24[h]-28[h] time period. Instead, consider using a smoothed step function (Definitions > Functions > Step).
Regarding making a function periodic, please read my contribution to the following thread, it explains how to do it:
www.comsol.com/community/forums/general/thread/103901
Best regards,
Jeff
Hello Ren, Generally speaking, turning terms on or off abruptly is not recommended. The time solver may take a single large step over the entire 24[h]-28[h] time period. Instead, consider using a smoothed step function (Definitions > Functions > Step). Regarding making a function periodic, please read my contribution to the following thread, it explains how to do it: https://www.comsol.com/community/forums/general/thread/103901 Best regards, Jeff

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.