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.

CREATING A PERIODIC WAVE WITH flc2hs(x,scale) AND mod(a,b)

Please login with a confirmed email address before reporting spam

Hello,

I'm trying to build a periodical wave. I want it to be linear, with its first semiperiod as an ascendent linear function, and the second semiperiod as a descendent linear function. Just like in the attached image.

I am using the function flc2hs(x,scale) to define the steps that will build the wave. I have defined two diferent parts:

Increasing part:
flc2hs(t+1e-2, 1e-2) - flc2hs(t, 1e-2)

decreasing part:
flc2hs(t, 1e-2) - flc2hs(t,2e-2)

What i have in mind is to repeat this two steps along t with the mod(a,b) function, and to multiply them with the linear function that will define the wave form(it'll be something linearly time depending).

Could anyone help me doing this two last steps? I've been searching for the mod(a,b) function on the program guide, but there is no explanation about it.

thank you very much


5 Replies Last Post Mar 23, 2011, 2:30 a.m. EDT
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 18, 2010, 5:08 p.m. EDT
Hi

but you will not really get a "linear function" with the heaviside smooth step functions, however it will be derivable.

When I have a problem with a mathematical function in COMSOL, my way around is to plot it as a "function" see below

Good luck
Ivar
Hi but you will not really get a "linear function" with the heaviside smooth step functions, however it will be derivable. When I have a problem with a mathematical function in COMSOL, my way around is to plot it as a "function" see below Good luck Ivar


Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 3, 2010, 11:34 a.m. EDT
Hi Ivar,

I've been working on creating this wave, and i ve decided to define it this way:

(t*H0)*(t<0.01)+((0.02-t)*H0)*(t>0.01)

I've realised that what i was trying to do at the beginning was a bit complex. The result is on the attached image. I only need one period of this wave. If i need the wave to be periodic in time, i'll have problems, because this description is not ok, the resultant wave is permanently decreasing from t=0.01. I'll investigate more.

Thanks for the help!

Tomàs
Hi Ivar, I've been working on creating this wave, and i ve decided to define it this way: (t*H0)*(t0.01) I've realised that what i was trying to do at the beginning was a bit complex. The result is on the attached image. I only need one period of this wave. If i need the wave to be periodic in time, i'll have problems, because this description is not ok, the resultant wave is permanently decreasing from t=0.01. I'll investigate more. Thanks for the help! Tomàs


Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Apr 4, 2010, 2:48 a.m. EDT
Hi

indeed it would most probabay work, if not try to step in a concetrated way at your slope changes. You still have the modulo to make it periodic.

If you still have convergence problems, you could fit a smoother sin function just around your slope change. I mostly use Maple to help me formulate my math for such piecewise continuous functions

Good luck
Ivar
Hi indeed it would most probabay work, if not try to step in a concetrated way at your slope changes. You still have the modulo to make it periodic. If you still have convergence problems, you could fit a smoother sin function just around your slope change. I mostly use Maple to help me formulate my math for such piecewise continuous functions Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 22, 2011, 6:20 p.m. EDT
I too am trying to create a periodic wave with flc2hs in 3.5a.

I applied the following: flc2hs(mod(t,365.2)-120),1)-flc2hs(mod(t,365.2)-150,1))

My t is measured in days so it should be "on" from day 120 to 150, and "off" otherwise, for each 365.2 day cycles. But it only happens the one time.

Is there something I am doing incorrectly?

Thanks!

Mattie
I too am trying to create a periodic wave with flc2hs in 3.5a. I applied the following: flc2hs(mod(t,365.2)-120),1)-flc2hs(mod(t,365.2)-150,1)) My t is measured in days so it should be "on" from day 120 to 150, and "off" otherwise, for each 365.2 day cycles. But it only happens the one time. Is there something I am doing incorrectly? Thanks! Mattie

Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Mar 23, 2011, 2:30 a.m. EDT
Hi

normally t is expressed by default in seconds, so I would use a "t[1/day]" (this works in v4, probably also in 3.5) in your call

Define a function with your expression, that helps to test it, as you can plot it out

and you should check your balance of "()"

--
Good luck
Ivar
Hi normally t is expressed by default in seconds, so I would use a "t[1/day]" (this works in v4, probably also in 3.5) in your call Define a function with your expression, that helps to test it, as you can plot it out and you should check your balance of "()" -- Good luck Ivar

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.