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.

Defining a Piecewise function of two variables

Please login with a confirmed email address before reporting spam

Hello,

I am trying to model NMR diffusion in COMSOL 4.3 and need to define a function beta at three different time intervals as follows:

beta = gyro*(g*x) (0 < t < 0.016s)
beta = 0 (0.016s < t < 0.040s)
beta = gyro*(-g*x) (0.040s < t < 0.056s)

x is the displacement in (m) and gyro and g are constants

I have defined three analytic functions for beta as functions of x. I am not sure how to use this to define a piecewise function for the three different time intervals. I am new to COMSOL and would be really grateful for any help with this.

Thank you,

Caroline

2 Replies Last Post 3 dic 2012, 16:17 GMT-5
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 3 dic 2012, 14:29 GMT-5
Hi

what abut combining 2 step functions in an analytical function, with a step from +1 to 0 at offset t=0.016, and one from 0 to -1 at t=0.04, and then the analytical funxtion ana1 = gyro*(g*x)*(stp1(t)+stp2(t))

or something like that, its nce with the analytical functions, as you might define units and plot the result to check it out carefully, before solving blindly ;)

--
Good luck
Ivar
Hi what abut combining 2 step functions in an analytical function, with a step from +1 to 0 at offset t=0.016, and one from 0 to -1 at t=0.04, and then the analytical funxtion ana1 = gyro*(g*x)*(stp1(t)+stp2(t)) or something like that, its nce with the analytical functions, as you might define units and plot the result to check it out carefully, before solving blindly ;) -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 3 dic 2012, 16:17 GMT-5
Thanks, that worked ! :)
Thanks, that worked ! :)

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.