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.

Creating a looping time dependent variable

Please login with a confirmed email address before reporting spam

Hello, I'm busy creating a model in Comsol to imitate the additive manufacturing process. Right now I'm trying to create a variable (tlay) which corresponds to the live timing for a single layer. For example, when the total time to deposit one layer is twenty seconds, the variable tlay should loop from 0 to 20 seconds and then repeat itself again. My idea was to create a state variable which does this but for some reason it doesn't really work and I'm not exactly sure why. I expressed the state variable in the following way.

state: Tlay Initial: t Update expression: if(tlay>timeTotal,(tlay-timeTotal),t)

The variable tlay works as intended for the first two iterations as you can see in the graph below where tlay is illustrated against the time. However after this the variable is all over the place and I can't really figure out why is this the case. Any help how to solve this is really appreciated. Thanks!



3 Replies Last Post 29.10.2022, 12:17 GMT-4
Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 2 years ago 29.10.2022, 09:01 GMT-4

How about mod(t, 20) ?

Cheers Edgar

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
How about mod(t, 20) ? Cheers Edgar

Please login with a confirmed email address before reporting spam

Posted: 2 years ago 29.10.2022, 09:51 GMT-4

Hi Edgar,

Thank you it worked, exactly what I needed.

Hi Edgar, Thank you it worked, exactly what I needed.

Edgar J. Kaiser Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 2 years ago 29.10.2022, 12:17 GMT-4

Thanks for the feedback and good luck.

-------------------
Edgar J. Kaiser
emPhys Physical Technology
www.emphys.com
Thanks for the feedback and good luck.

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.