MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HertzianViscoelasticNormalSpecies.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 
28 #include<cmath>
30 #include <Logger.h>
31 
32 class BaseParticle;
33 class BaseInteractable;
34 
36 {
37  elasticModulus_ = 0;
38  dissipation_ = 0;
39 #ifdef DEBUG_CONSTRUCTOR
40  std::cout<<"HertzianViscoelasticNormalSpecies::HertzianViscoelasticNormalSpecies() finished"<<std::endl;
41 #endif
42 }
43 
48 {
51 #ifdef DEBUG_CONSTRUCTOR
52  std::cout<<"HertzianViscoelasticNormalSpecies::HertzianViscoelasticNormalSpecies(const HertzianViscoelasticNormalSpecies &p) finished"<<std::endl;
53 #endif
54 }
55 
57 {
58 #ifdef DEBUG_DESTRUCTOR
59  std::cout<<"HertzianViscoelasticNormalSpecies::~HertzianViscoelasticNormalSpecies() finished"<<std::endl;
60 #endif
61 }
62 
66 void HertzianViscoelasticNormalSpecies::write(std::ostream& os) const
67  {
68  os << " stiffness " << elasticModulus_
69  << " dissipation " << dissipation_;
70 }
71 
76 {
77  std::string dummy;
78  is >> dummy >> elasticModulus_
79  >> dummy >> dissipation_;
80 }
81 
86 {
87  return "HertzianViscoelastic";
88 }
89 
92 {
93  if (elasticModulus >= 0)
94  elasticModulus_ = elasticModulus;
95  else
96  {
97  std::cerr << "Error in setElasticModulus" << std::endl;
98  exit(-1);
99  }
100 }
101 
104  // Here is a very nice paper describing contact modelling
105  // http://people.ds.cam.ac.uk/jae1001/CUS/research/pfizer/Antypov_Elliott_EPL_2011.pdf
106  // see also: https://answers.launchpad.net/yade/+question/235934
107  if (elasticModulus >= 0.0 && rest > 0.0 && rest <= 1.0)
108  {
109  elasticModulus_ = elasticModulus;
110  Mdouble logRestSquared = log(rest)*log(rest);
111  dissipation_ = sqrt(5.0 * logRestSquared / (logRestSquared + constants::sqr_pi));
112  logger(INFO,"Dissipation % set to match restitution coefficient % logE % sqrPi %",dissipation_,rest,log(rest),constants::sqr_pi);
113  }
114  else
115  {
116  logger(ERROR,"Error in setElasticModulusAndRestitutionCoefficient");
117  }
118 }
119 
122 {
123  return elasticModulus_;
124 }
125 
128 {
129  if (dissipation >= 0)
130  {
131  dissipation_ = dissipation;
132  }
133  else
134  {
135  std::cerr << "Error in setDissipation(" << dissipation << ")" << std::endl;
136  exit(-1);
137  }
138 }
139 
142 {
143  return dissipation_;
144 }
145 
147 //Mdouble HertzianViscoelasticNormalSpecies::getCollisionTime(Mdouble mass)
148 //{
149 // if (mass <= 0)
150 // {
151 // std::cerr << "Error in getCollisionTime(Mdouble mass) mass is not set or has an unexpected value, (getCollisionTime(" << mass << "))" << std::endl;
152 // exit(-1);
153 // }
154 // if (elasticModulus_ <= 0)
155 // {
156 // std::cerr << "Error in getCollisionTime(Mdouble mass) stiffness is not set or has an unexpected value, (getCollisionTime(" << mass << "), with stiffness=" << elasticModulus_ << ")" << std::endl;
157 // exit(-1);
158 // }
159 // if (dissipation_ < 0)
160 // {
161 // std::cerr << "Error in getCollisionTime(Mdouble mass) dissipation is not set or has an unexpected value, (getCollisionTime(" << mass << "), with dissipation=" << dissipation_ << ")" << std::endl;
162 // exit(-1);
163 // }
164 // Mdouble tosqrt = elasticModulus_ / (.5 * mass) - mathsFunc::square(dissipation_ / mass);
165 // if (tosqrt <= 0)
166 // {
167 // std::cerr << "Error in getCollisionTime(Mdouble mass) values for mass, stiffness and dissipation would lead to an overdamped system, (getCollisionTime(" << mass << "), with stiffness=" << elasticModulus_ << " and dissipation=" << dissipation_ << ")" << std::endl;
168 // exit(-1);
169 // }
170 // return constants::pi / std::sqrt(tosqrt);
171 //}
172 //
174 //Mdouble HertzianViscoelasticNormalSpecies::getRestitutionCoefficient(Mdouble mass)
175 //{
176 // return std::exp(-dissipation_ / mass * getCollisionTime(mass));
177 //}
178 //
180 //Mdouble HertzianViscoelasticNormalSpecies::getMaximumVelocity(Mdouble radius, Mdouble mass)
181 //{
182 // return radius * std::sqrt(elasticModulus_ / (.5 * mass));
183 //}
184 //
186 //void HertzianViscoelasticNormalSpecies::setStiffnessAndRestitutionCoefficient(Mdouble k_, Mdouble eps, Mdouble mass)
187 //{
188 // elasticModulus_ = k_;
189 // dissipation_ = -std::sqrt(2.0 * mass * elasticModulus_ / (constants::sqr_pi + mathsFunc::square(log(eps)))) * log(eps);
190 //}
191 //
193 //void HertzianViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, Mdouble mass)
194 //{
195 // dissipation_ = -mass / tc * std::log(eps);
196 // elasticModulus_ = .5 * mass * (mathsFunc::square(constants::pi / tc) + mathsFunc::square(dissipation_ / mass));
197 //}
198 //
202 //void HertzianViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(Mdouble collisionTime, Mdouble restitutionCoefficient, Mdouble mass1, Mdouble mass2)
203 //{
204 // Mdouble reduced_mass = mass1 * mass2 / (mass1 + mass2);
205 // setCollisionTimeAndRestitutionCoefficient(collisionTime, restitutionCoefficient, 2.0 * reduced_mass);
206 //}
207 
214 {
217 }
218 
219 Mdouble HertzianViscoelasticNormalSpecies::getCollisionTime(Mdouble particleDiameter, Mdouble particleDensity, Mdouble relativeVelocity) const {
220  // Here is a very nice paper describing contact modelling
221  // http://people.ds.cam.ac.uk/jae1001/CUS/research/pfizer/Antypov_Elliott_EPL_2011.pdf
222  //caution: this function assumes the contact is elastic (no dissipation)
223  //Mdouble omega0 = 2.0/constants::sqrt_pi*sqrt(getElasticModulus()/particleDensity)/relativeVelocity;
224  //Mdouble omega1 = sqrt(omega0*omega0-getDissipation()*getDissipation());
225  return 2.214*pow(mathsFunc::square(particleDensity/getElasticModulus())/relativeVelocity,0.2)*particleDiameter;
226 }
227 
228 
void setElasticModulus(Mdouble elasticModulus)
Allows the spring constant to be changed.
Mdouble getElasticModulus() const
Allows the spring constant to be accessed.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void mix(HertzianViscoelasticNormalSpecies *const SBase, HertzianViscoelasticNormalSpecies *const TBase)
Calculates collision time for two copies of a particle of given disp, k, mass.
Mdouble getCollisionTime(Mdouble particleDiameter, Mdouble particleDensity, Mdouble relativeVelocity) const
Used in Species::getName to obtain a unique name for each Species.
void read(std::istream &is)
Reads the species properties from an input stream.
double Mdouble
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:97
T square(T val)
squares a number
Definition: ExtendedMath.h:91
HertzianViscoelasticNormalSpecies()
The default constructor.
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
Mdouble average(Mdouble a, Mdouble b)
defines the average of two variables by the harmonic mean.
Definition: BaseSpecies.cc:85
void setElasticModulusAndRestitutionCoefficient(Mdouble elasticModulus, Mdouble rest)
Allows the spring constant to be changed.
Mdouble dissipation_
normal dissipation constant
std::string getBaseName() const
Used in Species::getName to obtain a unique name for each Species.
Defines the basic properties that a interactable object can have.
void write(std::ostream &os) const
Writes the species properties to an output stream.
HertzianViscoelasticNormalSpecies contains the parameters used to describe a Hertzian normal force (T...
const Mdouble sqr_pi
Definition: ExtendedMath.h:44
virtual ~HertzianViscoelasticNormalSpecies()
The default destructor.