# How to integrate motion in only one direction?

I'd like to model the soil-structure interaction. My structure is created by spheres as a clump. I only want to give it one DoF in the Z direction but keep its coordinate in X and Y directions constant or zero. How should I do?

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Karol Brzezinski
Solved:
Last query:
 Revision history for this message Guo, Chang (guopolyu) said on 2022-09-12: #1

I guess maybe I can set the dynamic of this clump is false and write a one-dimensional newton-integrator for the clump.

 Revision history for this message Karol Brzezinski (kbrzezinski) said on 2022-09-12: #2

Hi Guo,

You can block all degrees of freedom, except for 'z'. Let's say 'b' is your body, so:

b.state.blockedDOFs='xyXYZ'

the above code constrains body, and allows only for vertical movement (capital letters control rotation).

Best wishes,
Karol

 Revision history for this message Guo, Chang (guopolyu) said on 2022-09-12 #3

Hi Karol,
I've tried to use this function to block DoFs. But it didn't work.

This is part of my code. The clump's DoFs weren't blocked.

OutDiameter=0.1143

PipeRoughR=0.01

SectionNum=20

LongNum=15

WidthX=0.6

HeightZ=3

HeightZ0=0.3

thickness=0.01

gravity=(0,0,-10)

densityPipe=7850

InputR=OutDiameter/2-PipeRoughR

Gap=sin(pi/SectionNum)*2*InputR

LengthY=Gap*(LongNum-1)+PipeRoughR

PipeParticleNum=0

PP=[]

for j in range(LongNum):

for i in range(SectionNum):

PipeParticleNum += 1

PPID=O.bodies.appendClumped(PP)

PPClump=O.bodies[PPID[0]]

PPClump.dynamic=1

PPClump.state.blockDOFs='xyXYZ'

PPClump.state.vel = (0, 1,0)

PPClump.state.angVel = (0,0,0)

h=0.4

sp=pack.SpherePack()

sp.makeCloud((thickness*5,0.001,h),(WidthX-thickness*5,LengthY-0.001,h+.2),rMean=0.02)

#

sp.toSimulation(material=O.materials[SphereMID])

newton=NewtonIntegrator(damping=0.4,gravity=gravity,dampGravity=0)

O.engines=[

ForceResetter(),

#(1) This is where we allow big bodies, else it would crash due to the very large bottom box:

InsertionSortCollider([Bo1_Box_Aabb(),Bo1_Sphere_Aabb()],allowBiggerThanPeriod=True),

InteractionLoop(

[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],

[Ip2_FrictMat_FrictMat_FrictPhys()],

[Law2_ScGeom_FrictPhys_CundallStrack()]

),

GlobalStiffnessTimeStepper(),

newton,

]

for b in O.bodies:

if isinstance(b.shape,Sphere):

b.state.vel[2]=-1

Thank you.

Yours sincerely,
GUO

 Revision history for this message Karol Brzezinski (kbrzezinski) said on 2022-09-12: #4

Hi,

Try
PPClump.state.blockedDOFs='xyXYZ'

PPClump.state.blockDOFs='xyXYZ'

Cheers,
Karol

 Revision history for this message Guo, Chang (guopolyu) said on 2022-09-13 #5

OK. Thank you very much.
One more small question: why is there no warning when I write a wrong code?

 Revision history for this message Karol Brzezinski (kbrzezinski) said on 2022-09-13: #6

It is because you can give a new attribute to the body this way. For example, if you want to discriminate between groups of bodies, you can do something like this.

###
if b.state.pos[2]<z1:
b.shape.belongsTo = 'bottom'
###

belongsTo is an attribute that I have just made up.

Cheers,
Karol

 Revision history for this message Guo, Chang (guopolyu) said on 2022-09-13: #7

OK. I get it.
Thank you very much.

Yours sincerely,
GUO

 Revision history for this message Guo, Chang (guopolyu) said on 2022-09-13: #8

Thanks Karol Brzezinski, that solved my question.