1 #ifndef MERCURYDPM_CALIBRATION_H
2 #define MERCURYDPM_CALIBRATION_H
59 void setPSD(
int argc,
char *argv[]) {
60 for (
unsigned i=0;
i<argc-1; ++
i) {
61 if (!strcmp(argv[
i],
"-psd")) {
62 std::vector<DistributionElements> psdVector;
65 if (!strcmp(argv[
i + 1],
"logNormal"))
67 logger.assert_debug(argc >
i + 5,
"Error in logNormal");
69 double meanX = std::atof(argv[
i + 4]);
70 double stdX = std::atof(argv[
i + 5]);
71 if (!strcmp(argv[
i + 3],
"radius"))
74 else if (!strcmp(argv[
i + 3],
"diameter"))
79 logger(
ERROR,
"setPSD: distribution type % not known", argv[
i+3]);
81 double meanX2 = meanX*meanX;
82 double stdX2 = stdX*stdX;
83 double mean =
log(meanX2/sqrt(meanX2+stdX2));
84 double std = sqrt(
log(1+stdX2/meanX2));
85 double lnRMin = mean-2.5*std;
86 double lnRMax = mean+2.5*std;
88 psdVector.push_back({0.5*
exp(lnRMin), 0});
90 for (
int j = 1; j <
n; ++j) {
91 double lnR = lnRMin + j / (
double)
n * (lnRMax - lnRMin);
93 value.
probability = 0.5 * (1.0 + erf((lnR - mean) / (sqrt(2) * std)));
94 psdVector.push_back(value);
98 psdVector.push_back({0.5*
exp(lnRMax), 1});
99 if (!strcmp(argv[
i+2],
"number")) {
101 }
else if (!strcmp(argv[
i+2],
"volume")) {
104 logger(
ERROR,
"setPSD: distribution type % not known", argv[
i+2]);
109 for (
unsigned j=
i+4; j<argc-2 && argv[j][0]!=
'-' && argv[j+1][0]!=
'-'; j+=2) {
110 if (!strcmp(argv[
i+3],
"radius")) {
112 }
else if (!strcmp(argv[
i+3],
"diameter")) {
115 logger(
ERROR,
"setPSD: distribution type % not known", argv[
i+3]);
118 psdVector.push_back(value);
120 if (!strcmp(argv[
i+1],
"cumulative")) {
121 if (!strcmp(argv[
i+2],
"number")) {
123 }
else if (!strcmp(argv[
i+2],
"volume")) {
126 logger(
ERROR,
"setPSD: distribution type % not known", argv[
i+1]);
128 }
else if (!strcmp(argv[
i+1],
"probability")) {
129 if (!strcmp(argv[
i+2],
"number")) {
131 }
else if (!strcmp(argv[
i+2],
"volume")) {
134 logger(
ERROR,
"setPSD: distribution type % not known", argv[
i+1]);
137 logger(
ERROR,
"setPSD: distribution type % not known", argv[
i+2]);
149 if (stringSpecies ==
"LinearViscoelasticFrictionReversibleAdhesiveSpecies") {
160 double restitutionCoefficient =
readFromCommandLine(argc,argv,
"-restitutionCoefficient",1.0);
161 species->setCollisionTimeAndRestitutionCoefficient(collisionTime, restitutionCoefficient, massMin);
163 species->setSlidingFrictionCoefficient(
readFromCommandLine(argc,argv,
"-slidingFriction",0.0));
164 species->setSlidingStiffness(2. / 7. * species->getStiffness());
165 species->setSlidingDissipation(2. / 7. * species->getDissipation());
166 species->setRollingFrictionCoefficient(
readFromCommandLine(argc,argv,
"-rollingFriction",0.0));
167 species->setRollingStiffness(2. / 5. * species->getStiffness());
168 species->setRollingDissipation(2. / 5. * species->getDissipation());
169 species->setTorsionFrictionCoefficient(
readFromCommandLine(argc,argv,
"-torsionFriction",0.0));
170 species->setTorsionStiffness(2. / 5. * species->getStiffness());
171 species->setTorsionDissipation(2. / 5. * species->getDissipation());
173 species->setAdhesionStiffness(species->getStiffness());
174 species->setAdhesionForceMax(9.8*massD50*
readFromCommandLine(argc,argv,
"-bondNumber",0.0));
176 setTimeStep(0.05 * species->getCollisionTime(massMin));
180 mixedSpecies->setRollingFrictionCoefficient(0.0);
181 mixedSpecies->setSlidingFrictionCoefficient(0.0);
182 mixedSpecies->setAdhesionForceMax(0.0);
186 mixedSpecies->setRollingFrictionCoefficient(std::max(1.0,species->getSlidingFrictionCoefficient()));
187 mixedSpecies->setSlidingFrictionCoefficient(std::max(1.0,species->getRollingFrictionCoefficient()));
188 mixedSpecies->setAdhesionForceMax(0.0);
204 std::ofstream out(
getName()+
".psd");
209 out <<
"Diameter volumeProbability\n";
210 for (
auto p : vpsd.getParticleSizeDistribution())
211 out << p.internalVariable*2.0 <<
' ' << p.probability <<
'\n';
213 std::ofstream out2(
getName()+
".psd2");
214 out2 <<
"Diameter volumeProbability\n";
216 out2 << p->getRadius()*2.0 <<
'\n';
219 "psd = importdata('" +
getName() +
".psd',' ',1);\n"
222 "plot(d*1e6,p,'k.-',\"LineWidth\",2)\n"
223 "xlabel(\"diameter [um]\")\n"
224 "ylabel(\"number cumulative\")\n"
228 "psd2 = importdata('" +
getName() +
".psd2',' ',1);\n"
229 "d=psd2.data(:,1);\n"
230 "histogram(d*1e6,'Normalization','cdf')\n"
231 "legend('exact','data')\n"
232 "set(legend,'Location','best')\n"
235 "saveas(gcf,'" +
getName() +
".psd.png')\n");
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
const unsigned NEVER
Definition: File.h:35
@ NO_FILE
file will not be created/read
@ ONE_FILE
all data will be written into/ read from a single file called name_
Species< LinearViscoelasticNormalSpecies, FrictionSpecies, ReversibleAdhesiveSpecies > LinearViscoelasticFrictionReversibleAdhesiveSpecies
Definition: LinearViscoelasticFrictionReversibleAdhesiveSpecies.h:35
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
Definition: Calibration.h:19
Calibration(int argc, char *argv[])
Definition: Calibration.h:28
void writePSDToFile()
Definition: Calibration.h:202
ParticleSpecies * particleSpecies
Definition: Calibration.h:22
ParticleSpecies * frictionlessWallSpecies
Definition: Calibration.h:24
PSD psd
Definition: Calibration.h:21
void setPSD(int argc, char *argv[])
Definition: Calibration.h:59
void setSpecies(int argc, char *argv[])
Definition: Calibration.h:147
std::string param
Definition: Calibration.h:25
std::string getParam()
Definition: Calibration.h:39
ParticleSpecies * frictionalWallSpecies
Definition: Calibration.h:23
void setOutput(bool output)
Definition: Calibration.h:42
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
File eneFile
An instance of class File to handle in- and output into a .ene file.
Definition: DPMBase.h:1488
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:459
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1493
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1347
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
class of DistributionElements which stores internalVariables and probabilities of a distribution....
Definition: DistributionElements.h:34
Mdouble internalVariable
Definition: DistributionElements.h:36
Mdouble probability
Definition: DistributionElements.h:37
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:215
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
Contains a vector with radii and probabilities of a user defined particle size distribution (PSD)
Definition: PSD.h:65
Mdouble getMinRadius() const
Get smallest radius of the PSD.
Definition: PSD.cc:886
Mdouble getVolumeDx(Mdouble x) const
Calculate a certain diameter (e.g. D10, D50, D90, etc.) from a percentile x of the volume based PSD.
Definition: PSD.cc:777
@ PROBABILITYDENSITY_VOLUME_DISTRIBUTION
@ CUMULATIVE_VOLUME_DISTRIBUTION
@ PROBABILITYDENSITY_NUMBER_DISTRIBUTION
@ CUMULATIVE_NUMBER_DISTRIBUTION
MERCURYDPM_DEPRECATED void setPSDFromVector(std::vector< DistributionElements > psd, TYPE PSDType)
Deprecated version of reading in PSDs from a vector.
Definition: PSD.cc:396
Definition: ParticleSpecies.h:37
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:74
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467
const Mdouble NaN
Definition: GeneralDefine.h:43
const Mdouble pi
Definition: ExtendedMath.h:45
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
bool readFromCommandLine(int argc, char *argv[], std::string varName)
Returns true if command line arguments contain varName, false else.
Definition: CommandLineHelpers.cc:103
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:104
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:115