# Assinging a mass to a particle and applying displacment BC

Hi,
I am new to YADE. My code currently has on,ly two particles that just stay there. I have few questions:

1. How do I define a mass to my particle?
2. I want to apply a velocity boundary condition on my second ball. Lets say 0.005t .

My CODE:

# DATA COMPONENTS

# add 2 particles to the simulation
# they the default material (utils.defaultMat)
O.bodies.append([
# fixed: particle's position in space will not change (support)
# this particles is free, subject to dynamics
])

# FUNCTIONAL COMPONENTS

# simulation loop -- see presentation for the explanation
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
),

]

# set timestep to a fraction of the critical timestep
# the fraction is very small, so that the simulation is not too fast
# and the motion can be observed
O.dt=.5e-4*PWaveTimeStep()

# save the simulation, so that it can be reloaded later, for experimentation
O.saveTmp()

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
mrhappy
Solved:
2020-01-21
Last query:
2020-01-21
2020-01-20
 Jan Stránský (honzik) said on 2020-01-19: #1

Hello,

1)
b.state.mass = value

2)
b.state.vel = (vx,vy,vz) # setting velcity value, initial condition
b.state.blockedDOFs = "xyz" # if you want to preserve velocity regardless interactions

sidenote:
in answers, we usually use short variable names, like "b" for a body. In your case, "b" could be e.g. O.bodies[0], so you can use
O.bodies[0].state.mass = ...
or
b = O.bodies[0]

In another situation it could be e.g.
sph = sphere(...)
O.bodies.append(sphere)
sph.state.mass = ...

cheers
Jan
b.state.mass = ...

 mrhappy (mrhappy) said on 2020-01-20: #2

Hey Jan,

1. What are units for the mass? Is it in kg?
2. Where exactly can I place these lines in my current code?
3. I don't understand b.state.blockedDOFs = "xyz" . Lets say I want a fixed velocity of 3m/s in the x and y direction. How do I do that.

Thank you soo much. I really appreciate your help.

Thanks!

 Robert Caulk (rcaulk) said on 2020-01-20: #3

_A useful link appeared in the forum_ [1]

 Jan Stránský (honzik) said on 2020-01-20: #4

Hello,

1.
Yade has no units, it just computes numbers.
It is a good practise to have input units in basic units (m, kg, s, N, Pa, ..), then you are sure your output is also basic units

2.
basically you can put is anywhere :-)
You should put it where you need it.
E.g. if you want to set initial velocity of a body, you should put the velocity-setting-code somewhere after the body creation and before the first O.step/O.run command.

3.
> I don't understand b.state.blockedDOFs = "xyz"

b.state.blockedDOFs = "xyz" means that displacement degrees of freedom are blocked in x, y and z directions (blocked = interactions and external forces does not change velocity)

> Lets say I want a fixed velocity of 3m/s in the x and y direction. How do I do that.

b.state.blockedDOFs = "xy"
b.state.vel = (3,3,0)

this would make x and y velocity components be constant regardless interactions. z velocity component will change according to interaction forces.

cheers
Jan

 mrhappy (mrhappy) said on 2020-01-21: #5

Thank you soooo much Jan.
I really appreciate it!