Step Function

121 views
Skip to first unread message

Ary Lautaro Di Bartolo

unread,
May 27, 2021, 5:48:39 PM5/27/21
to PLUMED users
Hello community!

I am trying to implement this step function:
Screenshot from 2021-05-27 18-36-35.png

I managed to do it by doing the following:
titaij: CUSTOM ARG=ij,h VAR=x,h FUNC=step(x+1-h)*step(1-h-x)+step(x-1+h)*step(1+h-x)*(0.5-(3*(x-1))/(4*h)+((x-1)^3)/(4*(h^3)))+step(x+1+h)*step(-1+h-x)*(0.5+(3*(x+1))/(4*h)-((x+1)^3)/(4*(h^3)))

I think that I am missing the <= and >= of the first step because the step(x) function works with < and > as the manual (Plumed 2.7) shows:
Screenshot from 2021-05-27 18-42-24.png

If this is the best way of writing a step function, is there a way to choose to include or to exclude the limit value? 

Thanks in advance!

Kind regards,

Ary Lautaro Di Bartolo

Giovanni Bussi

unread,
May 27, 2021, 6:29:52 PM5/27/21
to plumed...@googlegroups.com
Hi,

I didn't check your function, but from your email it looks like you are worried by the individual points -1+h and 1-h right?

These are individual floating point numbers that will actually be never observed, unless you initialize from there.

I checked the code and if you hit that point the step function will be set to 1.0. However, the derivative will be infinite. Thus, if you do:

a(x) = f(x)*step(x) + g(x)*step(-x)

with f(x) and g(x) chosen so that their derivative in x=0 is identical (and thus it should be possible to compute the derivative of a(x) at x=0), the derivative of a(x) at x=0 will be nan I think (+infty-infty). If you really want to include the boundaries you should use a soft version of the theta function. Notice that you can add your own functions with a syntax like this:

titaij: CUSTOM ...
  ARG=ij,h VAR=x,h
  FUNC={
mystep(x+1-h)*mystep(1-h-x)+mystep(x-1+h)*mystep(1+h-x)*(0.5-(3*(x-1))/(4*h)+((x-1)^3)/(4*(h^3)))+mystep(x+1+h)*mystep(-1+h-x)*(0.5+(3*(x+1))/(4*h)-((x+1)^3)/(4*(h^3))) ;
mystep=0.5*(erf(50*x)+1)
}
...

In this manner, at the boundary the result will be the *average* between the two definitions, and derivatives will be well defined.

Giovanni




--
You received this message because you are subscribed to the Google Groups "PLUMED users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plumed-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/plumed-users/7e81d896-fce9-44ed-8a10-8fde8d1a9049n%40googlegroups.com.

Ary Lautaro Di Bartolo

unread,
May 28, 2021, 9:05:40 AM5/28/21
to PLUMED users
Dr. Giovanni,

You are right about my worries. As I don't initialize from those points I think that I will not need your soft version. I didn't knew about that sintax for FUNC, is very usefull!

Thanks for your reply.

Regards,

Ary

Reply all
Reply to author
Forward
0 new messages