Attractive force
Hello everybody,
I try to study the behavior of nanoparticles.
I initially coded the Brownian motion and now I'd like to model a simple force of attraction between the different particles. This force would appear only when the particles are quite closed and therefore depend on the distance between the particles.
Do you know a way to do this ?
I give you my script here. I'm new to Yade, if you have suggestions or remarks about my code, please, in particular in the last part which is obviously not perfect. However, the code works. I can use the results and trace the MSD, which looks good.
Thank you in advance.
//
import random, numpy
from yade import pack, qt
from yade import plot
# DATA COMPONENTS
a = 1e-6;
# rayon in meters
d = 2*a;
# diameter in meters
rho = 2.2626e+3;
#masse volumique
m = (4 * math.pi * a * a * a * rho)/3
#masse
mu = 1e-3;
# viscosity of water in SI units (Pascal-seconds) viscosite dynamique
nu =1e-6;
# viscosity of water in SI units (m au carre s moins un) viscosite cinematique
kB = 1.38e-23;
# Boltzmann constant
T = 293;
# Temperature in degrees Kelvin
D = kB * T / (6 * pi * mu * a);
#coef de diffusion
gamma = 6*pi*mu*a;
# Coefficient de friction
tau = m/gamma;
# Momentum relaxation time
Deltat = 10e-9;
#pas de temps que JE fixe
print("La valeur de m est {} ".format(m))
print("La valeur de d est {} ".format(d))
print("La valeur de D est {} ".format(D))
print("La valeur de gamma est {} ".format(gamma))
print("La valeur de Deltat est {} ".format(Deltat))
print("La valeur de tau est {} ".format(tau))
Mat=O.materials
O.bodies.
sp=pack.
sp.makeCloud(
sp.toSimulation()
def brownian():
for b in O.bodies:
Vpre=0
Id = b.id
f1 = - (gamma*Vpre) + (sqrt(2*
f2 = - (gamma*Vpre) + (sqrt(2*
f3 = - (gamma*Vpre) + (sqrt(2*
O.forces.
Vpre = b.state.vel
# FUNCTIONAL COMPONENTS
# simulation loop -- see presentation for the explanation
O.engines=[
ForceResetter(),
InsertionSor
InteractionLoop(
[
[
[
),
NewtonIntegrato
PyRunner(
PyRunner(
]
O.dt = Deltat
O.saveTmp()
from yade import plot
#here i would like to do something simpler and save position in different files but i can not and i don't know whi
def addPlotData():
t = O.time
position = O.bodies[
position1 = O.bodies[
position2 = O.bodies[
position3 = O.bodies[
position4 = O.bodies[
position5 = O.bodies[
position6 = O.bodies[
position7 = O.bodies[
position8 = O.bodies[
position9 = O.bodies[
plot.addData(
tempssurtau = t/tau,
x=position[0],
y=position[1],
z=position[2],
x1=
y1=
z1=
x2=
y2=
z2=
x3=
y3=
z3=
x4=
y4=
z4=
x5=
y5=
z5=
x6=
y6=
z6=
x7=
y7=
z7=
x8=
y8=
z8=
x9=
y9=
z9=
temps =t,
)
O.run(100000, True)
plot.plots={
'x':('y'),
'tempssurtau'
'x1':('y1'),
'x2':('y2'),
#'x3':('y3'),
#'x4':('y4'),
#'x5':('y5'),
#'x6':('y6'),
#'x7':('y7'),
#'x8':('y8'),
#'x9':('y9')
}
plot.plot(
plot.live=True
plot.autozoom=True
plot.saveDataTx
qt.View()
qt.center()
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Thib_bou for more information if necessary.