MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LinearViscoelasticNormalSpecies Class Reference

LinearViscoelasticNormalSpecies contains the parameters used to describe a linear elastic-dissipative normal force. More...

#include <LinearViscoelasticNormalSpecies.h>

+ Inheritance diagram for LinearViscoelasticNormalSpecies:

Public Types

typedef
LinearViscoelasticInteraction 
InteractionType
 The correct Interaction type for this FrictionForceSpecies. More...
 

Public Member Functions

 LinearViscoelasticNormalSpecies ()
 The default constructor. More...
 
 LinearViscoelasticNormalSpecies (const LinearViscoelasticNormalSpecies &p)
 The default copy constructor. More...
 
 ~LinearViscoelasticNormalSpecies ()
 The default destructor. More...
 
void read (std::istream &is)
 Reads the species properties from an input stream. More...
 
void write (std::ostream &os) const
 Writes the species properties to an output stream. More...
 
std::string getBaseName () const
 Used in Species::getName to obtain a unique name for each Species. More...
 
Mdouble getMaximumVelocity (Mdouble radius, Mdouble mass) const
 Calculates the maximum velocity allowed for a collision of two copies of P (for higher velocities particles could pass through each other) More...
 
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. More...
 
void setRestitutionCoefficient (double eps, Mdouble mass)
 Sets disp to obtain a restitution coefficient eps for a collision of two particles of mass m. More...
 
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. More...
 
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. More...
 
void setCollisionTimeAndRestitutionCoefficient (Mdouble collisionTime, Mdouble restitutionCoefficient, Mdouble mass1, Mdouble mass2)
 Set k, disp such that is matches a given tc and eps for a collision of two different masses. More...
 
Mdouble getCollisionTime (Mdouble mass) const
 Calculates collision time for two copies of a particle of given disp, k, mass. More...
 
Mdouble getRestitutionCoefficient (Mdouble mass) const
 Calculates restitution coefficient for two copies of given disp, k, mass. More...
 
void mix (LinearViscoelasticNormalSpecies *SBase, LinearViscoelasticNormalSpecies *TBase)
 creates default values for mixed species More...
 
void setStiffness (Mdouble new_k)
 Allows the spring constant to be changed. More...
 
Mdouble getStiffness () const
 Allows the spring constant to be accessed. More...
 
void setDissipation (Mdouble dissipation)
 Allows the normal dissipation to be changed. More...
 
Mdouble getDissipation () const
 Allows the normal dissipation to be accessed. More...
 
MERCURY_DEPRECATED void setStiffnessAndDissipation (helpers::KAndDisp new_)
 Allows the spring and dissipation constants to be changed simultaneously. More...
 
- Public Member Functions inherited from BaseNormalForce
 BaseNormalForce ()
 
 BaseNormalForce (const BaseNormalForce &p)
 
bool getConstantRestitution () const
 
void setConstantRestitution (bool constantRestitution)
 
- Public Member Functions inherited from BaseForce
BaseSpeciesgetBaseSpecies () const
 
void setBaseSpecies (BaseSpecies *baseSpecies)
 

Private Attributes

Mdouble stiffness_
 (normal) spring constant More...
 
Mdouble dissipation_
 (normal) viscosity More...
 

Detailed Description

LinearViscoelasticNormalSpecies contains the parameters used to describe a linear elastic-dissipative normal force.

See LinearViscoelasticNormalInteraction::computeForce for a description of the force law.

Definition at line 38 of file LinearViscoelasticNormalSpecies.h.

Member Typedef Documentation

Constructor & Destructor Documentation

LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies ( )

The default constructor.

Definition at line 35 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, and stiffness_.

36  : BaseNormalForce()
37 {
38  stiffness_ = 0.0;
39  dissipation_ = 0.0;
40 #ifdef DEBUG_CONSTRUCTOR
41  std::cout<<"LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies() finished"<<std::endl;
42 #endif
43 }
Mdouble stiffness_
(normal) spring constant
LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies ( const LinearViscoelasticNormalSpecies p)

The default copy constructor.

Parameters
[in]thespecies that is copied

Definition at line 48 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, and stiffness_.

49  : BaseNormalForce(p)
50 {
53 #ifdef DEBUG_CONSTRUCTOR
54  std::cout<<"LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies(const LinearViscoelasticNormalSpecies &p) finished"<<std::endl;
55 #endif
56 }
Mdouble stiffness_
(normal) spring constant
LinearViscoelasticNormalSpecies::~LinearViscoelasticNormalSpecies ( )

The default destructor.

Definition at line 58 of file LinearViscoelasticNormalSpecies.cc.

59 {
60 #ifdef DEBUG_DESTRUCTOR
61  std::cout<<"LinearViscoelasticNormalSpecies::~LinearViscoelasticNormalSpecies() finished"<<std::endl;
62 #endif
63 }

Member Function Documentation

std::string LinearViscoelasticNormalSpecies::getBaseName ( ) const

Used in Species::getName to obtain a unique name for each Species.

Returns
a string containing the name of the species (minus the word "Species")

Definition at line 87 of file LinearViscoelasticNormalSpecies.cc.

88 {
89  return "LinearViscoelastic";
90 }
Mdouble LinearViscoelasticNormalSpecies::getCollisionTime ( Mdouble  mass) const

Calculates collision time for two copies of a particle of given disp, k, mass.

Parameters
[in]massmass of a typical particle

Definition at line 139 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, BaseNormalForce::getConstantRestitution(), constants::pi, mathsFunc::square(), and stiffness_.

Referenced by getRestitutionCoefficient().

140 {
141  if (getConstantRestitution()) mass = 1;
142  if (mass <= 0)
143  {
144  std::cerr << "Warning in getCollisionTime(" << mass
145  << ") mass is not set or has an unexpected value, (getCollisionTime(" << mass << "))" << std::endl;
146  }
147  if (stiffness_ <= 0)
148  {
149  std::cerr << "Warning in getCollisionTime(" << mass << ") stiffness=" << stiffness_
150  << " is not set or has an unexpected value, (getCollisionTime(" << mass << "), with stiffness="
151  << stiffness_ << ")" << std::endl;
152  }
153  if (dissipation_ < 0)
154  {
155  std::cerr << "Warning in getCollisionTime(" << mass << ") dissipation=" << dissipation_
156  << " is not set or has an unexpected value, (getCollisionTime(" << mass << "), with dissipation="
157  << dissipation_ << ")" << std::endl;
158  }
159  Mdouble tosqrt = stiffness_ / (.5 * mass) - mathsFunc::square(dissipation_ / mass);
160  if (tosqrt <= 0)
161  {
162  std::cerr << "Warning in getCollisionTime(" << mass
163  << ") values for mass, stiffness and dissipation would lead to an overdamped system, (getCollisionTime("
164  << mass << "), with stiffness=" << stiffness_ << " and dissipation=" << dissipation_ << ")"
165  << std::endl;
166  }
167  return constants::pi / std::sqrt(tosqrt);
168 }
bool getConstantRestitution() const
Mdouble stiffness_
(normal) spring constant
double Mdouble
Definition: GeneralDefine.h:34
const Mdouble pi
Definition: ExtendedMath.h:45
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
Mdouble LinearViscoelasticNormalSpecies::getDissipation ( ) const

Allows the normal dissipation to be accessed.

Definition at line 132 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_.

Referenced by LinearViscoelasticInteraction::computeNormalForce(), mix(), and setCollisionTimeAndRestitutionCoefficient().

133 {
134  return dissipation_;
135 }
Mdouble LinearViscoelasticNormalSpecies::getMaximumVelocity ( Mdouble  radius,
Mdouble  mass 
) const

Calculates the maximum velocity allowed for a collision of two copies of P (for higher velocities particles could pass through each other)

Definition at line 178 of file LinearViscoelasticNormalSpecies.cc.

References stiffness_.

179 {
180  return radius * std::sqrt(stiffness_ / (.5 * mass));
181 }
Mdouble stiffness_
(normal) spring constant
Mdouble LinearViscoelasticNormalSpecies::getRestitutionCoefficient ( Mdouble  mass) const

Calculates restitution coefficient for two copies of given disp, k, mass.

Definition at line 171 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, mathsFunc::exp(), getCollisionTime(), and BaseNormalForce::getConstantRestitution().

172 {
173  if (getConstantRestitution()) mass = 1;
174  return std::exp(-dissipation_ / mass * getCollisionTime(mass));
175 }
bool getConstantRestitution() const
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
void LinearViscoelasticNormalSpecies::mix ( LinearViscoelasticNormalSpecies SBase,
LinearViscoelasticNormalSpecies TBase 
)

creates default values for mixed species

For all parameters we assume that the harmonic mean of the parameters of the original two species is a sensible default.

Parameters
[in]S,Tthe two species whose properties are mixed to create the new species

Definition at line 267 of file LinearViscoelasticNormalSpecies.cc.

References BaseSpecies::average(), dissipation_, getDissipation(), getStiffness(), and stiffness_.

268 {
269  stiffness_ = BaseSpecies::average(S->getStiffness(), T->getStiffness());
270  dissipation_ = BaseSpecies::average(S->getDissipation(), T->getDissipation());
271 }
Mdouble stiffness_
(normal) spring constant
static Mdouble average(Mdouble a, Mdouble b)
Returns the harmonic mean of two variables.
Definition: BaseSpecies.cc:110
void LinearViscoelasticNormalSpecies::read ( std::istream &  is)

Reads the species properties from an input stream.

Parameters
[in]inputstream (typically the restart file)

Definition at line 77 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, and stiffness_.

78 {
79  std::string dummy;
80  is >> dummy >> stiffness_
81  >> dummy >> dissipation_;
82 }
Mdouble stiffness_
(normal) spring constant
void LinearViscoelasticNormalSpecies::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.

Definition at line 215 of file LinearViscoelasticNormalSpecies.cc.

References ParticleSpecies::getDensity(), BaseInteractable::getSpecies(), and BaseParticle::getVolume().

Referenced by SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficientNoDispt(), and setCollisionTimeAndRestitutionCoefficient().

216 {
217  Mdouble mass = p->getSpecies()->getDensity() * p->getVolume();
219 }
virtual Mdouble getVolume() const
Get Particle volume function, which required a reference to the Species vector. It returns the volume...
double Mdouble
Definition: GeneralDefine.h:34
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
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...
Mdouble getDensity() const
Allows density_ to be accessed.
void LinearViscoelasticNormalSpecies::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.

Sets k, disp such that it matches a given tc and eps for a collision of two copies of equal mass m

Parameters
[in]tccollision time
[in]epsrestitution coefficient
[in]massharmonic average particle mass, \(\frac{2}{1/m1+1/m2}\)

Definition at line 228 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, BaseNormalForce::getConstantRestitution(), getDissipation(), getStiffness(), INFO, mathsFunc::log(), logger, constants::pi, mathsFunc::square(), and stiffness_.

229 {
230  if (getConstantRestitution()) mass = 1;
231  if (eps == 0.0)
232  {
233  stiffness_ = .5 * mass * mathsFunc::square(constants::pi / tc);
234  dissipation_ = std::sqrt(2.0 * mass * stiffness_);
235  }
236  else
237  {
238  dissipation_ = -mass / tc * mathsFunc::log(eps);
239  stiffness_ = .5 * mass * (mathsFunc::square(constants::pi / tc)
240  + mathsFunc::square(dissipation_ / mass));
241  }
242  logger(INFO,
243  "setCollisionTimeAndRestitutionCoefficient: set stiffness to % and dissipation to % to obtain a collision time of % and a restitution coefficient of % for two particles of mass %",
244  getStiffness(), getDissipation(), tc, eps, mass);
245 }
bool getConstantRestitution() const
Mdouble stiffness_
(normal) spring constant
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble getStiffness() const
Allows the spring constant to be accessed.
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
Mdouble log(Mdouble Power)
const Mdouble pi
Definition: ExtendedMath.h:45
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
void LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient ( Mdouble  collisionTime,
Mdouble  restitutionCoefficient,
Mdouble  mass1,
Mdouble  mass2 
)

Set k, disp such that is matches a given tc and eps for a collision of two different masses.

Recall the resitution constant is a function of k, disp and the mass of each particle in the collision See also 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. Recall the resitution constant is a function of k, disp and the mass of each particle in the collision See also setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, Mdouble mass)

Parameters
[in]collisiontime

Definition at line 253 of file LinearViscoelasticNormalSpecies.cc.

References setCollisionTimeAndRestitutionCoefficient().

256 {
257  Mdouble reduced_mass = mass1 * mass2 / (mass1 + mass2);
258  setCollisionTimeAndRestitutionCoefficient(collisionTime, restitutionCoefficient, 2.0 * reduced_mass);
259 }
double Mdouble
Definition: GeneralDefine.h:34
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...
void LinearViscoelasticNormalSpecies::setDissipation ( Mdouble  dissipation)

Allows the normal dissipation to be changed.

Definition at line 118 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_.

Referenced by setStiffnessAndDissipation().

119 {
120  if (dissipation >= 0)
121  {
122  dissipation_ = dissipation;
123  }
124  else
125  {
126  std::cerr << "Error in setDissipation(" << dissipation << ")" << std::endl;
127  exit(-1);
128  }
129 }
void LinearViscoelasticNormalSpecies::setRestitutionCoefficient ( double  eps,
Mdouble  mass 
)

Sets disp to obtain a restitution coefficient eps for a collision of two particles of mass m.

Sets k, disp such that it matches a given tc and eps for a collision of two copies of P

Parameters
[in]stiffnessstiffness
[in]epsrestitution coefficient
[in]masseffective particle mass, \(\frac{2}{1/m1+1/m2}\)

Definition at line 202 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, BaseNormalForce::getConstantRestitution(), getStiffness(), mathsFunc::log(), constants::sqr_pi, and mathsFunc::square().

Referenced by setStiffnessAndRestitutionCoefficient().

203 {
204  if (getConstantRestitution()) mass = 1;
205  if (eps == 0.0) {
206  dissipation_ = std::sqrt(2.0 * mass * getStiffness());
207  } else {
208  const Mdouble logEps = log(eps);
209  dissipation_ = -std::sqrt(2.0 * mass * getStiffness()
210  / (constants::sqr_pi + mathsFunc::square(logEps))) * logEps;
211  }
212 }
bool getConstantRestitution() const
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getStiffness() const
Allows the spring constant to be accessed.
Mdouble log(Mdouble Power)
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
const Mdouble sqr_pi
Definition: ExtendedMath.h:47
void LinearViscoelasticNormalSpecies::setStiffness ( Mdouble  new_k)

Allows the spring constant to be changed.

Definition at line 93 of file LinearViscoelasticNormalSpecies.cc.

References stiffness_.

Referenced by setStiffnessAndDissipation().

94 {
95  if (new_k >= 0)
96  stiffness_ = new_k;
97  else
98  {
99  std::cerr << "Error in set_k" << std::endl;
100  exit(-1);
101  }
102 }
Mdouble stiffness_
(normal) spring constant
void LinearViscoelasticNormalSpecies::setStiffnessAndDissipation ( helpers::KAndDisp  new_)

Allows the spring and dissipation constants to be changed simultaneously.

Definition at line 111 of file LinearViscoelasticNormalSpecies.cc.

References helpers::KAndDisp::disp, helpers::KAndDisp::k, setDissipation(), and setStiffness().

112 {
113  setStiffness(new_.k);
114  setDissipation(new_.disp);
115 }
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Mdouble disp
Definition: Helpers.h:49
void LinearViscoelasticNormalSpecies::setStiffnessAndRestitutionCoefficient ( Mdouble  stiffness,
Mdouble  eps,
Mdouble  mass 
)

Sets k, disp such that it matches a given tc and eps for a collision of two copies of P.

Sets k, disp such that it matches a given tc and eps for a collision of two copies of P

Parameters
[in]stiffnessstiffness
[in]epsrestitution coefficient
[in]harmonicmean of particle masses, \(\frac{2}{1/m1+1/m2}\)

Definition at line 189 of file LinearViscoelasticNormalSpecies.cc.

References BaseNormalForce::getConstantRestitution(), setRestitutionCoefficient(), and stiffness_.

190 {
191  if (getConstantRestitution()) mass = 1;
192  stiffness_ = stiffness;
193  setRestitutionCoefficient(eps, mass);
194 }
bool getConstantRestitution() const
Mdouble stiffness_
(normal) spring constant
void setRestitutionCoefficient(double eps, Mdouble mass)
Sets disp to obtain a restitution coefficient eps for a collision of two particles of mass m...
void LinearViscoelasticNormalSpecies::write ( std::ostream &  os) const

Writes the species properties to an output stream.

Parameters
[out]outputstream (typically the restart file)

Definition at line 68 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, and stiffness_.

69 {
70  os << " stiffness " << stiffness_
71  << " dissipation " << dissipation_;
72 }
Mdouble stiffness_
(normal) spring constant

Member Data Documentation


The documentation for this class was generated from the following files: