yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07821
[Branch ~yade-dev/yade/trunk] Rev 2901: 1. Add example of SpheresFactory into packs.py
------------------------------------------------------------
revno: 2901
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Tue 2011-07-26 14:38:18 +0200
message:
1. Add example of SpheresFactory into packs.py
2. Add stopIfFailed flag to SpheresFactory.
modified:
examples/packs/packs.py
pkg/dem/SpheresFactory.cpp
pkg/dem/SpheresFactory.hpp
--
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 'examples/packs/packs.py'
--- examples/packs/packs.py 2011-02-23 15:15:29 +0000
+++ examples/packs/packs.py 2011-07-26 12:38:18 +0000
@@ -129,8 +129,22 @@
rotateAroundZero=1,
zeroPoint=[-7.0,-6.0,-5.0]),
HarmonicMotionEngine(A=[0,0,0.5], f=[0,0,20.0], fi = [0.0,0.0,pi], ids = vibrationPlate),
- HarmonicRotationEngine(A=0.2, f=20.0, fi = pi, rotationAxis=[1.0,0.0,0.0], rotateAroundZero = True, zeroPoint = [-15.0,3.0,-7.0], ids = vibrationRotationPlate)
+ HarmonicRotationEngine(A=0.2, f=20.0, fi = pi, rotationAxis=[1.0,0.0,0.0], rotateAroundZero = True, zeroPoint = [-15.0,3.0,-7.0], ids = vibrationRotationPlate),
+ BoxFactory(maxParticles=300, extents=(1.0,1.0,1.0),center=(0.0,12.0,0.0),vMin=200.0,vMax=250.0,
+ PSDsizes=(0.1, 0.2, 0.3, 0.5, 0.7), PSDcum=(0.1, 0.5, 0.8, 1.0), PSDcalculateMass=True, exactDiam=False,
+ vAngle=math.pi/3.0,massFlowRate=50000.0,normal=(0.0,0.0,1.0),label='factory',mask=7,silent=True,stopIfFailed=False)
]
+'''
+Boxfactory is an example of usage SpheresFactory. Produces PSD-dispersion:
+
+Size: Mass, % Cumulative Cum. mass
+ mass,%
+0.5-0.7 20% 100% 1.0
+0.3-0.5 30% 80% 0.8
+0.2-0.3 40% 50% 0.5
+0.1-0.2 10% 10% 0.1
+'''
+
# we don't care about physical accuracy here, (over)critical step is fine as long as the simulation doesn't explode
O.dt=utils.PWaveTimeStep()
O.saveTmp()
=== modified file 'pkg/dem/SpheresFactory.cpp'
--- pkg/dem/SpheresFactory.cpp 2011-07-26 09:16:58 +0000
+++ pkg/dem/SpheresFactory.cpp 2011-07-26 12:38:18 +0000
@@ -27,7 +27,9 @@
FOREACH(const shared_ptr<Engine>& e, scene->engines){ collider=dynamic_pointer_cast<Collider>(e); if(collider) break; }
if(!collider) throw runtime_error("SpheresFactory: No Collider instance found in engines (needed for collision detection).");
}
+
goalMass+=massFlowRate*scene->dt; // totalMass that we want to attain in the current step
+
if ((PSDcum.size()>0) and (!PSDuse)) { //Defined, that we will use PSD
if ((PSDcum.size() != PSDsizes.size()) and (exactDiam)) { //The number of elements in both arrays should be the same
@@ -37,6 +39,31 @@
LOG_ERROR("PSDsizes should have a number of elements on 1 more, than PSDcum, if exactDiam=False");
throw std::logic_error("PSDsizes should have a number of elements on 1 more, than PSDcum, if exactDiam=False");
}
+
+ //Check the correctness of inputted data PSDcum
+ for (unsigned int i=1; i<PSDcum.size(); i++) {
+ if (PSDcum[i]<PSDcum[i-1] or PSDcum[i-1]<=0) {
+ LOG_ERROR("PSDcum should have an ascending positive series of numbers (for example: 0.1, 0.3, 0.5, 1.0)");
+ throw std::logic_error("PSDcum should have an ascending positive series of numbers (for example: 0.1, 0.3, 0.5, 1.0)");
+ }
+ }
+ //Check the correctness of inputted data PSDsizes
+ for (unsigned int i=1; i<PSDsizes.size(); i++) {
+ if (PSDsizes[i]<PSDsizes[i-1] or PSDsizes[i-1]<=0) {
+ LOG_ERROR("PSDsizes should have an ascending positive series of numbers (for example: 15, 20, 50, 80)");
+ throw std::logic_error("PSDsizes should have an ascending positive series of numbers (for example: 15, 20, 50, 80)");
+ }
+ }
+
+ //Make normalization of PSDcum
+ if (PSDcum[PSDcum.size()]!=1.0) {
+ Real k;
+ k = 1.0/PSDcum[PSDcum.size()-1];
+ for (unsigned int i=1; i<PSDcum.size(); i++) {
+ PSDcum[i] = PSDcum[i]*k;
+ }
+ }
+
PSDuse = true;
//Prepare main vectors
@@ -97,8 +124,11 @@
#endif
}
if(attempt==maxAttempt) {
- if (silent) {massFlowRate=0; goalMass=totalMass; LOG_INFO("Unable to place new sphere after "<<maxAttempt<<" attempts, SpheresFactory disabled.");}
- else {LOG_WARN("Unable to place new sphere after "<<maxAttempt<<" attempts, giving up.");}
+ if (silent) {LOG_INFO("Unable to place new sphere after "<<maxAttempt<<" attempts!");}
+ else {LOG_WARN("Unable to place new sphere after "<<maxAttempt<<" attempts!");}
+ if (stopIfFailed) {
+ massFlowRate=0; goalMass=totalMass;
+ }
return;
}
// pick random initial velocity (normal with some variation)
=== modified file 'pkg/dem/SpheresFactory.hpp'
--- pkg/dem/SpheresFactory.hpp 2011-07-26 09:16:58 +0000
+++ pkg/dem/SpheresFactory.hpp 2011-07-26 12:38:18 +0000
@@ -38,6 +38,7 @@
((vector<Real>,PSDsizes,,,"PSD-dispersion, sizes of cells, Diameter [m]"))
((vector<Real>,PSDcum,,,"PSD-dispersion, cumulative procent meanings [-]"))
((bool,PSDcalculateMass,true,,"PSD-Input is in mass (true), otherwise the number of particles will be considered."))
+ ((bool,stopIfFailed,true,,"If true, the SpheresFactory stops (sets massFlowRate=0), when maximal number of attempts to insert particle exceed."))
((bool,exactDiam,true,,"If true, the particles only with the defined in PSDsizes diameters will be created. Otherwise the diameter will be randomly chosen in the range [PSDsizes[i-1]:PSDsizes[i]], in this case the length of PSDsizes should be more on 1, than the length of PSDcum.")),
PSDuse=false;
);