# yade-users team mailing list archive

## Re: [Question #698572]: Is it possible to constrain the motion of a body along a circle

 Thread Previous • Date Previous • Date Next • Thread Next

```Question #698572 on Yade changed:

Status: Needs information => Open

Rohit John gave more information on the question:
Dear Karol,

> aren't those two statements opposite:
- You are correct, I made a mistake. It is supposed to be
"I am trying to simulate a rigid box that is constrained to rotate about an axis that DOES NOT PASS through its centre of mass. "
If I wanted the axis to pass through the center of mass, then using the blockedDOF variable of the body is sufficient.

> I think that is a good time to ask about MWE
- From what I understand a MWE is required when there is an error in the code. I am not facing an error but require guidance on how to constrain motion. Below I have given an example of what I require. I am simplified the problem. Instead of a box, I have used a clump made of two spheres. This clump is free to rotate about an axis passing through one of the spheres (NOT THE CENTRE OF MASS of the clump). I used a penalty force method discussed in [1] to constrain the motion of the clump. I want to know if there are other ways to achieve this.

Kind regards,
Rohit K. John

# ------------------------------------------------------------------------------------------------------------------------------- YADE SCRIPT
from math import *
from yade import *
from yade import utils, geom

# ---------------------------------------------------------------------------------- bodies
sph1 = sphere((0, -2, 2), .5)
sph2 = sphere(center=(0, 0, 0), radius=.5, fixed=True)

sph1_id = O.bodies.append(sph1)
sph2_id = O.bodies.append(sph2)

g        =  Vector3([0,0,-10])
stiffnes = 1e7

# ---------------------------------------------------------------- clump
clump_id = O.bodies.clump([sph1_id, sph2_id])

# ---------------------------------------------------------------------------------- engines
O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom()],  # collision geometry
[Ip2_FrictMat_FrictMat_FrictPhys()],  # collision "physics"
[Law2_ScGeom_FrictPhys_CundallStrack()]  # contact law -- apply forces
),
PyRunner(command = "eccentricAxisEngine()", iterPeriod = 1),
NewtonIntegrator(gravity=g, damping=0.0),
]

# ---------------------------------------------------------------------------------- additional engines
def eccentricAxisEngine():
pos_0 = O.bodies[sph2_id].state.pos
force = -stiffnes*pos_0
O.forces.addF(id = sph2_id, f = force)

# ---------------------------------------------------------------------------------- sim setup
O.dt = .5e-2 * PWaveTimeStep()
O.saveTmp()

--