yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #06755
[Branch ~yade-dev/yade/trunk] Rev 2666: 1. Unbreak the periodic cell.
------------------------------------------------------------
revno: 2666
committer: Václav Šmilauer <eu@xxxxxxxx>
branch nick: yade
timestamp: Thu 2011-01-20 15:55:15 +0100
message:
1. Unbreak the periodic cell.
added:
py/tests/engines.py
renamed:
py/tests/omega.py => py/tests/core.py
modified:
core/Cell.cpp
core/Cell.hpp
core/Scene.cpp
examples/concrete/periodic.py
py/pack/pack.py
py/tests/__init__.py
py/tests/pbc.py
py/tests/wrapper.py
scripts/test/facet-sphere-ViscElBasic-peri.py
scripts/test/peri3dController_example1.py
scripts/test/peri3dController_shear.py
scripts/test/peri8.py
scripts/test/periodic-compress.py
scripts/test/periodic-geom-compare.py
scripts/test/periodic-grow.py
scripts/test/periodic-shear.py
scripts/test/periodic-simple-shear.py
scripts/test/periodic-simple.py
scripts/test/periodic-triax.py
scripts/test/sphere-sphere-ViscElBasic-peri.py
py/tests/core.py
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/Cell.cpp'
--- core/Cell.cpp 2011-01-19 18:47:05 +0000
+++ core/Cell.cpp 2011-01-20 14:55:15 +0000
@@ -9,6 +9,7 @@
invTrsf=trsf.inverse();
// Hsize contains colums with updated base vectors
Hsize+=_trsfInc*Hsize;
+ if(Hsize.determinant()==0){ throw runtime_error("Cell is degenerate (zero volume)."); }
// lengths of transformed cell vectors, skew cosines
Matrix3r Hnorm; // normalized transformed base vectors
for(int i=0; i<3; i++){
=== modified file 'core/Cell.hpp'
--- core/Cell.hpp 2011-01-19 18:47:05 +0000
+++ core/Cell.hpp 2011-01-20 14:55:15 +0000
@@ -88,10 +88,15 @@
Vector3r bodyFluctuationVel(const Vector3r& pos, const Vector3r& vel) const { if(homoDeform==HOMO_VEL || homoDeform==HOMO_VEL_2ND) return (vel-velGrad*pos); return vel; }
Vector3r getRefSize() const { return refSize; }
- void setRefSize(const Vector3r& s){refSize=s; Hsize=Matrix3r::Zero(); Hsize.diagonal()=refSize; Hsize=trsf*Hsize; integrateAndUpdate(0);}
- void setInitHsize(const Matrix3r& m){Hsize=m; for (int k=0;k<3;k++) refSize[k]=Hsize.col(k).norm(); integrateAndUpdate(0);}
+ // change length of initial cell vectors (scale current Hsize by the ratio)
+ // should be identical to: { refSize=s; Hsize=invTrsf*Hsize; for(int i=0;i<3;i++) Hsize.col(i)=Hsize.col(i).normalized()*refSize[i]; /* transform back*/ Hsize=trsf*Hsize; integrateAndUpdate(0); }
+ void setRefSize(const Vector3r& s){ for(int i=0;i<3;i++) Hsize.col(i)*=s[i]/refSize[i]; refSize=s; integrateAndUpdate(0); }
+ Matrix3r getHsize() const { return Hsize; }
+ void setHsize(const Matrix3r& m){ Hsize=m; for(int k=0;k<3;k++) refSize[k]=Hsize.col(k).norm(); integrateAndUpdate(0);}
+ Matrix3r getHsize0() const { return invTrsf*Hsize; }
Matrix3r getTrsf() const { return trsf; }
void setTrsf(const Matrix3r& m){ Hsize=m*invTrsf*Hsize; trsf=m; integrateAndUpdate(0); }
+
// return current cell volume
Real getVolume() const {return Hsize.determinant();}
void postLoad(Cell&){ integrateAndUpdate(0); }
@@ -103,15 +108,23 @@
enum { HOMO_NONE=0, HOMO_POS=1, HOMO_VEL=2, HOMO_VEL_2ND=3 };
YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Cell,Serializable,"Parameters of periodic boundary conditions. Only applies if O.isPeriodic==True.",
- ((Vector3r,refSize,Vector3r(1,1,1),Attr::readonly,"Reference size of the cell. Change the value with :yref:`Cell::setRefSize`"))
- ((Matrix3r,trsf,Matrix3r::Identity(),Attr::readonly,"Current transformation matrix of the cell. Change the value with :yref:`Cell::setTrsf`"))
+ /* overridden below to be modified by getters/setters because of intended side-effects */
+ ((Vector3r,refSize,Vector3r(1,1,1),,"[overridden]"))
+ ((Matrix3r,trsf,Matrix3r::Identity(),,"[overridden]"))
+ ((Matrix3r,Hsize,Matrix3r::Identity(),,"[overridden]"))
+ /* normal attributes */
((Matrix3r,invTrsf,Matrix3r::Identity(),Attr::readonly,"Inverse of current transformation matrix of the cell."))
- ((Matrix3r,velGrad,Matrix3r::Zero(),,"Velocity gradient of the transformation; used in NewtonIntegrator."))
+ ((Matrix3r,velGrad,Matrix3r::Zero(),,"Velocity gradient of the transformation; used in :yref:`NewtonIntegrator`."))
((Matrix3r,prevVelGrad,Matrix3r::Zero(),Attr::readonly,"Velocity gradient in the previous step."))
- ((Matrix3r,Hsize,Matrix3r::Zero(),Attr::readonly,"The current cell size (one column per box edge), computed from *refSize* and *trsf* |yupdate|"))
((int,homoDeform,3,Attr::triggerPostLoad,"Deform (:yref:`velGrad<Cell.velGrad>`) the cell homothetically, by adjusting positions or velocities of particles. The values have the following meaning: 0: no homothetic deformation, 1: set absolute particle positions directly (when ``velGrad`` is non-zero), but without changing their velocity, 2: adjust particle velocity (only when ``velGrad`` changed) with Îv_i=Î âv x_i. 3: as 2, but include a 2nd order term in addition -- the derivative of 1 (convective term in the velocity update).")),
/*ctor*/ integrateAndUpdate(0),
/*py*/
+ // override some attributes above
+ .add_property("refSize",&Cell::getRefSize,&Cell::setRefSize,"Reference size of the cell (lengths of initial cell vectors, i.e. columns of :yref:`Hsize<Cell.Hsize>`). Modifying this value will scale cell vectors such to have desired length.")
+ .add_property("Hsize",&Cell::getHsize,&Cell::setHsize,"Base cell vectors (columns of the matrix), updated at every step from :yref:`velGrad<Cell.velGrad>` (:yref:`trsf<Cell.trsf>` accumulates applied :yref:`velGrad<Cell.velGrad>` transformations).")
+ .add_property("trsf",&Cell::getTrsf,&Cell::setTrsf,"Current transformation matrix of the cell.")
+ // useful properties
+ .add_property("Hsize0",&Cell::getHsize0,"Initial value of Hsize, before applying transformation (computed as :yref:`invTrsf<Cell.invTrsf>` Ã :yref:`Hsize<Cell.Hsize>`.")
.def_readonly("size",&Cell::getSize_copy,"Current size of the cell, i.e. lengths of 3 cell lateral vectors after applying current trsf. Update automatically at every step.")
.add_property("volume",&Cell::getVolume,"Current volume of the cell.")
// debugging only
@@ -119,9 +132,6 @@
.def("unshearPt",&Cell::unshearPt,"Apply inverse shear on the point (removes skew+rot of the cell)")
.def("shearPt",&Cell::shearPt,"Apply shear (cell skew+rot) on the point")
.def("wrapPt",&Cell::wrapPt_py,"Wrap point inside the reference cell, assuming the cell has no skew+rot.")
- .def("setTrsf",&Cell::setTrsf,"Set transformation (will update Hsize as if it was initialy an axis-aligned cuboïd).")
- .def("setRefSize",&Cell::setRefSize,"Set reference size of the cell (will update Hsize as if the cell was initialy an axis-aligned cuboïd).")
- .def("setInitHsize",&Cell::setInitHsize,"Define reference base vectors of the undeformed period. The shape is arbitrary: a non-rectangular parallepiped can be defined as the reference configuration, and will correspond to trsf=0.")
.def_readonly("shearTrsf",&Cell::_shearTrsf,"Current skew+rot transformation (no resize)")
.def_readonly("unshearTrsf",&Cell::_unshearTrsf,"Inverse of the current skew+rot transformation (no resize)")
);
=== modified file 'core/Scene.cpp'
--- core/Scene.cpp 2010-11-24 22:42:15 +0000
+++ core/Scene.cpp 2011-01-20 14:55:15 +0000
@@ -27,6 +27,7 @@
#include<unistd.h>
#include<time.h>
+namespace py=boost::python;
YADE_PLUGIN((Scene));
CREATE_LOGGER(Scene);
@@ -49,6 +50,7 @@
tags.push_back("id="+id);
tags.push_back("d.id="+id);
tags.push_back("id.d="+id);
+ // tags.push_back("revision="+py::extract<string>(py::import("yade.config").attr("revision"))());;
}
=== modified file 'examples/concrete/periodic.py'
--- examples/concrete/periodic.py 2011-01-19 18:22:56 +0000
+++ examples/concrete/periodic.py 2011-01-20 14:55:15 +0000
@@ -82,7 +82,7 @@
avgRadius=numpy.average([r for c,r in sp])
O.bodies.append([utils.sphere(c,r,color=utils.randomColor()) for c,r in sp])
O.periodic=True
-O.cell.setRefSize(sp.cellSize)
+O.cell.refSize=sp.cellSize
axis=2
ax1=(axis+1)%3
ax2=(axis+2)%3
=== modified file 'py/pack/pack.py'
--- py/pack/pack.py 2011-01-19 18:22:56 +0000
+++ py/pack/pack.py 2011-01-20 14:55:15 +0000
@@ -90,8 +90,8 @@
assert(isinstance(rot,Matrix3))
if self.cellSize!=Vector3.Zero:
O.periodic=True
- O.cell.setTrsf(rot)
- O.cell.setRefSize(self.cellSize)
+ O.cell.trsf=rot
+ O.cell.refSize=self.cellSize
if not self.hasClumps():
return O.bodies.append([utils.sphere(rot*c,r,**kw) for c,r in self])
else:
@@ -427,12 +427,12 @@
# x1,y1,z1 already computed above
sp=SpherePack()
O.periodic=True
- O.cell.setRefSize(Vector3(x1,y1,z1))
+ O.cell.refSize=(x1,y1,z1)
#print cloudPorosity,beta,gamma,N100,x1,y1,z1,O.cell.refSize
#print x1,y1,z1,radius,rRelFuzz
O.materials.append(FrictMat(young=3e10,density=2400))
num=sp.makeCloud(Vector3().Zero,O.cell.refSize,radius,rRelFuzz,spheresInCell,True)
- O.engines=[ForceResetter(),InsertionSortCollider([Bo1_Sphere_Aabb()],nBins=5,sweepLength=.05*radius),InteractionLoop([Ig2_Sphere_Sphere_Dem3DofGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_Dem3DofGeom_FrictPhys_CundallStrack()]),PeriIsoCompressor(charLen=2*radius,stresses=[-100e9,-1e8],maxUnbalanced=1e-2,doneHook='O.pause();',globalUpdateInt=5,keepProportions=True),NewtonIntegrator(damping=.6)]
+ O.engines=[ForceResetter(),InsertionSortCollider([Bo1_Sphere_Aabb()],nBins=5,verletDist=.05*radius),InteractionLoop([Ig2_Sphere_Sphere_Dem3DofGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_Dem3DofGeom_FrictPhys_CundallStrack()]),PeriIsoCompressor(charLen=2*radius,stresses=[-100e9,-1e8],maxUnbalanced=1e-2,doneHook='O.pause();',globalUpdateInt=5,keepProportions=True),NewtonIntegrator(damping=.6)]
O.materials.append(FrictMat(young=30e9,frictionAngle=.5,poisson=.3,density=1e3))
for s in sp: O.bodies.append(utils.sphere(s[0],s[1]))
O.dt=utils.PWaveTimeStep()
@@ -478,9 +478,9 @@
O.switchScene(); O.resetThisScene()
sp=SpherePack()
O.periodic=True
- O.cell.setRefSize(Vector3(initSize))
+ O.cell.refSize=initSize
sp.makeCloud(Vector3().Zero,O.cell.refSize,radius,rRelFuzz,-1,True)
- O.engines=[ForceResetter(),InsertionSortCollider([Bo1_Sphere_Aabb()],nBins=2,sweepLength=.05*radius),InteractionLoop([Ig2_Sphere_Sphere_Dem3DofGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_Dem3DofGeom_FrictPhys_CundallStrack()]),PeriIsoCompressor(charLen=2*radius,stresses=[-100e9,-1e8],maxUnbalanced=1e-2,doneHook='O.pause();',globalUpdateInt=20,keepProportions=True),NewtonIntegrator(damping=.8)]
+ O.engines=[ForceResetter(),InsertionSortCollider([Bo1_Sphere_Aabb()],nBins=2,verletDist=.05*radius),InteractionLoop([Ig2_Sphere_Sphere_Dem3DofGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_Dem3DofGeom_FrictPhys_CundallStrack()]),PeriIsoCompressor(charLen=2*radius,stresses=[-100e9,-1e8],maxUnbalanced=1e-2,doneHook='O.pause();',globalUpdateInt=20,keepProportions=True),NewtonIntegrator(damping=.8)]
O.materials.append(FrictMat(young=30e9,frictionAngle=.1,poisson=.3,density=1e3))
for s in sp: O.bodies.append(utils.sphere(s[0],s[1]))
O.dt=utils.PWaveTimeStep()
=== modified file 'py/tests/__init__.py'
--- py/tests/__init__.py 2011-01-12 16:22:18 +0000
+++ py/tests/__init__.py 2011-01-20 14:55:15 +0000
@@ -4,7 +4,7 @@
import unittest,inspect
# add any new test suites to the list here, so that they are picked up by testAll
-allTests=['wrapper','omega','pbc','clump','cohesive-chain']
+allTests=['wrapper','core','pbc','clump','cohesive-chain']
# all yade modules (ugly...)
import yade.eudoxos,yade.export,yade.linterpolation,yade.log,yade.pack,yade.plot,yade.post2d,yade.timing,yade.utils,yade.ymport,yade.geom
=== renamed file 'py/tests/omega.py' => 'py/tests/core.py'
--- py/tests/omega.py 2011-01-19 18:22:56 +0000
+++ py/tests/core.py 2011-01-20 14:55:15 +0000
@@ -2,7 +2,7 @@
# 2009 © Václav Šmilauer <eudoxos@xxxxxxxx>
"""
-Basic functionality of Omega, such as accessing bodies, materials, interactions.
+Core functionality (Scene in c++), such as accessing bodies, materials, interactions. Specific functionality tests should go to engines.py or elsewhere, not here.
"""
import unittest
import random
@@ -18,10 +18,10 @@
class TestForce(unittest.TestCase): pass
class TestTags(unittest.TestCase): pass
-class TestEngines(unittest.TestCase):
+class TestLoop(unittest.TestCase):
def setUp(self): O.reset()
def testSubstepping(self):
- 'Engines: substepping'
+ 'Loop: substepping'
O.engines=[ForceResetter(),PyRunner(initRun=True,iterPeriod=1,command='pass'),GravityEngine()]
# value outside the loop
self.assert_(O.subStep==-1)
@@ -36,7 +36,7 @@
O.engines=[PyRunner(initRun=True,iterPeriod=1,command='if O.subStep!=0: raise RuntimeError("O.subStep!=0 inside the loop with O.subStepping==False!")')]
O.step()
def testEnginesModificationInsideLoop(self):
- 'Engines: can be modified inside the loop transparently.'
+ 'Loop: O.engines can be modified inside the loop transparently.'
O.engines=[
PyRunner(initRun=True,iterPeriod=1,command='from yade import *; O.engines=[ForceResetter(),GravityEngine(),NewtonIntegrator()]'), # change engines here
ForceResetter() # useless engine
@@ -56,54 +56,9 @@
self.assert_(len(O.engines)==3)
self.assert_(len(O._currEngines)==3)
def testDead(self):
- 'Engines: dead engines are not run'
+ 'Loop: dead engines are not run'
O.engines=[PyRunner(dead=True,initRun=True,iterPeriod=1,command='pass')]
O.step(); self.assert_(O.engines[0].nDone==0)
- def testKinematicEngines(self):
- 'Engines: test kinematic engines'
- tolerance = 1e-5
- rotIndex=1.0
- angVelTemp = pi/rotIndex
- O.reset()
- id_fixed_transl = O.bodies.append(utils.sphere((0.0,0.0,0.0),1.0,fixed=True))
- id_nonfixed_transl = O.bodies.append(utils.sphere((0.0,5.0,0.0),1.0,fixed=False))
- id_fixed_rot = O.bodies.append(utils.sphere((0.0,10.0,10.0),1.0,fixed=True))
- id_nonfixed_rot = O.bodies.append(utils.sphere((0.0,15.0,10.0),1.0,fixed=False))
- id_fixed_helix = O.bodies.append(utils.sphere((0.0,20.0,10.0),1.0,fixed=True))
- id_nonfixed_helix = O.bodies.append(utils.sphere((0.0,25.0,10.0),1.0,fixed=False))
- O.engines=[
-
- TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_fixed_transl]),
- TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_nonfixed_transl]),
- RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_rot]),
- RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_rot]),
- HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_helix]),
- HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_helix]),
- ForceResetter(),
- NewtonIntegrator()
- ]
- O.dt = 1.0
- for i in range(0,25):
- O.step()
- self.assertTrue(abs(O.bodies[id_fixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of fixed bodies
- self.assertTrue(abs(O.bodies[id_nonfixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of nonfixed bodies
-
- self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[0]-10.0*sin(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies X
- self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[2]-10.0*cos(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies Y
- self.assertTrue(abs(O.bodies[id_fixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance) #Check rotation of fixed bodies, angle
-
- self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check rotation of nonfixed bodies X
- self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check rotation of nonfixed bodies Y
- self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance) #Check rotation of nonfixed bodies, angle
-
- self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of fixed bodies X
- self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of fixed bodies Y
- self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[1]-20.0 - O.iter)<tolerance) #Check helixEngine of fixed bodies Z
-
- self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of nonfixed bodies X
- self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of nonfixed bodies Y
- self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[1]-25.0 - O.iter)<tolerance) #Check helixEngine of nonfixed bodies Z
-
@@ -123,15 +78,6 @@
failed=list(failed); failed.sort()
self.assert_(len(failed)==0,'Failed classes were: '+' '.join(failed))
-
-class TestCell(unittest.TestCase):
- def setUp(self):
- O.reset(); O.periodic=True
- def testAttributesAreCrossUpdated(self):
- "Cell: updates Hsize automatically when refSize is updated"
- O.cell.setRefSize((2.55,11,45))
- self.assert_(O.cell.Hsize==Matrix3(2.55,0,0, 0,11,0, 0,0,45));
-
class TestMaterialStateAssociativity(unittest.TestCase):
def setUp(self): O.reset()
def testThrowsAtBadCombination(self):
=== added file 'py/tests/engines.py'
--- py/tests/engines.py 1970-01-01 00:00:00 +0000
+++ py/tests/engines.py 2011-01-20 14:55:15 +0000
@@ -0,0 +1,58 @@
+'test functionality of individual engines'
+
+import unittest
+import random
+from yade.wrapper import *
+from miniEigen import *
+from yade._customConverters import *
+from yade import utils
+from yade import *
+from math import *
+
+
+class TestKinematicEngines(unittest.TestCase):
+ def testKinematicEngines(self):
+ 'Engines: kinematic engines'
+ tolerance = 1e-5
+ rotIndex=1.0
+ angVelTemp = pi/rotIndex
+ O.reset()
+ id_fixed_transl = O.bodies.append(utils.sphere((0.0,0.0,0.0),1.0,fixed=True))
+ id_nonfixed_transl = O.bodies.append(utils.sphere((0.0,5.0,0.0),1.0,fixed=False))
+ id_fixed_rot = O.bodies.append(utils.sphere((0.0,10.0,10.0),1.0,fixed=True))
+ id_nonfixed_rot = O.bodies.append(utils.sphere((0.0,15.0,10.0),1.0,fixed=False))
+ id_fixed_helix = O.bodies.append(utils.sphere((0.0,20.0,10.0),1.0,fixed=True))
+ id_nonfixed_helix = O.bodies.append(utils.sphere((0.0,25.0,10.0),1.0,fixed=False))
+ O.engines=[
+ TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_fixed_transl]),
+ TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_nonfixed_transl]),
+ RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_rot]),
+ RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_rot]),
+ HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_helix]),
+ HelixEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], linearVelocity = 1.0, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_helix]),
+ ForceResetter(),
+ NewtonIntegrator()
+ ]
+ O.dt = 1.0
+ for i in range(0,2):
+ O.step()
+ self.assertTrue(abs(O.bodies[id_fixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of fixed bodies
+ self.assertTrue(abs(O.bodies[id_nonfixed_transl].state.pos[0] - O.iter) < tolerance) #Check translation of nonfixed bodies
+
+ self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[0]-10.0*sin(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies X
+ self.assertTrue(abs(O.bodies[id_fixed_rot].state.pos[2]-10.0*cos(pi/angVelTemp*O.iter))<tolerance) #Check rotation of fixed bodies Y
+ self.assertTrue(abs(O.bodies[id_fixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance) #Check rotation of fixed bodies, angle
+
+ self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check rotation of nonfixed bodies X
+ self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check rotation of nonfixed bodies Y
+ self.assertTrue(abs(O.bodies[id_nonfixed_rot].state.ori.toAxisAngle()[1]-Quaternion(Vector3(0.0,1.0,0.0),pi/angVelTemp*O.iter).toAxisAngle()[1])<tolerance) #Check rotation of nonfixed bodies, angle
+
+ self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of fixed bodies X
+ self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of fixed bodies Y
+ self.assertTrue(abs(O.bodies[id_fixed_helix].state.pos[1]-20.0 - O.iter)<tolerance) #Check helixEngine of fixed bodies Z
+
+ self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of nonfixed bodies X
+ self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance) #Check helixEngine of nonfixed bodies Y
+ self.assertTrue(abs(O.bodies[id_nonfixed_helix].state.pos[1]-25.0 - O.iter)<tolerance) #Check helixEngine of nonfixed bodies Z
+
+
=== modified file 'py/tests/pbc.py'
--- py/tests/pbc.py 2011-01-19 18:22:56 +0000
+++ py/tests/pbc.py 2011-01-20 14:55:15 +0000
@@ -18,7 +18,7 @@
# prefix test names with PBC:
def setUp(self):
O.reset(); O.periodic=True;
- O.cell.setRefSize(Vector3(2.5,2.5,3))
+ O.cell.refSize=(2.5,2.5,3)
self.cellDist=Vector3i(0,0,10) # how many cells away we go
self.relDist=Vector3(0,.999999999999999999,0) # rel position of the 2nd ball within the cell
self.initVel=Vector3(0,0,5)
@@ -31,6 +31,10 @@
O.cell.velGrad=Matrix3(0,0,0, 0,0,0, 0,0,-1)
O.cell.homoDeform=3
O.dt=0 # do not change positions with dt=0 in NewtonIntegrator, but still update velocities from velGrad
+ def testRefSize(self):
+ "PBC: Hsize reflects changes of refSize"
+ O.cell.refSize=(2.55,11,45)
+ self.assert_(O.cell.Hsize==Matrix3(2.55,0,0, 0,11,0, 0,0,45));
def testHomotheticResizeVel(self):
"PBC: homothetic cell deformation adjusts particle velocity (homoDeform==3)"
O.dt=1e-5
=== modified file 'py/tests/wrapper.py'
--- py/tests/wrapper.py 2010-10-19 14:57:27 +0000
+++ py/tests/wrapper.py 2011-01-20 14:55:15 +0000
@@ -14,8 +14,6 @@
from yade import system
from yade import *
-
-
allClasses=system.childClasses('Serializable')
class TestObjectInstantiation(unittest.TestCase):
@@ -65,6 +63,36 @@
# accessing invalid attributes raises AttributeError
self.assertRaises(AttributeError,lambda: Sphere(attributeThatDoesntExist=42))
self.assertRaises(AttributeError,lambda: Sphere().attributeThatDoesntExist)
+ ##
+ ## attribute flags
+ ##
+ def testTriggerPostLoad(self):
+ 'Core: Attr::triggerPostLoad'
+ # TranslationEngine normalizes translationAxis automatically
+ # anything else could be tested
+ te=TranslationEngine();
+ te.translationAxis=(0,2,0)
+ self.assert_(te.translationAxis==(0,1,0))
+ def testHidden(self):
+ 'Core: Attr::hidden'
+ # hidden attributes are not wrapped in python at all
+ self.assert_(not hasattr(Interaction(),'iterLastSeen'))
+ def testNoSave(self):
+ 'Core: Attr::noSave'
+ # update bound of the particle
+ O.bodies.append(utils.sphere((0,0,0),1))
+ O.engines=[InsertionSortCollider([Bo1_Sphere_Aabb()]),NewtonIntegrator()]
+ O.step()
+ O.saveTmp()
+ mn0=Vector3(O.bodies[0].bound.min)
+ O.reload()
+ mn1=Vector3(O.bodies[0].bound.min)
+ # check that the minimum is not saved
+ self.assert_(not isnan(mn0[0]))
+ self.assert_(isnan(mn1[0]))
+ def _testReadonly(self):
+ 'Core: Attr::readonly'
+ self.assertRaises(AttributeError,lambda: setattr(Body(),'id',3))
class TestEigenWrapper(unittest.TestCase):
def assertSeqAlmostEqual(self,v1,v2):
=== modified file 'scripts/test/facet-sphere-ViscElBasic-peri.py'
--- scripts/test/facet-sphere-ViscElBasic-peri.py 2011-01-19 18:22:56 +0000
+++ scripts/test/facet-sphere-ViscElBasic-peri.py 2011-01-20 14:55:15 +0000
@@ -45,7 +45,7 @@
]
O.periodic=True
-O.cell.setRefSize(Vector3(1,1,1))
+O.cell.refSize=(1,1,1)
O.dt=.01*tc
=== modified file 'scripts/test/peri3dController_example1.py'
--- scripts/test/peri3dController_example1.py 2010-10-17 01:06:13 +0000
+++ scripts/test/peri3dController_example1.py 2011-01-20 14:55:15 +0000
@@ -61,5 +61,5 @@
O.step()
bo1s.aabbEnlargeFactor=ig2ss.distFactor=-1
-O.run(); O.wait()
+O.run(); #O.wait()
plot.plot()
=== modified file 'scripts/test/peri3dController_shear.py'
--- scripts/test/peri3dController_shear.py 2011-01-19 18:22:56 +0000
+++ scripts/test/peri3dController_shear.py 2011-01-20 14:55:15 +0000
@@ -55,6 +55,7 @@
renderer=qt.Renderer()
renderer.intrPhys,renderer.shape=True,False
+Gl1_CpmPhys.dmgLabel=False
qt.View()
O.run()
#plot.plot()
=== modified file 'scripts/test/peri8.py'
--- scripts/test/peri8.py 2011-01-19 18:22:56 +0000
+++ scripts/test/peri8.py 2011-01-20 14:55:15 +0000
@@ -3,7 +3,7 @@
[utils.sphere(c,r) for c in [(r,r,r),(3*r,r,r),(3*r,3*r,r),(r,3*r,r),(r,r,3*r),(3*r,r,3*r),(3*r,3*r,3*r),(r,3*r,3*r)]]
)
O.periodic=True
-O.cell.setRefSize((a,a,a))
+O.cell.refSize=(a,a,a)
zRot=-pi/4.
-O.cell.setTrsf(Matrix3(cos(zRot),-sin(zRot),0,sin(zRot),cos(zRot),0,0,0,1))
+O.cell.trsf=Matrix3(cos(zRot),-sin(zRot),0,sin(zRot),cos(zRot),0,0,0,1)
p7=O.bodies[7].state.pos
=== modified file 'scripts/test/periodic-compress.py'
--- scripts/test/periodic-compress.py 2011-01-19 18:22:56 +0000
+++ scripts/test/periodic-compress.py 2011-01-20 14:55:15 +0000
@@ -1,5 +1,5 @@
O.periodic=True
-O.cell.setRefSize(Vector3(20,20,10))
+O.cell.refSize=(20,20,10)
from yade import pack,log,timing
O.materials.append(FrictMat(young=30e9,density=2400))
p=pack.SpherePack()
=== modified file 'scripts/test/periodic-geom-compare.py'
--- scripts/test/periodic-geom-compare.py 2011-01-19 18:22:56 +0000
+++ scripts/test/periodic-geom-compare.py 2011-01-20 14:55:15 +0000
@@ -6,8 +6,8 @@
#log.setLevel('PeriTriaxController',log.DEBUG)
#log.setLevel('Shop',log.TRACE)
O.periodic=True
-O.cell.setRefSize(Vector3(.1,.1,.1))
-O.cell.setTrsf(Matrix3().Identity);
+O.cell.refSize=(.1,.1,.1)
+O.cell.trsf=Matrix3().Identity;
sp=pack.SpherePack()
radius=5e-3
=== modified file 'scripts/test/periodic-grow.py'
--- scripts/test/periodic-grow.py 2011-01-19 18:22:56 +0000
+++ scripts/test/periodic-grow.py 2011-01-20 14:55:15 +0000
@@ -19,7 +19,7 @@
cubeSize=20
# absolute positioning of the cell is not important
O.periodic=True
-O.cell.setRefSize(Vector3(cubeSize,cubeSize,cubeSize))
+O.cell.refSize=(cubeSize,cubeSize,cubeSize)
O.dt=utils.PWaveTimeStep()
O.saveTmp()
from yade import qt
=== modified file 'scripts/test/periodic-shear.py'
--- scripts/test/periodic-shear.py 2011-01-19 18:22:56 +0000
+++ scripts/test/periodic-shear.py 2011-01-20 14:55:15 +0000
@@ -1,5 +1,5 @@
O.periodic=True
-O.cell.setRefSize(Vector3(.55,.55,.55))
+O.cell.refSize=(.55,.55,.55)
O.bodies.append(utils.facet([[.4,.0001,.3],[.2,.0001,.3],[.3,.2,.2]]))
O.bodies.append(utils.sphere([.3,.1,.4],.05,dynamic=True))
O.bodies.append(utils.sphere([.200001,.2000001,.4],.05,dynamic=False))
@@ -26,7 +26,7 @@
# O.cellShear=Vector3(.2*sin(g),.2*cos(pi*g),.2*sin(2*g)+.2*cos(3*g))
# time.sleep(0.001)
# g+=1e-3
-O.cell.setTrsf(Matrix3(1,0,0, 0,1,.5, 0,0,1))
+O.cell.trsf=Matrix3(1,0,0, 0,1,.5, 0,0,1)
O.dt=2e-2*utils.PWaveTimeStep()
O.step()
O.saveTmp()
=== modified file 'scripts/test/periodic-simple-shear.py'
--- scripts/test/periodic-simple-shear.py 2011-01-19 18:22:56 +0000
+++ scripts/test/periodic-simple-shear.py 2011-01-20 14:55:15 +0000
@@ -5,7 +5,7 @@
from yade import pack,log,qt
log.setLevel('PeriTriaxController',log.TRACE)
O.periodic=True
-O.cell.setRefSize(Vector3(.1,.1,.1))
+O.cell.refSize=(.1,.1,.1)
#O.cell.Hsize=Matrix3(0.1,0,0, 0,0.1,0, 0,0,0.1)
sp=pack.SpherePack()
radius=5e-3
=== modified file 'scripts/test/periodic-simple.py'
--- scripts/test/periodic-simple.py 2011-01-19 18:22:56 +0000
+++ scripts/test/periodic-simple.py 2011-01-20 14:55:15 +0000
@@ -24,7 +24,7 @@
O.bodies.appendClumped([utils.sphere([0,4,8],.8),utils.sphere([0,5,7],.6)])
# sets up the periodic cell
O.periodic=True
-O.cell.setRefSize(Vector3(10,10,10))
+O.cell.refSize=(10,10,10)
# normally handled in by the simulation... but we want to have the rendering right before start
O.cell.postProcessAttributes()
O.dt=.1*utils.PWaveTimeStep()
=== modified file 'scripts/test/periodic-triax.py'
--- scripts/test/periodic-triax.py 2011-01-19 18:22:56 +0000
+++ scripts/test/periodic-triax.py 2011-01-20 14:55:15 +0000
@@ -5,7 +5,7 @@
from yade import pack,log,qt
log.setLevel('PeriTriaxController',log.TRACE)
O.periodic=True
-O.cell.setRefSize(Vector3(.1,.1,.1))
+O.cell.refSize=(.1,.1,.1)
#O.cell.Hsize=Matrix3(0.1,0,0, 0,0.1,0, 0,0,0.1)
sp=pack.SpherePack()
radius=5e-3
=== modified file 'scripts/test/sphere-sphere-ViscElBasic-peri.py'
--- scripts/test/sphere-sphere-ViscElBasic-peri.py 2011-01-19 18:22:56 +0000
+++ scripts/test/sphere-sphere-ViscElBasic-peri.py 2011-01-20 14:55:15 +0000
@@ -36,7 +36,7 @@
]
O.periodic=True
-O.cell.setRefSize(Vector3(1,1,1))
+O.cell.refSize=(1,1,1)
O.dt=.01*tc