MercuryDPM  Alpha
 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-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 #include <cmath>
27 #include "SlidingFrictionSpecies.h"
29 #include "Species/BaseSpecies.h"
31 
32 class BaseParticle;
33 class BaseInteractable;
34 
36 {
41 #ifdef DEBUG_CONSTRUCTOR
42  std::cout<<"SlidingFrictionSpecies::SlidingFrictionSpecies() finished"<<std::endl;
43 #endif
44 }
45 
50 {
55 #ifdef DEBUG_CONSTRUCTOR
56  std::cout<<"SlidingFrictionSpecies::SlidingFrictionSpecies(const SlidingFrictionSpecies &p) finished"<<std::endl;
57 #endif
58 }
59 
61 {
62 #ifdef DEBUG_DESTRUCTOR
63  std::cout<<"SlidingFrictionSpecies::~SlidingFrictionSpecies() finished"<<std::endl;
64 #endif
65 }
66 
70 void SlidingFrictionSpecies::write(std::ostream& os) const
71  {
72  //BaseSpecies::write(os);
73  os << " slidingStiffness " << slidingStiffness_;
74  os << " slidingDissipation " << slidingDissipation_;
75  os << " slidingFrictionCoefficient " << slidingFrictionCoefficient_;
76  os << " slidingFrictionCoefficientStatic " << slidingFrictionCoefficientStatic_;
77 }
78 
82 void SlidingFrictionSpecies::read(std::istream& is)
83 {
84  //BaseSpecies::read(is);
85  std::string dummy;
86  is >> dummy >> slidingStiffness_;
87  is >> dummy >> slidingDissipation_;
88  is >> dummy >> slidingFrictionCoefficient_;
89  is >> dummy >> slidingFrictionCoefficientStatic_;
90 }
91 
96 {
97  return "SlidingFriction";
98 }
99 
102 {
103  if (new_kt >= 0)
104  {
105  slidingStiffness_ = new_kt;
106  }
107  else
108  {
109  std::cerr << "Error in setSlidingStiffness" << std::endl;
110  exit(-1);
111  }
112 }
113 
116 {
117  return slidingStiffness_;
118 }
119 
122 {
123  if (new_dispt >= 0)
124  slidingDissipation_ = new_dispt;
125  else
126  {
127  std::cerr << "Error in setSlidingDissipation" << std::endl;
128  exit(-1);
129  }
130 }
133 {
134  return slidingDissipation_;
135 }
136 
138 //mu has to be set to allow tangential forces (sets dispt=disp as default)
140 {
141  if (new_mu >= 0)
142  {
145  }
146  else
147  {
148  std::cerr << "Error in setSlidingFrictionCoefficient" << std::endl;
149  exit(-1);
150  }
151 }
152 
155 {
157 }
158 
161 {
162  if (new_mu >= 0)
163  {
165  }
166  else
167  {
168  std::cerr << "Error in setSlidingFrictionCoefficientStatic" << std::endl;
169  exit(-1);
170  }
171 }
172 
175 {
177 }
178 
186 {
187  return true;
188 }
189 
197 {
198  slidingStiffness_ = average(SFrictional->getSlidingStiffness(), TFrictional->getSlidingStiffness());
202 }
203 
206 {
207  Mdouble stiffness;
208  //the dynamic cast is needed to check if the normal force species is LinearViscoelasticSpecies; otherwise this function cannot be used
210  if (species!= nullptr)
211  {
212  species->setCollisionTimeAndRestitutionCoefficient(tc, eps, mass);
213  stiffness = species->getStiffness();
214  }
215  else
216  {
218  if (species2 != nullptr)
219  {
220  species2->setDissipation(-mass / tc * std::log(eps));
221  species2->setLoadingStiffness(.5 * mass * (mathsFunc::square(constants::pi/tc) + mathsFunc::square(species2->getDissipation()) /mass));
222  stiffness = species2->getLoadingStiffness();
223  }
224  else
225  {
226  std::cerr << "SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient only works for LinearViscoelasticSlidingFrictionSpecies or LinearPlasticViscoelasticSlidingFrictionSpecies" << std::endl;
227  exit(-1);
228  }
229  }
230 
231  //from Deen...Kuipers2006, eq. 43 and 30
233  if (beta != 0.0)
234  setSlidingDissipation(-2 * log(beta) * sqrt(1.0 / 7.0 * mass * getSlidingStiffness() / (mathsFunc::square(constants::pi) + mathsFunc::square(log(beta)))));
235  else
236  setSlidingDissipation(2. * sqrt(1.0 / 7.0 * mass * getSlidingStiffness()));
237 }
238 
241 {
242  //the dynamic cast is needed to check if the normal force species is LinearViscoelasticSpecies; otherwise this function cannot be used
244  if (species == nullptr)
245  {
246  std::cerr << "SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient only works for LinearViscoelasticSlidingFrictionSpecies" << std::endl;
247  exit(-1);
248  }
249  species->setCollisionTimeAndRestitutionCoefficient(tc, eps, mass);
250  //from BeckerSchwagerPoeschel2008, eq. 56
251  setSlidingStiffness(2.0 / 7.0 * species->getStiffness() * mathsFunc::square(acos(-beta) / constants::pi));
253 }
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...
void setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, Mdouble mass)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of equal mass m...
Mdouble getSlidingFrictionCoefficientStatic() const
Allows the static Coulomb friction coefficient to be accessed.
Mdouble getStiffness() const
Allows the spring constant to be accessed.
void mix(SlidingFrictionSpecies *const S, SlidingFrictionSpecies *const T)
creates default values for mixed species
Mdouble slidingFrictionCoefficientStatic_
static Coulomb friction coefficient (by default set equal to mu)
double Mdouble
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:97
T square(T val)
squares a number
Definition: ExtendedMath.h:91
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...
bool getUseAngularDOFs() const
Returns true if torques have to be calculated.
const Mdouble pi
Definition: ExtendedMath.h:42
void setSlidingFrictionCoefficientStatic(Mdouble new_mu)
Allows the static Coulomb friction coefficient to be changed.
virtual ~SlidingFrictionSpecies()
The default destructor.
Mdouble average(Mdouble a, Mdouble b)
defines the average of two variables by the harmonic mean.
Definition: BaseSpecies.cc:85
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...
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.