Yade documnetation

Asked by mohsen

in the name of god
hello
I'am confused with yade documentation specially chapters 8 and 9. here are my questions (I know they are elementary) :
1- what is the difference between Class references (chap 8) and modules (chap 9)?
2- as an example, in chap 8 one class is (p. 412):
     class yade.wrapper.BodyContainer((object)arg1, (BodyContainer)arg2)
     can anyone explain what is the meaning of each expression:
     i : yade.wrapper
     ii: bodyContainer
     iii: (object)arg1, (BodyContainer)arg2--> why font style of these two is italic?
     iv: arg1, arg2
3-In chap 9, in some classes the word 'class' is omitted in other places not. why ?(example) :
    yade.pack.gtsSurface2Facets(surf, **kw) (p 440)
    class yade.pack.inGtsSurface_py(inherits Predicate) (p. 441)

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello Mohsen,

I'am confused with yade documentation

There are more versions of the documentation, please send a link..

> 1- what is the difference between Class references (chap 8) and modules
> (chap 9)?
>

the main difference is location of the source code. Class reference is
generated from C++ source files, while modules are Python modules located
in different directory

> 2- as an example, in chap 8 one class is (p. 412):
> class yade.wrapper.BodyContainer((object)arg1, (BodyContainer)arg2)
> can anyone explain what is the meaning of each expression:
> i : yade.wrapper
>

yade.wrapper is a Python module created to wrap the C++ part of Yade for
Python

> ii: bodyContainer
>

BodyContainer is class name

     iii: (object)arg1, (BodyContainer)arg2--> why font style of these two
> is italic?
>

it comes from the template, to emphasize that they are input arguments

> iv: arg1, arg2
>

argument1, argument2 :-)
arg1 is always the object itself (like "self" in class definitions in
Python)
other arguments are what the function/class expects, usually also with
type. The very first line of each class is the default constructor. So
BodyContainer expects another BodyContainer as an argument :-) Just to get
an idea (I have never used this code myself) you can try in Yade:

BodyContainer() # results in error complaining about missing argument
BodyContainer(O.bodies) # without error

> 3-In chap 9, in some classes the word 'class' is omitted in other places
> not. why ?(example) :
> yade.pack.gtsSurface2Facets(surf, **kw) (p 440)
> class yade.pack.inGtsSurface_py(inherits Predicate) (p. 441)
>

yade.pack.gtsSurface2Facets(surf, **kw) is just a plain function, not
class, that's the reason

I am not sure if I explained everything understandably, if not, just ask
again :-)
cheers
Jan

Revision history for this message
mohsen (agha-mohsena) said :
#2

hello Jan
thatns you for your consideration

my reference Documentation link:
https://yade-dem.org/doc/Yade.pdf

there are some more ambiguities:

about question 1- : there are some functions in Class references(ch 8) that are repeated in Yade modules (ch9); although they are not the same but i can not understand the difference for a better selecting when coding:
      class yade.wrapper.Sphere((object)arg1) (p.156)
       yade.utils.sphere(center, radius, dynamic=None, fixed=False, wire=False, color=None, highlight= False, material=-1, mask=1) (p. 464)

again such classes could be found about 'tetra'. what is the difference between s1 (an instance of yade.wrapper.Sphere) and s2(an instance of yade.utils.sphere)

2- i found this example on page 6:
Yade [96]: s=utils.sphere(center=[0,0,0],radius=1)
...
Yade [99]: s.shape.radius
...
as i have searched there is no 'radius' method for 'shape' class (p 151). how above command is correct?

thanks Jan

Revision history for this message
Best Jan Stránský (honzik) said :
#3

Hi Mohsen,

> my reference Documentation link:
> https://yade-dem.org/doc/Yade.pdf

thanks

>
>
> there are some more ambiguities:

> about question 1- : there are some functions in Class references(ch 8)
> that are repeated in Yade modules (ch9); although they are not the same but
> i can not understand the difference for a better selecting when coding:
> class yade.wrapper.Sphere((object)arg1) (p.156)
> yade.utils.sphere(center, radius, dynamic=None, fixed=False,
> wire=False, color=None, highlight= False, material=-1, mask=1) (p. 464)
>

be careful, that all commands are case sensitive, so sphere and Sphere are
completely different things :-) Sphere is a class inherited from Shape.
utils.sphere(...) is auxiliary function to create Body, whose shape is
Sphere:

#########
s = sphere((0,0,0),1)
print s
print s.shape
#########

Even if the name would be the same, the different "namespace" (yade.wrapper
or yade.utils) means, that it is different thing. you can try

#######
utils.Sphere = utils.sphere
print utils.Sphere
print yade.wrapper.Sphere
#######

> again such classes could be found about 'tetra'. what is the difference
> between s1 (an instance of yade.wrapper.Sphere) and s2(an instance of
> yade.utils.sphere)
>
> 2- i found this example on page 6:
> Yade [96]: s=utils.sphere(center=[0,0,0],radius=1)
> ...
> Yade [99]: s.shape.radius
> ...
> as i have searched there is no 'radius' method for 'shape' class (p 151).
> how above command is correct?
>

In the example, "s" is instance of Body. Body has attributes e.g. state,
shape etc. s.shape can be any shape, but if it is created by utils.sphere
functions, s.shape is Sphere, and it has radius (you can find Sphere in
class reference). Also see my above comments

cheers
Jan

Revision history for this message
mohsen (agha-mohsena) said :
#4

thank you Jan so much
i have to focus on
1- Class reference and modules more; they have confused me.
2- the procedure of creating of a body
thank again

Revision history for this message
mohsen (agha-mohsena) said :
#5

Thanks Jan Stránský, that solved my question.