[lammps-users] fix controller

Dear All,

I’m reaching out to you all regarding help using fix controller. I am doing a granular sim where i want to move a granule (update it’s position) based on the stresses acting on the granular ensemble.

Let me briefly describe my system. I have 4 large granules which are like 4 large walls which bound a collection of small granules. My goal is to move one of the 4 large granules so that the stress ratio (sigma_xx/sigma_yy) of the smaller granules is 1. For the frictionless system, it is effectively 1 as verified by LAMMPs and theoretical expectations. The problem is when I include friction, the stress ratio is no longer 1 which is once again theoretically expected. However, I would like to move the walls such that the stress ratio can be controlled to reach 1 (or another constant value) which I think I can achieve via fix controller.

I was thinking of doing this: Move the position of granule # 1379 (one of the wall granules in my system) such that variable stress_ratio_equal is 1. I think my input deck regarding the concerning sections should be as follows:

group granules id 1:1375
group walls id 1376:1379
group top_wall id 1376
group bottom_wall id 1377
group left_wall id 1378
group right_wall id 1379
group stationary_walls id 1376 1377 1378

fix 1 granules nve/sphere
fix 2 granules viscous 1
fix 3 stationary move linear 0 0 0

compute peratom atoms stress/atom NULL pair
compute p atoms reduce sum c_peratom[1] c_peratom[2] c_peratom[3]
compute p1 atoms reduce sum c_peratom[4] c_peratom[5] c_peratom[6]
variable press equal -(c_p[1]+c_p[2])/(20.043.8*0.2)
variable stress_ratio equal c_p[1]/c_p[2]

variable foo internal -0.0001

fix 7 all enforce2d

fix 222 right_wall move variable NULL v_zero NULL v_foo v_zero NULL

fix 1111 all controller 10 0.01 1 0.00001 0.00 v_stress_ratio 1 foo

My concern is this in the LAMMPS docs:

“For this fix to work, the control variable must actually induce a change in a running LAMMPS simulation. Typically this will only occur if there is some other command (e.g. a thermostat fix) which uses the control variable as an input parameter.”

My control variable is the velocity of the wall dictated by fix move (id 222) and process variable is v_stress_ratio. However, when I run this, the right_wall doesn’t move at all. I don’t know how else I can change the position of the wall granule apart from fix move such that I attain the desired state.

Any help will be much appreciated!

Thanks

Fix controller is a non-trivial mechanism and requires some care and experimentation to get it right. You cannot just pick some example values and expect them to work.
I suggest experimenting with a trivially simple system to gain some experience first.

Here is an example for controlling fix move. The first simulation moves a wall of non-interacting atoms with constant velocity. The variable “vel” has the velocity, the variable “move” computes the desired position, the compute “pos” the actual position, and the variable “diff” the difference between the desire (“move”) and actual (“posi”) location. As you can see from the thermo output, the wall is moved across the system by 10 units over the course of the simulation.
The second simulation sets up the same system, but now the velocity variable is recomputed by fix controller with the target of keeping the “diff” variable close to zero.

lattice sc 1.0
region box block -5 10 -5 5 -5 5
create_box 1 box
mass 1 1.0
pair_style zero 2.0
pair_coeff * *
timestep 0.1

region wall block -4.1 -3.9 -5 5 -5 5
create_atoms 1 region wall
group wall region wall

variable vel equal 0.01
variable move equal v_vel*0.1*step-4.0
compute pos wall reduce ave x
variable diff equal v_move-c_pos

fix 1 wall move variable NULL NULL NULL v_vel NULL NULL

thermo_style custom step v_move c_pos v_diff
thermo 100
dump 1 all atom 100 move.lammpstrj
run 10000 post no

Dear Dr. Axel,

Thanks so much. This is very helpful and valuable! I can now see an oscillatory response in my system when I try to use fix control to control pressure, and the oscillation is less than a percent of my desired value. I think I can try and play with the parameters to find better tuning.

I have one last question. I am unable to maintain my desired stress ratio however at a specific pressure. I do not know if this is possible but is it possible to specify two PID controls? To maintain pressure and stress ratio? Right now if my desired pressure is 500k and stress ratio is 1, by moving one of the walls with pressure as my process variable I get pressure of 495k and a stress ratio of 1.19. Do you think there is a way to simultaneously control both?

Thanks once again!