MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SlidingFrictionSpecies.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 #include <cmath>
27 #include "SlidingFrictionSpecies.h"
29 #include "Species/BaseSpecies.h"
31 
32 class BaseParticle;
33 
34 class BaseInteractable;
35 
37 {
42  isSuperquadricSpecies_ = false;
43 #ifdef DEBUG_CONSTRUCTOR
44  std::cout<<"SlidingFrictionSpecies::SlidingFrictionSpecies() finished"<<std::endl;
45 #endif
46 }
47 
52 {
58 #ifdef DEBUG_CONSTRUCTOR
59  std::cout<<"SlidingFrictionSpecies::SlidingFrictionSpecies(const SlidingFrictionSpecies &p) finished"<<std::endl;
60 #endif
61 }
62 
64 {
65 #ifdef DEBUG_DESTRUCTOR
66  std::cout<<"SlidingFrictionSpecies::~SlidingFrictionSpecies() finished"<<std::endl;
67 #endif
68 }
69 
73 void SlidingFrictionSpecies::write(std::ostream& os) const
74 {
75  //BaseSpecies::write(os);
76  os << " slidingStiffness " << slidingStiffness_;
77  os << " slidingDissipation " << slidingDissipation_;
78  os << " slidingFrictionCoefficient " << slidingFrictionCoefficient_;
79  os << " slidingFrictionCoefficientStatic " << slidingFrictionCoefficientStatic_;
80 }
81 
85 void SlidingFrictionSpecies::read(std::istream& is)
86 {
87  //BaseSpecies::read(is);
88  std::string dummy;
89  is >> dummy >> slidingStiffness_;
90  is >> dummy >> slidingDissipation_;
91  is >> dummy >> slidingFrictionCoefficient_;
92  is >> dummy >> slidingFrictionCoefficientStatic_;
93 }
94 
99 {
100  return "SlidingFriction";
101 }
102 
105 {
106  if (new_kt >= 0)
107  {
108  slidingStiffness_ = new_kt;
109  }
110  else
111  {
112  std::cerr << "Error in setSlidingStiffness" << std::endl;
113  exit(-1);
114  }
115 }
116 
119 {
120  return slidingStiffness_;
121 }
122 
125 {
126  if (new_dispt >= 0)
127  slidingDissipation_ = new_dispt;
128  else
129  {
130  std::cerr << "Error in setSlidingDissipation" << std::endl;
131  exit(-1);
132  }
133 }
134 
137 {
138  return slidingDissipation_;
139 }
140 
142 //mu has to be set to allow tangential forces (sets dispt=disp as default)
144 {
145  if (new_mu >= 0)
146  {
149  }
150  else
151  {
152  std::cerr << "Error in setSlidingFrictionCoefficient" << std::endl;
153  exit(-1);
154  }
155 }
156 
159 {
161 }
162 
165 {
166  if (new_mu >= 0)
167  {
169  }
170  else
171  {
172  std::cerr << "Error in setSlidingFrictionCoefficientStatic" << std::endl;
173  exit(-1);
174  }
175 }
176 
179 {
181 }
182 
190 {
191  return true;
192 }
193 
201 {
208 }
209 
212  Mdouble beta, Mdouble mass)
213 {
214  Mdouble stiffness;
215  //the dynamic cast is needed to check if the normal force species is LinearViscoelasticSpecies; otherwise this function cannot be used
217  if (species != nullptr)
218  {
219  species->setCollisionTimeAndRestitutionCoefficient(tc, eps, mass);
220  stiffness = species->getStiffness();
221  }
222  else
223  {
225  if (species2 != nullptr)
226  {
227  species2->setDissipation(-mass / tc * std::log(eps));
228  species2->setLoadingStiffness(.5 * mass * (mathsFunc::square(constants::pi / tc) +
229  mathsFunc::square(species2->getDissipation()) / mass));
230  stiffness = species2->getLoadingStiffness();
231  }
232  else
233  {
234  logger(ERROR,
235  "SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient only works for LinearViscoelasticSlidingFrictionSpecies or LinearPlasticViscoelasticSlidingFrictionSpecies"
236  );
237  }
238  }
239 
240  // from: N. G. Deen et. al. https://doi.org/10.1016/j.ces.2006.08.014
241  // eq. 43 and 30
242  setSlidingStiffness(2.0 / 7.0 * stiffness * (mathsFunc::square(constants::pi) + mathsFunc::square(log(beta))) /
244  if (beta != 0.0)
245  setSlidingDissipation(-2 * log(beta) * sqrt(1.0 / 7.0 * mass * getSlidingStiffness() /
247  else
248  setSlidingDissipation(2. * sqrt(1.0 / 7.0 * mass * getSlidingStiffness()));
249 }
250 
252 void
254  Mdouble beta, Mdouble mass)
255 {
256  //the dynamic cast is needed to check if the normal force species is LinearViscoelasticSpecies; otherwise this function cannot be used
258  if (species == nullptr)
259  {
260  std::cerr
261  << "SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient only works for LinearViscoelasticSlidingFrictionSpecies"
262  << std::endl;
263  exit(-1);
264  }
265  species->setCollisionTimeAndRestitutionCoefficient(tc, eps, mass);
266  // from: V. Becker et. al. https://doi.org/10.1103/PhysRevE.77.011304
267  // eq. 56
268  setSlidingStiffness(2.0 / 7.0 * species->getStiffness() * mathsFunc::square(acos(-beta) / constants::pi));
270 }
271 
272 void SlidingFrictionSpecies::setIsSuperquadricSpecies(bool isSuperquadricSpecies)
273 {
274  SlidingFrictionSpecies::isSuperquadricSpecies_ = isSuperquadricSpecies;
275 }
276 
278 {
279  return isSuperquadricSpecies_;
280 }
Mdouble slidingStiffness_
tangential stiffness.
void read(std::istream &is)
Reads the species properties from an input stream.
void setCollisionTimeAndNormalAndTangentialRestitutionCoefficientNoDispt(Mdouble tc, Mdouble eps, Mdouble beta, Mdouble mass)
Sets k, disp, kt (with dispt=0) such that it matches a given tc and eps for a collision of two partic...
Mdouble getSlidingFrictionCoefficientStatic() const
Allows the static Coulomb friction coefficient to be accessed.
void setIsSuperquadricSpecies(bool isSuperquadricSpecies)
bool getUseAngularDOFs() const override
Returns true if torques have to be calculated.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getStiffness() const
Allows the spring constant to be accessed.
Mdouble slidingFrictionCoefficientStatic_
static Coulomb friction coefficient (by default set equal to mu)
Mdouble beta(Mdouble z, Mdouble w)
This is the beta function, returns the approximation based on cmath's implementation of ln(gamma) ...
void mix(SlidingFrictionSpecies *S, SlidingFrictionSpecies *T)
creates default values for mixed species
Mdouble log(Mdouble Power)
void setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, BaseParticle *p)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of particle p...
virtual std::string getBaseName() const
Used in Species::getName to obtain a unique name for each Species.
LinearViscoelasticNormalSpecies contains the parameters used to describe a linear elastic-dissipative...
const Mdouble pi
Definition: ExtendedMath.h:45
void setSlidingFrictionCoefficientStatic(Mdouble new_mu)
Allows the static Coulomb friction coefficient to be changed.
~SlidingFrictionSpecies()
The default destructor.
static Mdouble average(Mdouble a, Mdouble b)
Returns the harmonic mean of two variables.
Definition: BaseSpecies.cc:110
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
void setLoadingStiffness(Mdouble loadingStiffness)
Sets the loading stiffness of the linear plastic-viscoelastic normal force.
void setSlidingStiffness(Mdouble new_kt)
Allows the spring constant to be changed.
void setSlidingFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb friction coefficient to be changed; also sets mu_s by default...
void setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(Mdouble tc, Mdouble eps, Mdouble beta, Mdouble mass)
Sets k, disp, kt, dispt such that it matches a given tc and eps for a collision of two particles of m...
void setDissipation(Mdouble dissipation)
Sets the linear dissipation coefficient of the linear plastic-viscoelastic normal force...
Mdouble slidingDissipation_
tangential dissipation coefficient.
SlidingFrictionSpecies contains the parameters used to describe sliding friction. ...
void write(std::ostream &os) const
Writes the species properties to an output stream.
Mdouble getSlidingStiffness() const
Allows the spring constant to be accessed.
Mdouble getSlidingDissipation() const
Allows the tangential viscosity to be accessed.
Defines the basic properties that a interactable object can have.
void setSlidingDissipation(Mdouble new_dispt)
Allows the tangential viscosity to be changed.
LinearPlasticViscoelasticNormalSpecies contains the parameters used to describe a plastic-cohesive no...
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
SlidingFrictionSpecies()
The default constructor.
Mdouble slidingFrictionCoefficient_
(dynamic) Coulomb friction coefficient
Mdouble getSlidingFrictionCoefficient() const
Allows the (dynamic) Coulomb friction coefficient to be accessed.
Mdouble getLoadingStiffness() const
Returns the loading stiffness of the linear plastic-viscoelastic normal force.