I want to know how one can change the sign of variable each time randomly

Dear Lammps users,
I am trying to apply fix addforce, with different sign randomly at the time. Here, time at which pulse is being applied distributed with poisson function. Kindly help me out,

Thanks and regard
Ramanand Singh Yadav

In variable expressions, you can use “logical expressions”, e.g. (v_x > 0.5) which will result in either a value of 1 (true) or 0 (false). Thus the expressions “-1.0+(v_x>0.5)*2.0” will be either -1.0 or 1.0 depending on whether the value of the variable x is greater or smaller than 0.5.

can you help me how this variable with different sign used randomly at different time. Because this way I get randomly one value which is being used through all simulation.

No, because I don’t know what you are doing and I cannot read your mind.
Most likely you are doing something wrong and are using the wrong kind of variable expansion.

Sorry for the incomplete question here I am rephrasing the question.
I am attempting to utilize the fix addforce command in LAMMPS to apply a pulse of constant magnitude with random signs at times distributed according to a Poisson distribution. However, I’m encountering two main challenges:

  1. Generating a variable with a constant magnitude and random sign, and incorporating it into the addforce command.
  2. Implementing the addition of force at times that follow a Poisson distribution.

Rephrasing doesn’t help. It is not the question that is the problem, it is the lack of detail and demonstration of what you have already tried and what failed how that is missing. This is not resolved by just asking the same thing differently.

There is an even bigger challenge: you don’t seem to grasp how getting help in an online forum works. Just announcing that you have “challenges” is not sufficient. Without demonstrating what you have already done, i.e. providing a small demonstration example (best constructed off one of the (simple) LAMMPS examples) and explaining how you can tell that what you did had not the expected effect, you are giving off the impression that you expect others to do what is essentially your task and without making it as easy as possible to assist you; on the contrary.

Second, you need to do some research on your own. If you look through the available text book material and online resources, you should have found that: a) LAMMPS does not intrinsically generate a Poisson distribution and b) there are ways to create all kinds of random number distributions from a uniform distribution (which LAMMPS does provide). Now, if you have problems with the “mechanical” implementation of this, you may well ask here, but - as before - proper forum etiquette expects you do give it a first try and check it and show it to us and then explain how what you implemented does not fit your needs.

For more explanations on how you can make the best out of a forum in which people that are responding are volunteering their time you should have a good read through the forum guidelines and suggestions.