← Back to team overview

yade-users team mailing list archive

Re: [Question #269434]: Attractive force

 

Question #269434 on Yade changed:
https://answers.launchpad.net/yade/+question/269434

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hello,

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 ?


In general I don't see a big problem here. Roughly saying, all contact laws
evaluate interaction forces somehow dependent on particles distance.
However, usually the forces are repulsive when particles are getting closer
:-) So I think there will be need of a new contact law, involving c++
source code modification...

I give you my script here. I'm new to Yade, if you have suggestions or
> remarks about my code


I think the code is OK, especially for beginner

def brownian():
>                 for b in O.bodies:
>                         Vpre=0
>                         Id = b.id
>                         f1 = - (gamma*Vpre) + (sqrt(2*kB*T*gamma/Deltat)*
> random.gauss(0,1))
>                         f2 = - (gamma*Vpre) + (sqrt(2*kB*T*gamma/Deltat)*
> random.gauss(0,1))
>                         f3 = - (gamma*Vpre) + (sqrt(2*kB*T*gamma/Deltat)*
> random.gauss(0,1))
>                         O.forces.addF(Id,(f1, f2,f3), permanent = True)
>                         Vpre = b.state.vel


just note that addF actually sets new permanent force, instead of adding
the random force to the value :-)

Not knowing anything of physical modeling of Brownian motion, what is the
purpose of Vpre (as it is not used in the code)?

#here i would like to do something simpler and save position in different
> files but i can not and i don't know whi


To save data in more files, you have more options (depending on the purpose
of having more files):
1) use standard and easy-to-use plot functions, saving data in 1 file and
after the simulation split the file in more files (using e.g. python or
some other script)
2) write your own function for saving (take plot.data and save it
"manually")
3) write your own function for both storing data during simulation and
saving


just the last note, plot module can deal with vectors. you can save some
lines by:

def addPlotData():
        ...
        position1 = O.bodies[1].state.pos
        ...
        plot.addData(
                                ...
                                pos1=position1,
                                ...
         )

then plot.saveDataTxt will results to:

# ... pos1_x pos1_y pos1_z ...
...

cheers
Jan

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.