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...
 
MERCURYDPM_DEPRECATED void setStiffnessAndDissipation (helpers::KAndDisp new_)
 Allows the spring and dissipation constants to be changed simultaneously. More...
 
Mdouble computeTimeStep (Mdouble mass)
 
- Public Member Functions inherited from BaseNormalForce
 BaseNormalForce ()
 
 BaseNormalForce (const BaseNormalForce &p)
 
bool getConstantRestitution () const
 
void setConstantRestitution (bool constantRestitution)
 
virtual void actionsAfterTimeStep (BaseParticle *particle) const
 
- 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 }
BaseNormalForce()
Definition: BaseNormalForce.h:35
Mdouble dissipation_
(normal) viscosity
Definition: LinearViscoelasticNormalSpecies.h:123
Mdouble stiffness_
(normal) spring constant
Definition: LinearViscoelasticNormalSpecies.h:122

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

◆ computeTimeStep()

Mdouble LinearViscoelasticNormalSpecies::computeTimeStep ( Mdouble  mass)
inline
116  {
117  return 0.02 * constants::pi /
118  std::sqrt(stiffness_ / (.5 * mass) - mathsFunc::square(dissipation_ / mass));
119  }
const Mdouble pi
Definition: ExtendedMath.h:45
T square(const T val)
squares a number
Definition: ExtendedMath.h:106

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

◆ 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 }
double Mdouble
Definition: GeneralDefine.h:34
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ ERROR
bool getConstantRestitution() const
Definition: BaseNormalForce.h:46

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

Referenced by getRestitutionCoefficient(), main(), MaserRepeatedOutInMPI2Test::MaserRepeatedOutInMPI2Test(), ParticleCreation::ParticleCreation(), ParticleInclusion::ParticleInclusion(), ShiftingConstantMassFlowMaserBoundarySelfTest::setupInitialConditions(), ShiftingMaserBoundarySelfTest::setupInitialConditions(), ConstantMassFlowMaserBoundaryMixedSpeciesSelfTest::setupInitialConditions(), ConstantMassFlowMaserSelfTest::setupInitialConditions(), SubcriticalMaserBoundarySelfTest::setupInitialConditions(), Wall::setupInitialConditions(), EllipsoidsBouncingOnWallDemo::setupInitialConditions(), EllipticalSuperQuadricCollision::setupInitialConditions(), SphericalSuperQuadricCollision::setupInitialConditions(), VisualisationTest::setupInitialConditions(), Packing::setupInitialConditions(), SubcriticalMaserBoundaryTESTMPI2Test::SubcriticalMaserBoundaryTESTMPI2Test(), and viscoElasticUnitTest::viscoElasticUnitTest().

◆ getDissipation()

Mdouble LinearViscoelasticNormalSpecies::getDissipation ( ) const

◆ 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_.

Referenced by main().

◆ 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 }
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:137
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84

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

Referenced by main(), CubicCell::setupInitialConditions(), and SubcriticalMaserBoundaryTESTMPI2Test::SubcriticalMaserBoundaryTESTMPI2Test().

◆ 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
268 {
269  stiffness_ = BaseSpecies::average(S->getStiffness(), T->getStiffness());
270  dissipation_ = BaseSpecies::average(S->getDissipation(), T->getDissipation());
271 }
static Mdouble average(Mdouble a, Mdouble b)
Returns the harmonic mean of two variables.
Definition: BaseSpecies.cc:110

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

References setCollisionTimeAndRestitutionCoefficient().

◆ setCollisionTimeAndRestitutionCoefficient() [2/3]

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.

213 {
214  Mdouble mass = p->getSpecies()->getDensity() * p->getVolume();
216 }
const ParticleSpecies * getSpecies() const
Returns a pointer to the species of this BaseInteractable.
Definition: BaseInteractable.h:108
virtual Mdouble getVolume() const
Get Particle volume function, which required a reference to the Species vector. It returns the volume...
Definition: BaseParticle.cc:143
Mdouble getDensity() const
Allows density_ to be accessed.
Definition: ParticleSpecies.cc:118

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

