revision: v0.14
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)
 
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.

Member Typedef Documentation

◆ InteractionType

The correct Interaction type for this FrictionForceSpecies.

Constructor & Destructor Documentation

◆ LinearViscoelasticNormalSpecies() [1/2]

LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies ( )

The default constructor.

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 }

References dissipation_, and stiffness_.

◆ LinearViscoelasticNormalSpecies() [2/2]

LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies ( const LinearViscoelasticNormalSpecies p)

The default copy constructor.

Parameters
[in]thespecies that is copied
49  : BaseNormalForce(p)
50 {
53 #ifdef DEBUG_CONSTRUCTOR
54  std::cout<<"LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies(const LinearViscoelasticNormalSpecies &p) finished"<<std::endl;
55 #endif
56 }

References dissipation_, and stiffness_.

◆ ~LinearViscoelasticNormalSpecies()

LinearViscoelasticNormalSpecies::~LinearViscoelasticNormalSpecies ( )

The default destructor.

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

Member Function Documentation

◆ getBaseName()

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")
88 {
89  return "LinearViscoelastic";
90 }

◆ getCollisionTime()

Mdouble LinearViscoelasticNormalSpecies::getCollisionTime ( Mdouble  mass) const

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

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

Parameters
[in]massmass of a typical particle
138 {
139  if (getConstantRestitution()) mass = 1;
140  if (mass <= 0)
141  {
142  logger(ERROR, "Warning in getCollisionTime(%) mass is not set or has an unexpected value, "
143  "(getCollisionTime(%)", mass, mass);
144  }
145  if (stiffness_ <= 0)
146  {
147  logger(ERROR, "Error in getCollisionTime(%) stiffness=% is not set or has an unexpected value "
148  "(getCollisionTime(%), with stiffness=%)",
149  mass, stiffness_, mass, stiffness_);
150  }
151  if (dissipation_ < 0)
152  {
153  logger(ERROR, "Error in getCollisionTime(%) dissipation=% is not set or has an unexpected value "
154  "(getCollisionTime(%), with dissipation=%)",
155  mass, dissipation_, mass, dissipation_);
156  }
157  Mdouble tosqrt = stiffness_ / (.5 * mass) - mathsFunc::square(dissipation_ / mass);
158  if (tosqrt <= 0)
159  {
160  logger(ERROR, "Warning in getCollisionTime(%) values for mass, stiffness and dissipation would lead to an "
161  "overdamped system, (getCollisionTime(%), with stiffness=% and dissipation=%",
162  mass, mass, stiffness_, dissipation_);
163  }
164  return constants::pi / std::sqrt(tosqrt);
165 }

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

Referenced by getRestitutionCoefficient().

◆ getDissipation()

Mdouble LinearViscoelasticNormalSpecies::getDissipation ( ) const

Allows the normal dissipation to be accessed.

131 {
132  return dissipation_;
133 }

References dissipation_.

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

◆ getMaximumVelocity()

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)

176 {
177  return radius * std::sqrt(stiffness_ / (.5 * mass));
178 }

References stiffness_.

◆ getRestitutionCoefficient()

Mdouble LinearViscoelasticNormalSpecies::getRestitutionCoefficient ( Mdouble  mass) const

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

169 {
170  if (getConstantRestitution()) mass = 1;
171  return std::exp(-dissipation_ / mass * getCollisionTime(mass));
172 }

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

◆ getStiffness()

◆ mix()

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
265 {
266  stiffness_ = BaseSpecies::average(S->getStiffness(), T->getStiffness());
267  dissipation_ = BaseSpecies::average(S->getDissipation(), T->getDissipation());
268 }

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

◆ read()

void LinearViscoelasticNormalSpecies::read ( std::istream &  is)

Reads the species properties from an input stream.

Parameters
[in]inputstream (typically the restart file)
78 {
79  std::string dummy;
80  is >> dummy >> stiffness_
81  >> dummy >> dissipation_;
82 }

References dissipation_, and stiffness_.

◆ setCollisionTimeAndRestitutionCoefficient() [1/3]

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
253 {
254  Mdouble reduced_mass = mass1 * mass2 / (mass1 + mass2);
255  setCollisionTimeAndRestitutionCoefficient(collisionTime, restitutionCoefficient, 2.0 * reduced_mass);
256 }

References setCollisionTimeAndRestitutionCoefficient().

◆ setCollisionTimeAndRestitutionCoefficient() [2/3]

void LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient ( Mdouble  tc,
Mdouble  eps,
BaseParticle p 
)

◆ setCollisionTimeAndRestitutionCoefficient() [3/3]

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}\)
226 {
227  if (getConstantRestitution()) mass = 1;
228  if (eps == 0.0)
229  {
230  stiffness_ = .5 * mass * mathsFunc::square(constants::pi / tc);
231  dissipation_ = std::sqrt(2.0 * mass * stiffness_);
232  }
233  else
234  {
235  dissipation_ = -mass / tc * mathsFunc::log(eps);
236  stiffness_ = .5 * mass * (mathsFunc::square(constants::pi / tc)
237  + mathsFunc::square(dissipation_ / mass));
238  }
239  logger(INFO,
240  "setCollisionTimeAndRestitutionCoefficient: set stiffness to % and dissipation to % to obtain a collision time of % and a restitution coefficient of % for two particles of mass %",
241  getStiffness(), getDissipation(), tc, eps, mass);
242 }

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

◆ setDissipation()

void LinearViscoelasticNormalSpecies::setDissipation ( Mdouble  dissipation)

Allows the normal dissipation to be changed.

118 {
119  if (dissipation >= 0)
120  {
121  dissipation_ = dissipation;
122  }
123  else
124  {
125  logger(ERROR, "Error in setDissipation(%)", dissipation);
126  }
127 }

References dissipation_, ERROR, and logger.

Referenced by setStiffnessAndDissipation().

◆ setRestitutionCoefficient()

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}\)
200 {
201  if (getConstantRestitution()) mass = 1;
202  if (eps == 0.0) {
203  dissipation_ = std::sqrt(2.0 * mass * getStiffness());
204  } else {
205  const Mdouble logEps = log(eps);
206  dissipation_ = -std::sqrt(2.0 * mass * getStiffness()
207  / (constants::sqr_pi + mathsFunc::square(logEps))) * logEps;
208  }
209 }

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

Referenced by setStiffnessAndRestitutionCoefficient().

◆ setStiffness()

void LinearViscoelasticNormalSpecies::setStiffness ( Mdouble  new_k)

Allows the spring constant to be changed.

94 {
95  if (new_k >= 0)
96  stiffness_ = new_k;
97  else
98  {
99  logger(ERROR, "setStiffness(%) argument has to be non-negative!", new_k);
100  }
101 }

References ERROR, logger, and stiffness_.

Referenced by setStiffnessAndDissipation().

◆ setStiffnessAndDissipation()

void LinearViscoelasticNormalSpecies::setStiffnessAndDissipation ( helpers::KAndDisp  new_)

Allows the spring and dissipation constants to be changed simultaneously.

111 {
112  setStiffness(new_.k);
113  setDissipation(new_.disp);
114 }

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

◆ setStiffnessAndRestitutionCoefficient()

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}\)
187 {
188  if (getConstantRestitution()) mass = 1;
189  stiffness_ = stiffness;
190  setRestitutionCoefficient(eps, mass);
191 }

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

◆ write()

void LinearViscoelasticNormalSpecies::write ( std::ostream &  os) const

Writes the species properties to an output stream.

Parameters
[out]outputstream (typically the restart file)
69 {
70  os << " stiffness " << stiffness_
71  << " dissipation " << dissipation_;
72 }

References dissipation_, and stiffness_.

Member Data Documentation

◆ dissipation_

◆ stiffness_


The documentation for this class was generated from the following files:
mathsFunc::square
T square(const T val)
squares a number
Definition: ExtendedMath.h:106
BaseInteractable::getSpecies
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
Definition: BaseInteractable.h:108
LinearViscoelasticNormalSpecies::setStiffness
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:93
constants::pi
const Mdouble pi
Definition: ExtendedMath.h:45
LinearViscoelasticNormalSpecies::setDissipation
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:117
constants::sqr_pi
const Mdouble sqr_pi
Definition: ExtendedMath.h:47
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
mathsFunc::exp
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84
LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient
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.
Definition: LinearViscoelasticNormalSpecies.cc:212
INFO
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
mathsFunc::log
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:104
helpers::KAndDisp::disp
Mdouble disp
Definition: Helpers.h:49
BaseParticle::getVolume
virtual Mdouble getVolume() const
Get Particle volume function, which required a reference to the Species vector. It returns the volume...
Definition: BaseParticle.cc:141
ParticleSpecies::getDensity
Mdouble getDensity() const
Allows density_ to be accessed.
Definition: ParticleSpecies.cc:117
LinearViscoelasticNormalSpecies::getDissipation
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:130
Mdouble
double Mdouble
Definition: GeneralDefine.h:34
ERROR
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
BaseSpecies::average
static Mdouble average(Mdouble a, Mdouble b)
Returns the harmonic mean of two variables.
Definition: BaseSpecies.cc:110
LinearViscoelasticNormalSpecies::dissipation_
Mdouble dissipation_
(normal) viscosity
Definition: LinearViscoelasticNormalSpecies.h:117
BaseNormalForce::BaseNormalForce
BaseNormalForce()
Definition: BaseNormalForce.h:34
BaseNormalForce::getConstantRestitution
bool getConstantRestitution() const
Definition: BaseNormalForce.h:45
helpers::KAndDisp::k
Mdouble k
Definition: Helpers.h:48
LinearViscoelasticNormalSpecies::getCollisionTime
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:137
LinearViscoelasticNormalSpecies::stiffness_
Mdouble stiffness_
(normal) spring constant
Definition: LinearViscoelasticNormalSpecies.h:116
LinearViscoelasticNormalSpecies::setRestitutionCoefficient
void setRestitutionCoefficient(double eps, Mdouble mass)
Sets disp to obtain a restitution coefficient eps for a collision of two particles of mass m.
Definition: LinearViscoelasticNormalSpecies.cc:199
LinearViscoelasticNormalSpecies::getStiffness
Mdouble getStiffness() const
Allows the spring constant to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:104