MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LinearPlasticViscoelasticInteraction.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 
26 
28 #include "InteractionHandler.h"
29 #include "Particles/BaseParticle.h"
30 #include <iomanip>
31 #include <fstream>
33 #include <cmath> // std::max
40  : BaseInteraction(P, I, timeStamp)
41 {
42  maxOverlap_=0;
43 #ifdef DEBUG_CONSTRUCTOR
44  std::cout<<"LinearPlasticViscoelasticInteraction::LinearPlasticViscoelasticInteraction() finished"<<std::endl;
45 #endif
46 }
51  : BaseInteraction(p)
52 {
54 #ifdef DEBUG_CONSTRUCTOR
55  std::cout<<"LinearPlasticViscoelasticInteraction::LinearPlasticViscoelasticInteraction(const LinearPlasticViscoelasticInteraction &p finished"<<std::endl;
56 #endif
57 }
62 {
63 #ifdef DEBUG_DESTRUCTOR
64  std::cout<<"LinearPlasticViscoelasticInteraction::~LinearPlasticViscoelasticInteraction() finished"<<std::endl;
65 #endif
66 }
67 
72 void LinearPlasticViscoelasticInteraction::write(std::ostream& os) const
73 {
75 }
81 {
83 }
88 {
89  return "LinearPlasticViscoelastic";
90 }
95 {
96  // Compute the relative velocity vector of particle P w.r.t. I
97  setRelativeVelocity(getP()->getVelocityAtContact(getContactPoint()) - getI()->getVelocityAtContact(getContactPoint()));
98  // Compute the projection of vrel onto the normal (can be negative)
100 
101  if (getOverlap() > 0) //if contact forces
102  {
104  //Mdouble normalForce = species->getLoadingStiffness() * getOverlap() - species->getDissipation() * getNormalRelativeVelocity();
106  Mdouble normalForce = -species->getDissipation() * getNormalRelativeVelocity();
107 
108  BaseParticle* PParticle = dynamic_cast<BaseParticle*>(getP());
109  BaseParticle* IParticle = dynamic_cast<BaseParticle*>(getI());
110  Mdouble effectiveDiameter;
111  if (IParticle == 0)
112  effectiveDiameter = 2.0 * PParticle->getRadius();
113  else
114  effectiveDiameter = ((2.0 * PParticle->getRadius() * IParticle->getRadius()) / (PParticle->getRadius() + IParticle->getRadius()));
115  //calculate deltastar, the overlap above which k2max becomes active (the 'fluid branch')
116  Mdouble deltaStar = (species->getUnloadingStiffnessMax() / (species->getUnloadingStiffnessMax() - species->getLoadingStiffness())) * species->getPenetrationDepthMax() * effectiveDiameter;
117  //2*depth*r_eff is the overlap at which fn=0 on the k2max branch
118  //deltastar is the overlap at which the k1 and the k2max branch meet
119 
120  //retrieve history parameter deltamax, the max. achieved overlap
121  maxOverlap_ = std::min(deltaStar, std::max(maxOverlap_, getOverlap()));
122 
123  //calculate k2(deltamax) (only use first case for Walton-Braun spring)
124  Mdouble unloadingStiffness;
125  if (getOverlap() > deltaStar)
126  unloadingStiffness = species->getUnloadingStiffnessMax();
127  else
128  unloadingStiffness = species->getLoadingStiffness() + (species->getUnloadingStiffnessMax() - species->getLoadingStiffness()) * (maxOverlap_ / deltaStar);
129 
130  //calculate delta0(deltamax), the overlap where the force is zero
131  Mdouble equilibriumOverlap = (unloadingStiffness - species->getLoadingStiffness()) / unloadingStiffness * maxOverlap_;
132 
133  //add elastic force
134  //std::cout << k2*(getOverlap()-(delta0))-species->k*getOverlap() << std::endl;
135  if (getOverlap() > deltaStar)
136  {
137  normalForce += species->getUnloadingStiffnessMax() * (getOverlap() - equilibriumOverlap);
138  }
139  else if (unloadingStiffness * (getOverlap() - (equilibriumOverlap)) >= species->getLoadingStiffness() * getOverlap())
140  {
141  normalForce += species->getLoadingStiffness() * getOverlap();
142  }
143  else if (unloadingStiffness * (getOverlap() - equilibriumOverlap) >= -species->getCohesionStiffness() * getOverlap())
144  {
145  normalForce += unloadingStiffness * (getOverlap() - equilibriumOverlap);
146  }
147  else
148  {
149  normalForce += -species->getCohesionStiffness() * getOverlap();
150  maxOverlap_ = (unloadingStiffness + species->getCohesionStiffness()) / (unloadingStiffness - species->getLoadingStiffness()) * getOverlap();
151  }
152 
153  setAbsoluteNormalForce(std::abs(normalForce)); //used for further corce calculations;
154  setForce(getNormal() * normalForce);
155  setTorque(Vec3D(0.0, 0.0, 0.0));
156  }
157  else
158  {
160  setForce(Vec3D(0.0, 0.0, 0.0));
161  setTorque(Vec3D(0.0, 0.0, 0.0));
162  }
163 }
168 {
170 }
175 {
176  if (getOverlap() > 0)
178  else
179  return 0.0;
181 }
186 {
187  return dynamic_cast<const LinearPlasticViscoelasticNormalSpecies*>(getBaseSpecies());
188 }
193 {
194  return maxOverlap_;
195 }
200 {
201  maxOverlap_ = maxOverlap;
202 }
207 {
209  Mdouble effectiveDiameter = 2.0*getEffectiveRadius();
210  Mdouble deltaMaxFluid = species->getPenetrationDepthMax() * effectiveDiameter / (1.0-species->getLoadingStiffness()/species->getUnloadingStiffnessMax());
211  if (getOverlap() > deltaMaxFluid)
212  return species->getUnloadingStiffnessMax();
213  else
214  return species->getLoadingStiffness() + (species->getUnloadingStiffnessMax() - species->getLoadingStiffness()) * getMaxOverlap()/deltaMaxFluid;
215 }
216 
virtual std::string getBaseName() const
Returns the name of the interaction.
Mdouble getEffectiveRadius() const
Returns a Mdouble to the effective radius of the interaction. (Not corrected for the overlap) ...
virtual void read(std::istream &is)
Interaction read function, which accepts an std::istream as input.
void computeLinearPlasticViscoelasticForce()
Creates a copy of an object of this class. (Deep copy)
Mdouble getUnloadingStiffnessMax() const
Returns the maximum unloading stiffness of the linear plastic-viscoelastic normal force...
const Vec3D & getRelativeVelocity() const
Returns a constant reference to a vector of relative velocity.
double Mdouble
void setRelativeVelocity(Vec3D relativeVelocity)
set the relative velocity of the current of the interactions.
void setForce(Vec3D force)
set total force (this is used by the normal force, tangential forces are added use addForce) ...
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:187
void setNormalRelativeVelocity(Mdouble normalRelativeVelocit)
set the normal component of the relative velocity.
T square(T val)
squares a number
Definition: ExtendedMath.h:91
Stores information about interactions between two interactable objects; often particles but could be ...
void computeNormalForce()
Calls computeLinearPlasticViscoElasticForce().
Mdouble getCohesionStiffness() const
Returns the cohesive stiffness of the linear plastic-viscoelastic normal force.
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
Mdouble getNormalRelativeVelocity() const
Returns a double which is the norm (length) of the relative velocity vector.
LinearPlasticViscoelasticInteraction(BaseInteractable *P, BaseInteractable *I, Mdouble timeStamp)
Constructor.
const BaseSpecies * getBaseSpecies() const
Return a constant point to BaseSpecies of the interaction.
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
void setTorque(Vec3D torque)
set the total force (this is used by the normal force, tangential torques are added use addTorque) ...
Mdouble getDissipation() const
Allows the normal dissipation to be accessed.
Mdouble getRadius() const
Returns the particle's radius_.
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
void setAbsoluteNormalForce(Mdouble absoluteNormalForce)
the absolute values of the norm (length) of the normal force
Mdouble getElasticEnergy() const
Computes and returns the amount of elastic energy stored in the spring.
BaseInteractable * getI()
const LinearPlasticViscoelasticNormalSpecies * getSpecies() const
virtual void read(std::istream &is)
Interaction read function, which accepts an std::istream as input.
Defines the basic properties that a interactable object can have.
LinearPlasticViscoelasticNormalSpecies contains the parameters used to describe a plastic-cohesive no...
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble getPenetrationDepthMax() const
Returns the maximum penetration depth of the linear plastic-viscoelastic normal force.
virtual void write(std::ostream &os) const
Interaction print function, which accepts an std::ostream as input.
Computes normal forces in case of a linear plastic visco-elastic interaction.
virtual void write(std::ostream &os) const
Interaction write function, which accepts an std::ostream as input.
Mdouble getLoadingStiffness() const
Returns the loading stiffness of the linear plastic-viscoelastic normal force.