Referenced by BouncingSuperQuadric::BouncingSuperQuadric(), main(), MaserRepeatedOutInMPI2Test::MaserRepeatedOutInMPI2Test(), SilbertPeriodic::set_study(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(), SlidingFrictionSpecies::setCollisionTimeAndNormalAndTangentialRestitutionCoefficientNoDispt(), setCollisionTimeAndRestitutionCoefficient(), AxisymmetricWallSelfTest::setSpeciesAndTimeStep(), ShiftingConstantMassFlowMaserBoundarySelfTest::setupInitialConditions(), ShiftingMaserBoundarySelfTest::setupInitialConditions(), PolydisperseInsertionBoundarySelfTest::setupInitialConditions(), Packing::setupInitialConditions(), MovingIntersectionOfWallsUnitTest_Basic::setupInitialConditions(), WallSpecies::setupInitialConditions(), and SubcriticalMaserBoundaryTESTMPI2Test::SubcriticalMaserBoundaryTESTMPI2Test().

◆ 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  logger.assert_always(tc>0, "collision time has to be positive");
228  logger.assert_always(eps>=0 && eps<=1, "restitution has to be in [0,1]");
229  logger.assert_always(mass>0, "mass has to be positive");
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 }
@ INFO
Mdouble getStiffness() const
Allows the spring constant to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:104
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
Definition: LinearViscoelasticNormalSpecies.cc:130
Mdouble log(Mdouble Power)
Definition: ExtendedMath.cc:104

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

◆ setDissipation()

◆ 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 }
const Mdouble sqr_pi
Definition: ExtendedMath.h:47

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 Contact::Contact(), InsertionBoundaryMPI2Test::InsertionBoundaryMPI2Test(), InsertionBoundarySelfTest::InsertionBoundarySelfTest(), main(), ParticleInclusion::ParticleInclusion(), protectiveWall::protectiveWall(), SpeciesHandler::readOldObject(), setStiffnessAndDissipation(), CubicCell::setupInitialConditions(), ConstantMassFlowMaserBoundaryMixedSpeciesSelfTest::setupInitialConditions(), ConstantMassFlowMaserSelfTest::setupInitialConditions(), CubeDeletionBoundarySelfTest::setupInitialConditions(), DeletionBoundarySelfTest::setupInitialConditions(), DistributionSelfTest::setupInitialConditions(), DistributionToPSDSelfTest::setupInitialConditions(), InsertionBoundarySelfTest::setupInitialConditions(), MultiplePSDSelfTest::setupInitialConditions(), PSDManualInsertionSelfTest::setupInitialConditions(), PSDSelfTest::setupInitialConditions(), SubcriticalMaserBoundarySelfTest::setupInitialConditions(), EllipsoidsBouncingOnWallDemo::setupInitialConditions(), EllipticalSuperQuadricCollision::setupInitialConditions(), SphericalSuperQuadricCollision::setupInitialConditions(), VisualisationTest::setupInitialConditions(), ParticleParticleInteraction::setupInitialConditions(), ParticleWallInteraction::setupInitialConditions(), FreeFall::setupInitialConditions(), SeparateFilesSelfTest::setupInitialConditions(), ContactDetectionWithWallTester::setupParticleAndWall(), ContactDetectionTester::setupParticles(), SilbertPeriodic::SilbertPeriodic(), T_protectiveWall::T_protectiveWall(), and Wall::Wall().

◆ 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 }
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:117
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:93
Mdouble k
Definition: FormulaHelpers.h:39
Mdouble disp
Definition: FormulaHelpers.h:40

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 }
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

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

Referenced by main(), ParticleCreation::ParticleCreation(), SilbertPeriodic::set_study(), Packing::setupInitialConditions(), StressStrainControl::StressStrainControl(), and viscoElasticUnitTest::viscoElasticUnitTest().

◆ 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: