← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2900: Add exactDiam flag to SpheresFactory

 

------------------------------------------------------------
revno: 2900
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Tue 2011-07-26 11:16:58 +0200
message:
  Add exactDiam flag to SpheresFactory
modified:
  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 'pkg/dem/SpheresFactory.cpp'
--- pkg/dem/SpheresFactory.cpp	2011-07-21 10:00:24 +0000
+++ pkg/dem/SpheresFactory.cpp	2011-07-26 09:16:58 +0000
@@ -29,9 +29,13 @@
 	}
 	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()) {
-			LOG_ERROR("PSDcum and PSDsizes should have an equal number of elements.");
-			throw std::logic_error("PSDcum and PSDsizes should have an equal number of elements.");
+		
+		if ((PSDcum.size() != PSDsizes.size()) and (exactDiam)) {								//The number of elements in both arrays should be the same
+			LOG_ERROR("PSDcum and PSDsizes should have an equal number of elements, if exactDiam=True.");
+			throw std::logic_error("PSDcum and PSDsizes should have an equal number of elements, if exactDiam=True.");
+		} else if ((PSDcum.size() != (PSDsizes.size()-1)) and (not(exactDiam))) {//The number of elements in PSDsizes should be on 1 more, than in PSDcum
+			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");
 		}
 		PSDuse = true;
 		
@@ -65,7 +69,14 @@
 					maxdiffID = k;
 				}
 			}
-			r=PSDsizes[maxdiffID]/2.0;
+			
+			if (exactDiam) {							//Choose the exact diameter
+				r=PSDsizes[maxdiffID]/2.0;
+			} else {											//Choose the diameter from the range
+				Real rMinE = PSDsizes[maxdiffID]/2.0;
+				Real rMaxE = PSDsizes[maxdiffID+1]/2.0;
+				r=rMinE+randomUnit()*(rMaxE-rMinE);
+			}
 		} else {
 			// pick random radius
 			r=rMin+randomUnit()*(rMax-rMin);

=== modified file 'pkg/dem/SpheresFactory.hpp'
--- pkg/dem/SpheresFactory.hpp	2011-07-21 10:00:24 +0000
+++ pkg/dem/SpheresFactory.hpp	2011-07-26 09:16:58 +0000
@@ -37,7 +37,8 @@
 		((std::string,blockedDOFs,"" ,,"Blocked degress of freedom"))
 		((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,PSDcalculateMass,true,,"PSD-Input is in mass (true), otherwise the number of particles will be considered."))
+    ((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;
 	);
 };