MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SinterNormalSpecies.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 
27 #include "SinterNormalSpecies.h"
29 #include "Logger.h"
30 class BaseParticle;
31 class BaseInteractable;
32 
34 {
36  loadingStiffness_ = 0.0;
38  cohesionStiffness_ = 0.0;
40  dissipation_ = 0.0;
41  sinterAdhesion_ = 0.0;
42  sinterRate_ = 0.0;
44 #ifdef DEBUG_CONSTRUCTOR
45  std::cout<<"SinterNormalSpecies::SinterNormalSpecies() finished"<<std::endl;
46 #endif
47 }
48 
53 {
63 #ifdef DEBUG_CONSTRUCTOR
64  std::cout<<"SinterNormalSpecies::SinterNormalSpecies(const SinterNormalSpecies &p) finished"<<std::endl;
65 #endif
66 }
67 
69 {
70 #ifdef DEBUG_DESTRUCTOR
71  std::cout<<"SinterNormalSpecies::~SinterNormalSpecies() finished"<<std::endl;
72 #endif
73 }
74 
78 void SinterNormalSpecies::write(std::ostream& os) const
79 {
80  os << " loadingStiffness " << loadingStiffness_;
81  os << " maxUnloadingStiffness " << unloadingStiffnessMax_;
82  os << " cohesionStiffness " << cohesionStiffness_;
83  os << " maxPenetration " << penetrationDepthMax_;
84  os << " dissipation " << dissipation_;
85  os << " sinterAdhesion " << sinterAdhesion_;
86  os << " inverseSinterViscosity " << inverseSinterViscosity_;
87  os << " sinterRate_ " << sinterRate_;
88  os << " sinterType " << (unsigned) sinterType_;
89 }
90 
94 void SinterNormalSpecies::read(std::istream& is)
95 {
96  std::string dummy;
97  is >> dummy >> loadingStiffness_;
98  is >> dummy >> unloadingStiffnessMax_;
99  is >> dummy >> cohesionStiffness_;
100  is >> dummy >> penetrationDepthMax_;
101  is >> dummy >> dissipation_;
102  is >> dummy >> sinterAdhesion_;
103  is >> dummy >> inverseSinterViscosity_;
104  is >> dummy >> sinterRate_;
105  unsigned type;
106  is >> dummy >> type;
107  sinterType_ = (SINTERTYPE) type;
108 }
109 
114 {
115  return "Sinter";
116 }
117 
124 {
132 }
133 
140 void SinterNormalSpecies::setPlasticParameters (Mdouble loadingStiffness, Mdouble unloadingStiffnessMax, Mdouble cohesionStiffness, Mdouble penetrationDepthMax)
141 {
142  if (loadingStiffness <= 0 || unloadingStiffnessMax < loadingStiffness || cohesionStiffness < 0 || penetrationDepthMax < 0)
143  {
144  std::cerr << "Error: arguments of setPlasticParameters do not make sense" << std::endl;
145  exit(-1);
146  }
147  setLoadingStiffness(loadingStiffness);
148  setUnloadingStiffnessMax(unloadingStiffnessMax);
149  setCohesionStiffness(cohesionStiffness);
150  setPenetrationDepthMax(penetrationDepthMax);
151 }
152 
157 {
158  return loadingStiffness_;
159 }
160 
165 {
166  return unloadingStiffnessMax_;
167 }
168 
173 {
174  return cohesionStiffness_;
175 }
176 
181 {
182  return penetrationDepthMax_;
183 }
184 
189 {
190  loadingStiffness_ = loadingStiffness;
191 }
192 
197 {
198  unloadingStiffnessMax_ = unloadingStiffnessMax;
199 }
200 
205 {
206  cohesionStiffness_ = cohesionStiffness;
207 }
208 
213 {
214  penetrationDepthMax_ = penetrationDepthMax;
215 }
216 
222 {
223  if (unloadingStiffnessMax_ / (.5 * mass) < mathsFunc::square(dissipation_ /mass)) {
224  std::cerr << "Dissipation too high; max. allowed " << sqrt(2.0 * unloadingStiffnessMax_ * mass) << std::endl;
225  exit(-1);
226  }
227  return 0.02 * constants::pi / std::sqrt(unloadingStiffnessMax_ / (.5 * mass) - mathsFunc::square(dissipation_ /mass));
228 }
229 
235 {
236  if (dissipation < 0)
237  {
238  logger(ERROR,"setDissipation(%)",dissipation);
239  exit(-1);
240  }
241  dissipation_ = dissipation;
242 }
243 
249 {
250  if (sinterAdhesion < 0)
251  {
252  logger(ERROR,"setSinterAdhesion(%)",sinterAdhesion);
253  exit(-1);
254  }
255  sinterAdhesion_ = sinterAdhesion;
256 }
262 {
263  if (sinterRate < 0)
264  {
265  logger(ERROR,"setSinterRate(%)",sinterRate);
266  }
267  sinterRate_ = sinterRate;
268 }
269 
275 {
276  sinterType_ = sinterType;
278  logger(INFO, "Sintertype set to CONSTANT_RATE");
280  logger(INFO, "Sintertype set to PARHAMI_MCKEEPING");
282  logger(INFO, "Sintertype set to TEMPERATURE_DEPENDENT_FRENKEL");
283  else
284  logger(ERROR, "Sintertype not understood");
285 }
286 
292 {
293  //assertOrDie(inverseSinterViscosity < 0, "inverseSinterViscosity should be non-negative!");
294  if (inverseSinterViscosity < 0)
295  {
296  logger(ERROR,"setInverseSinterViscosity(%)",inverseSinterViscosity);
297  }
299  inverseSinterViscosity_ = inverseSinterViscosity;
300 }
301 
302 void SinterNormalSpecies::setSinterForceAndTime (Mdouble adhesionForce, Mdouble sinterTime, Mdouble radius)
303 {
306  setSinterAdhesion(adhesionForce/radius);
307  setInverseSinterViscosity(1.0/(93.75 * adhesionForce * sinterTime / std::pow(radius, 5)));
308  logger(INFO,"Set sintering parameters: adhesion force f_a=%*r, sinter viscosity is nu = contactRadius^4/%",
310 }
311 
317  (Mdouble alpha, Mdouble beta, Mdouble atomicVolume /*Omega*/, Mdouble surfaceEnergy /*gamma_s*/,
318  Mdouble thicknessDiffusion /*deltaB*D0B*/, Mdouble activationEnergy /*QB*/, Mdouble temperature /*T*/)
319 {
320  setSinterType(SINTERTYPE::PARHAMI_MCKEEPING);
321  const Mdouble boltzmannConstant /*k_B*/ = 1.38064852e-23;
322  const Mdouble gasConstant /*R_g*/ = 8.314459848;
323  const Mdouble thicknessDiffusionVacancy /*DB*/ = thicknessDiffusion*exp(-activationEnergy/gasConstant/temperature);
324  const Mdouble diffusionParameter /*DeltaB*/ = atomicVolume/boltzmannConstant/temperature*thicknessDiffusionVacancy;
325  setInverseSinterViscosity(constants::pi / (2.0 * beta * diffusionParameter));
326  setSinterAdhesion(alpha/beta*constants::pi*surfaceEnergy);
327  logger(INFO,"Set sintering parameters: the adhesion force f_a=%*r, the rate of change of the plastic overlap is d(delta0)/dt=f_ep/(%*a^4)", getSinterAdhesion(),
328  getInverseSinterViscosity());
329 }
330 
335 {
336  setLoadingStiffness(new_.k);
337  setDissipation(new_.disp);
338 }
339 
344 {
345  return dissipation_;
346 }
347 
352 {
353  return sinterAdhesion_;
354 }
359 {
361 }
366 {
367  return sinterRate_;
368 }
370 {
371  return sinterType_;
372 }
373 
375 {
376  return temperatureDependentSinterRate_(temperature);
377 }
378 
379 std::function<double(double temperature)> SinterNormalSpecies::getTemperatureDependentSinterRate() const
380 {
382 }
383 
384 void SinterNormalSpecies::setTemperatureDependentSinterRate(std::function<double(double temperature)> temperatureDependentSinterRate)
385 {
386  temperatureDependentSinterRate_ = temperatureDependentSinterRate;
387 }
388 
389 
398 {
399  if (eps==0.0) {
401  dissipation_ = std::sqrt(2.0 * mass * loadingStiffness_);
402  } else {
403  dissipation_ = -mass / tc * std::log(eps);
405  }
407 }
408 
416 {
417  loadingStiffness_ = stiffness;
418  if (eps==0.0) {
419  dissipation_ = std::sqrt(2.0 * mass * stiffness);
420  } else {
421  dissipation_ = -std::sqrt(2.0 * mass * stiffness / (constants::sqr_pi + mathsFunc::square(log(eps)))) * log(eps);
422  }
424 }
425 
428 {
429  if (mass <= 0)
430  {
431  std::cerr << "Error in getCollisionTime(" << mass << ") mass is not set or has an unexpected value, (getCollisionTime(" << mass << "))" << std::endl;
432  exit(-1);
433  }
434  if (loadingStiffness_ <= 0)
435  {
436  std::cerr << "Error in getCollisionTime(" << mass << ") stiffness=" << loadingStiffness_ << " is not set or has an unexpected value, (getCollisionTime(" << mass << "), with stiffness=" << loadingStiffness_ << ")" << std::endl;
437  exit(-1);
438  }
439  if (dissipation_ < 0)
440  {
441  std::cerr << "Error in getCollisionTime(" << mass << ") dissipation=" << dissipation_ << " is not set or has an unexpected value, (getCollisionTime(" << mass << "), with dissipation=" << dissipation_ << ")" << std::endl;
442  exit(-1);
443  }
444  Mdouble tosqrt = loadingStiffness_ / (.5 * mass) - mathsFunc::square(dissipation_ / mass);
445  if (tosqrt <= -1e-8*loadingStiffness_ / (.5 * mass))
446  {
447  std::cerr << "Error in getCollisionTime(" << mass << ") values for mass, stiffness and dissipation would lead to an overdamped system, (getCollisionTime(" << mass << "), with stiffness=" << loadingStiffness_ << " and dissipation=" << dissipation_ << ")" << std::endl;
448  exit(-1);
449  }
450  return constants::pi / std::sqrt(tosqrt);
451 }
void setParhamiMcKeeping(Mdouble alpha, Mdouble beta, Mdouble atomicVolume, Mdouble surfaceEnergy, Mdouble thicknessDiffusion, Mdouble activationEnergy, Mdouble temperature)
Sets the sinterAdhesion_ and inverseSinterViscosity_ based on the Parhami-McKeeping parameters...
Mdouble unloadingStiffnessMax_
the maximum elastic constant (k_2^max) for plastic deformations
SINTERTYPE sinterType_
sinterType options determin how the rate of sintering, d(equilibriumOverlap)/dt is computed PARHAMI_M...
SinterNormalSpecies()
The default constructor.
void setDissipation(Mdouble dissipation)
Sets the linear dissipation coefficient of the linear plastic-viscoelastic normal force...
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
return type specifically for fuctions returning k and disp at once
Definition: Helpers.h:42
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:53
void setCohesionStiffness(Mdouble cohesionStiffness)
Sets the cohesive stiffness of the linear plastic-viscoelastic normal force.
void setTemperatureDependentSinterRate(std::function< double(double temperature)> temperatureDependentSinterRate)
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:78
Mdouble loadingStiffness_
(normal) spring constant (k_1)
Mdouble cohesionStiffness_
the adhesive spring constant (k^c) for plastic deformations
void read(std::istream &is)
Reads the species properties from an input stream.
void setPenetrationDepthMax(Mdouble penetrationDepthMax)
Sets the maximum penetration depth of the linear plastic-viscoelastic normal force.
void setPlasticParameters(Mdouble loadingStiffness, Mdouble unloadingStiffnessMax, Mdouble cohesionStiffness, Mdouble penetrationDepthMax)
Sets all parameters of the linear plastic-viscoelastic normal force at once.
Mdouble getSinterAdhesion() const
Accesses sinterAdhesion_.
Mdouble computeTimeStep(Mdouble mass)
Returns the optimal time step to resolve a collision of two particles of a given mass.
double Mdouble
void setStiffnessAndRestitutionCoefficient(Mdouble k_, Mdouble eps, Mdouble mass)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of P...
void setSinterAdhesion(Mdouble sinterAdhesion)
Sets sinterAdhesion_.
Mdouble penetrationDepthMax_
the depth (relative to the normalized radius) at which k_2^max is used (phi_f)
Mdouble getCollisionTime(Mdouble mass)
Calculates collision time for two copies of a particle of given disp, k, mass.
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:97
T square(T val)
squares a number
Definition: ExtendedMath.h:91
void setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, Mdouble mass)
Set k, disp such that is matches a given tc and eps for a collision of two different masses...
SINTERTYPE getSinterType() const
void setInverseSinterViscosity(Mdouble inverseSinterViscosity)
Sets inverseSinterViscosity_.
void write(std::ostream &os) const
Writes the species properties to an output stream.
void setSinterRate(Mdouble sinterRate)
Sets sinterRate_.
void setSinterForceAndTime(Mdouble adhesionForce, Mdouble sinterTime, Mdouble radius)
MERCURY_DEPRECATED void setLoadingStiffnessAndDissipation(helpers::KAndDisp new_)
Allows the spring and dissipation constants to be changed simultaneously.
Mdouble disp
Definition: Helpers.h:46
const Mdouble pi
Definition: ExtendedMath.h:42
Mdouble dissipation_
linear dissipation coefficient
std::function< double(double temperature)> temperatureDependentSinterRate_
Mdouble average(Mdouble a, Mdouble b)
defines the average of two variables by the harmonic mean.
Definition: BaseSpecies.cc:85
Mdouble getLoadingStiffness() const
Returns the loading stiffness of the linear plastic-viscoelastic normal force.
Mdouble getCohesionStiffness() const
Returns the cohesive stiffness of the linear plastic-viscoelastic normal force.
virtual ~SinterNormalSpecies()
The default destructor.
void setLoadingStiffness(Mdouble loadingStiffness)
Sets the loading stiffness of the linear plastic-viscoelastic normal force.
std::string getBaseName() const
Used in Species::getName to obtain a unique name for each Species.
Mdouble getPenetrationDepthMax() const
Returns the maximum penetration depth of the linear plastic-viscoelastic normal force.
SinterNormalSpecies contains the parameters used to describe a plastic-cohesive normal force (Stefan ...
std::function< double(double temperature)> getTemperatureDependentSinterRate() const
void setUnloadingStiffnessMax(Mdouble unloadingStiffnessMax)
Sets the maximum unloading stiffness of the linear plastic-viscoelastic normal force.
void mix(SinterNormalSpecies *const S, SinterNormalSpecies *const T)
creates default values for mixed species
Defines the basic properties that a interactable object can have.
Mdouble getUnloadingStiffnessMax() const
Returns the maximum unloading stiffness of the linear plastic-viscoelastic normal force...
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
void setSinterType(SINTERTYPE sinterType)
Sets sinterRate_.
Mdouble getInverseSinterViscosity() const
Accesses inverseSinterViscosity_.
const Mdouble sqr_pi
Definition: ExtendedMath.h:44
Mdouble getSinterRate() const
Accesses sinterRate_.