Re: [Yade-users] [Question #690825]: writing a yade class

2020-06-05 Thread Launchpad Janitor
Question #690825 on Yade changed:
https://answers.launchpad.net/yade/+question/690825

Status: Needs information => Expired

Launchpad Janitor expired the question:
This question was expired because it remained in the 'Needs information'
state without activity for the last 15 days.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690825]: writing a yade class

2020-05-21 Thread Jan Stránský
Question #690825 on Yade changed:
https://answers.launchpad.net/yade/+question/690825

Status: Open => Needs information

Jan Stránský requested more information:
> before declaring as a static method. ok?

this I don't understand.. :-(
such discussion is becoming too abstract, probably the specific content of your 
files would be needed.. (as a single post probably?)

> but where and how (syntax) do i define and implement the expression
for d(alfa)/dt= in this part??

same as above, please provide the content of your .hpp and .cpp files..

from what I understood:

// .hpp file
class MyPhys {
   static Real computeNewAlpha(...);
   ...
}

// .cpp file
Real MyPhys :: computeNewAlpha(...) {
   // here you put the computation, wither directly or possibly using other 
functions, depends..
   return newAlpha;
}

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690825]: writing a yade class

2020-05-21 Thread Rioual
Question #690825 on Yade changed:
https://answers.launchpad.net/yade/+question/690825

Status: Answered => Open

Rioual is still having a problem:
Hello Jan,

OK, I created 3 staticmethods computeNormalForce, computeTangentialForce
and computeNewAlfa in the phys part of my hpp contact lawclass file. I
have apparently the precise the .def() with all the static and dynamic
parameters necessary for computation of the variable in this
part...before declaring as a static method.   ok?

Concerning the syntax In Law2::go (which is in the .cpp class file of my 
contact law):
 you tell me to write "phys.alpha = MyPhys::computeNewAlpha(phys.alpha,dt,...)"
but where and how (syntax) do i define and implement the expression for 
d(alfa)/dt=  in this part??

Thanks for all

Best,

V.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690825]: writing a yade class

2020-05-20 Thread Jan Stránský
Question #690825 on Yade changed:
https://answers.launchpad.net/yade/+question/690825

Status: Open => Answered

Jan Stránský proposed the following answer:
> if i get it(?)

I would say yes

> which define my yade class

actually several classes :-)

> i have an internal variable alfa to evolves with time through an
evolution equation ... How can i test values for different time steps
using the previous methodology??

supposing alpha is a member of MyPhys (different value for each interaction).
alpha is probably updated inside Law2::go function.
But the computation of new value of alpha depends on a finite set of parameters.
So on the MyPhys, you define a static method, let's say 
computeNewAlpha(oldAlpha,dt,whatever)
In Law2::go, you would call this method and provide all parameters.
phys.alpha = MyPhys::computeNewAlpha(phys.alpha,dt,...)
Then in Python you can test the function independently on anything if it 
computes expected values:
MyPhys.computeNewAlpha(0.5,0.1,123)

> i have to use a 2 particle basic yade simulation for that ??

One option is to test it directly on Yade simulation.
But from maintanance point of view, I like the approach of we are discussing. 
E.g. in future if you want to use a different equation for alpha, you just 
replace the body of computeNewAlpha function, modify expected test results and 
that's it.

Definitely the two-sphere tests should be part of the testing, but can be one 
of the last steps, when you are sure everything else (MyPhys.computeNewAlpha 
and other computations) works.
The "structural-level tests" should be the very last testing step in an ideal 
testing case.

cheers
Jan

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690825]: writing a yade class

2020-05-20 Thread Rioual
Question #690825 on Yade changed:
https://answers.launchpad.net/yade/+question/690825

Status: Answered => Open

Rioual is still having a problem:
Dear Jan,

Thanks for your input and encouragement.

- My question was to be able to test the implemented yade files .hpp and .cpp 
associated to a contact law.
The same files that will be called by yade to use the new interaction law.
So option b) (Discussed in [4], #4) would be more my focus.
Basically, if i get it(?):
1) i keep the  .hpp and .cpp files I wrote following [1][2][3][4] (which define 
my yade class) 
2)I add several staticmethod along these files. 
3) From yade terminal in python, i use the staticmethods defined previously to 
test different values or expressions of the class (as explained
in [4], #4).

- In my case i have an internal variable alfa to evolves with time through an 
evolution equation (see
 https://answers.launchpad.net/yade/+question/690280); How can i test values 
for different time steps 
using the previous methodology??
 i have to use a 2 particle basic yade simulation for that ?? ( #1 of 
https://answers.launchpad.net/yade/+question/690655).

All the best

V.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690825]: writing a yade class

2020-05-19 Thread Jan Stránský
Question #690825 on Yade changed:
https://answers.launchpad.net/yade/+question/690825

Status: Open => Answered

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

> I want to write a specific Yade Class to test a new contact law
defined by hpp and cpp files.

You have basically two options:

a)
(Discussed in [4], #3)
write the "equation code" externally and then you do not need to bother with 
Yade at all (probably would be even more difficult if Yade was incorporated).
This way,the code is easy to test externally, is lightweight, can be used not 
only with Yade..
It is also easily testable as a C++ program (as I wrote, I have no real 
experience, I use Python)
Than the Yade class just use equations from these external files.

b)
(Discussed in [4], #4)
write "normal Yade class", but structure it such that it uses a lot of 
functions. Each function is then independently testable (so there should be no 
need of "insert regular prints")
Basically it would be like to make all functions from a) approach as static 
methods of "normal yade classes".
Can be tested very similarly as a), but the testing can be done in Python 
(which is IMO much easier and more flexible).

After a while I think that b) is the way to go.
Unless you have special needs like reusing the code in another DEM code etc. 
which I suppose is not the case.

> I will insert regular prints

for development stage, this is probably OK, but is not "clean" solution
for the final code. (now the logging would come :-)

using b) correctly, this should not be necessary.

> What is the syntax for a yade class ??

syntax is standard C++..
Usually Yade macros are used, but they are not necessary btw., but helps to 
unify the code of"end" classes, make interaction with Python "out of the box", 
helps saving/loading...
But the macros are again standard C++ :-)

> some examples i could get inspiration from ?

already discussed Cpm* [1], Frict* [2] and Bubble* [3]
material/IPhys/Ip2/Law2 "stack".

For really testing as such, I don't know about examples of "sub-class
testing" not using actual Yade simulations..

> In which folder do i store this Yade Class ??

the easiest is probably yade/pkg/dem directory (both a) and b)
approaches)

cheers
Jan

PS: do not be discouraged, it is simply completely new field, so it
takes time to get familiar with it :-)

[1] https://answers.launchpad.net/yade/+question/690684
[2] https://answers.launchpad.net/yade/+question/690280
[3] https://answers.launchpad.net/yade/+question/690708
[4] https://answers.launchpad.net/yade/+question/690655

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


[Yade-users] [Question #690825]: writing a yade class

2020-05-19 Thread Rioual
New question #690825 on Yade:
https://answers.launchpad.net/yade/+question/690825

Hello,

I want to write a specific Yade Class to test a new contact law defined by  hpp 
and cpp files. I will insert regular prints
 in this class for the test of the law, following previous advices from Jan and 
Bruno (https://answers.launchpad.net/yade/+question/690655).
What is the syntax for a yade class ?? some examples i could get inspiration 
from ?  
In which folder do i store this Yade Class ??


Thanks,
Best,

Vincent

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp