MercuryDPM  Alpha
 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...
 
virtual ~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 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 *const SBase, LinearViscoelasticNormalSpecies *const 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 BaseSpecies
 BaseSpecies ()
 The default constructor. More...
 
 BaseSpecies (const BaseSpecies &p)
 The copy constructor. More...
 
virtual ~BaseSpecies ()
 The default destructor. More...
 
virtual BaseSpeciescopy () const =0
 Creates a deep copy of the object from which it is called. More...
 
void setHandler (SpeciesHandler *handler)
 Sets the pointer to the handler to which this species belongs. More...
 
SpeciesHandlergetHandler () const
 Returns the pointer to the handler to which this species belongs. More...
 
Mdouble average (Mdouble a, Mdouble b)
 defines the average of two variables by the harmonic mean. More...
 
virtual void mixAll (BaseSpecies *const S, BaseSpecies *const T)=0
 creates default values for mixed species More...
 
virtual Mdouble getInteractionDistance () const =0
 returns the largest separation distance at which adhesive short-range forces can occur. More...
 
virtual bool getUseAngularDOFs () const =0
 Returns true if torques (i.e. angular degrees of freedom) have to be calculated. More...
 
virtual BaseInteractiongetNewInteraction (BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp) const =0
 returns new Interaction object. More...
 
- Public Member Functions inherited from BaseObject
 BaseObject ()
 Default constructor. More...
 
 BaseObject (const BaseObject &p)
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()
 virtual destructor More...
 
virtual std::string getName () const =0
 A purely virtual function. More...
 
virtual void moveInHandler (const unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (const unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (const unsigned int id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 

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 36 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 {
37  stiffness_ = 0;
38  dissipation_ = 0;
39 #ifdef DEBUG_CONSTRUCTOR
40  std::cout<<"LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies() finished"<<std::endl;
41 #endif
42 }
Mdouble stiffness_
(normal) spring constant
LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies ( const LinearViscoelasticNormalSpecies p)

The default copy constructor.

Parameters
[in]thespecies that is copied

Definition at line 47 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, and stiffness_.

48 {
51 #ifdef DEBUG_CONSTRUCTOR
52  std::cout<<"LinearViscoelasticNormalSpecies::LinearViscoelasticNormalSpecies(const LinearViscoelasticNormalSpecies &p) finished"<<std::endl;
53 #endif
54 }
Mdouble stiffness_
(normal) spring constant
LinearViscoelasticNormalSpecies::~LinearViscoelasticNormalSpecies ( )
virtual

The default destructor.

Definition at line 56 of file LinearViscoelasticNormalSpecies.cc.

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

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 85 of file LinearViscoelasticNormalSpecies.cc.

86 {
87  return "LinearViscoelastic";
88 }
Mdouble LinearViscoelasticNormalSpecies::getCollisionTime ( Mdouble  mass) const

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

Definition at line 136 of file LinearViscoelasticNormalSpecies.cc.

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

Referenced by getRestitutionCoefficient().

137 {
138  if (mass <= 0)
139  {
140  std::cerr << "Warning in getCollisionTime(" << mass << ") mass is not set or has an unexpected value, (getCollisionTime(" << mass << "))" << std::endl;
141  }
142  if (stiffness_ <= 0)
143  {
144  std::cerr << "Warning in getCollisionTime(" << mass << ") stiffness=" << stiffness_ << " is not set or has an unexpected value, (getCollisionTime(" << mass << "), with stiffness=" << stiffness_ << ")" << std::endl;
145  }
146  if (dissipation_ < 0)
147  {
148  std::cerr << "Warning in getCollisionTime(" << mass << ") dissipation=" << dissipation_ << " is not set or has an unexpected value, (getCollisionTime(" << mass << "), with dissipation=" << dissipation_ << ")" << std::endl;
149  }
150  Mdouble tosqrt = stiffness_ / (.5 * mass) - mathsFunc::square(dissipation_ / mass);
151  if (tosqrt <= 0)
152  {
153  std::cerr << "Warning in getCollisionTime(" << mass << ") values for mass, stiffness and dissipation would lead to an overdamped system, (getCollisionTime(" << mass << "), with stiffness=" << stiffness_ << " and dissipation=" << dissipation_ << ")" << std::endl;
154  }
155  return constants::pi / std::sqrt(tosqrt);
156 }
Mdouble stiffness_
(normal) spring constant
double Mdouble
T square(T val)
squares a number
Definition: ExtendedMath.h:91
const Mdouble pi
Definition: ExtendedMath.h:42
Mdouble LinearViscoelasticNormalSpecies::getDissipation ( ) const

Allows the normal dissipation to be accessed.

Definition at line 130 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_.

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

131 {
132  return dissipation_;
133 }
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 165 of file LinearViscoelasticNormalSpecies.cc.

References stiffness_.

166 {
167  return radius * std::sqrt(stiffness_ / (.5 * mass));
168 }
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 159 of file LinearViscoelasticNormalSpecies.cc.

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

160 {
161  return std::exp(-dissipation_ / mass * getCollisionTime(mass));
162 }
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:78
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
void LinearViscoelasticNormalSpecies::mix ( LinearViscoelasticNormalSpecies *const  S,
LinearViscoelasticNormalSpecies *const  T 
)

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 223 of file LinearViscoelasticNormalSpecies.cc.

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

224 {
227 }
Mdouble stiffness_
(normal) spring constant
Mdouble getStiffness() const
Allows the spring constant to be accessed.
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 LinearViscoelasticNormalSpecies::read ( std::istream &  is)
virtual

Reads the species properties from an input stream.

Parameters
[in]inputstream (typically the restart file)

Implements BaseObject.

Definition at line 75 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, and stiffness_.

76 {
77  std::string dummy;
78  is >> dummy >> stiffness_
79  >> dummy >> dissipation_;
80 }
Mdouble stiffness_
(normal) spring constant
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]masseffective particle mass, $\frac{2}{1/m1+1/m2}$

Definition at line 192 of file LinearViscoelasticNormalSpecies.cc.

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

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

193 {
194  if (eps==0.0) {
195  stiffness_ = .5 * mass * mathsFunc::square(constants::pi / tc);
196  dissipation_ = std::sqrt(2.0 * mass * stiffness_);
197  } else {
198  dissipation_ = -mass / tc * mathsFunc::log(eps);
199  stiffness_ = .5 * mass * (mathsFunc::square(constants::pi / tc)
200  + mathsFunc::square(dissipation_ / mass));
201  }
202  logger(INFO,"setCollisionTimeAndRestitutionCoefficient: set stiffness to % and dissipation to % to obtain a collision time of % and a restitution coefficient of % for two particles of mass %",
203  getStiffness(),getDissipation(),tc,eps,mass);
204 }
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)
Definition: ExtendedMath.cc:97
T square(T val)
squares a number
Definition: ExtendedMath.h:91
const Mdouble pi
Definition: ExtendedMath.h:42
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 212 of file LinearViscoelasticNormalSpecies.cc.

References setCollisionTimeAndRestitutionCoefficient().

213 {
214  Mdouble reduced_mass = mass1 * mass2 / (mass1 + mass2);
215  setCollisionTimeAndRestitutionCoefficient(collisionTime, restitutionCoefficient, 2.0 * reduced_mass);
216 }
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...
double Mdouble
void LinearViscoelasticNormalSpecies::setDissipation ( Mdouble  dissipation)

Allows the normal dissipation to be changed.

Definition at line 116 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_.

Referenced by setStiffnessAndDissipation().

117 {
118  if (dissipation >= 0)
119  {
120  dissipation_ = dissipation;
121  }
122  else
123  {
124  std::cerr << "Error in setDissipation(" << dissipation << ")" << std::endl;
125  exit(-1);
126  }
127 }
void LinearViscoelasticNormalSpecies::setStiffness ( Mdouble  new_k)

Allows the spring constant to be changed.

Definition at line 91 of file LinearViscoelasticNormalSpecies.cc.

References stiffness_.

Referenced by setStiffnessAndDissipation().

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

Allows the spring and dissipation constants to be changed simultaneously.

Definition at line 109 of file LinearViscoelasticNormalSpecies.cc.

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

110 {
111  setStiffness(new_.k);
112  setDissipation(new_.disp);
113 }
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:46
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]masseffective particle mass, $\frac{2}{1/m1+1/m2}$

Definition at line 176 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, mathsFunc::log(), constants::sqr_pi, mathsFunc::square(), and stiffness_.

177 {
178  stiffness_ = stiffness;
179  if (eps==0.0) {
180  dissipation_ = std::sqrt(2.0 * mass * stiffness);
181  } else {
182  dissipation_ = -std::sqrt(2.0 * mass * stiffness / (constants::sqr_pi + mathsFunc::square(log(eps)))) * log(eps);
183  }
184 }
Mdouble stiffness_
(normal) spring constant
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:97
T square(T val)
squares a number
Definition: ExtendedMath.h:91
const Mdouble sqr_pi
Definition: ExtendedMath.h:44
void LinearViscoelasticNormalSpecies::write ( std::ostream &  os) const
virtual

Writes the species properties to an output stream.

Parameters
[out]outputstream (typically the restart file)

Implements BaseObject.

Definition at line 66 of file LinearViscoelasticNormalSpecies.cc.

References dissipation_, and stiffness_.

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

Member Data Documentation


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