MercuryDPM  Beta
 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 {
105  return elasticModulus_;
106 }
107 
110 {
111  if (dissipation >= 0)
112  {
113  dissipation_ = dissipation;
114  }
115  else
116  {
117  std::cerr << "Error in setDissipation(" << dissipation << ")" << std::endl;
118  exit(-1);
119  }
120 }
121 
124 {
125  return dissipation_;
126 }
127 
129 //Mdouble HertzianViscoelasticNormalSpecies::getCollisionTime(Mdouble mass)
130 //{
131 // if (mass <= 0)
132 // {
133 // std::cerr << "Error in getCollisionTime(Mdouble mass) mass is not set or has an unexpected value, (getCollisionTime(" << mass << "))" << std::endl;
134 // exit(-1);
135 // }
136 // if (elasticModulus_ <= 0)
137 // {
138 // std::cerr << "Error in getCollisionTime(Mdouble mass) stiffness is not set or has an unexpected value, (getCollisionTime(" << mass << "), with stiffness=" << elasticModulus_ << ")" << std::endl;
139 // exit(-1);
140 // }
141 // if (dissipation_ < 0)
142 // {
143 // std::cerr << "Error in getCollisionTime(Mdouble mass) dissipation is not set or has an unexpected value, (getCollisionTime(" << mass << "), with dissipation=" << dissipation_ << ")" << std::endl;
144 // exit(-1);
145 // }
146 // Mdouble tosqrt = elasticModulus_ / (.5 * mass) - mathsFunc::square(dissipation_ / mass);
147 // if (tosqrt <= 0)
148 // {
149 // 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;
150 // exit(-1);
151 // }
152 // return constants::pi / std::sqrt(tosqrt);
153 //}
154 //
156 //Mdouble HertzianViscoelasticNormalSpecies::getRestitutionCoefficient(Mdouble mass)
157 //{
158 // return std::exp(-dissipation_ / mass * getCollisionTime(mass));
159 //}
160 //
162 //Mdouble HertzianViscoelasticNormalSpecies::getMaximumVelocity(Mdouble radius, Mdouble mass)
163 //{
164 // return radius * std::sqrt(elasticModulus_ / (.5 * mass));
165 //}
166 //
168 //void HertzianViscoelasticNormalSpecies::setStiffnessAndRestitutionCoefficient(Mdouble k_, Mdouble eps, Mdouble mass)
169 //{
170 // elasticModulus_ = k_;
171 // dissipation_ = -std::sqrt(2.0 * mass * elasticModulus_ / (constants::sqr_pi + mathsFunc::square(log(eps)))) * log(eps);
172 //}
173 //
175 //void HertzianViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, Mdouble mass)
176 //{
177 // dissipation_ = -mass / tc * std::log(eps);
178 // elasticModulus_ = .5 * mass * (mathsFunc::square(constants::pi / tc) + mathsFunc::square(dissipation_ / mass));
179 //}
180 //
184 //void HertzianViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(Mdouble collisionTime, Mdouble restitutionCoefficient, Mdouble mass1, Mdouble mass2)
185 //{
186 // Mdouble reduced_mass = mass1 * mass2 / (mass1 + mass2);
187 // setCollisionTimeAndRestitutionCoefficient(collisionTime, restitutionCoefficient, 2.0 * reduced_mass);
188 //}
189 
196 {
199 }
void setElasticModulus(Mdouble elasticModulus)
Allows the spring constant to be changed.
Mdouble getElasticModulus() const
Allows the spring constant to be accessed.
void mix(HertzianViscoelasticNormalSpecies *const SBase, HertzianViscoelasticNormalSpecies *const TBase)
Calculates collision time for two copies of a particle of given disp, k, mass.
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.
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
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...
virtual ~HertzianViscoelasticNormalSpecies()
The default destructor.