yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #23148
Re: [Question #690825]: writing a yade class
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.