MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ChargedBondedSpecies.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 #include "ChargedBondedSpecies.h"
27 #include "Logger.h"
28 #include "Species/BaseSpecies.h"
29 
37 {
38  //setting adhesion values initially to zero such that, by default, particles do not experience
39  //long range forces
42  //similarly, setting bond properties to zero such that, by default, particles cannot be 'bondd'...
43  bondForceMax_ = 0;
44  //...and do not impart any excess dissipation!
45  bondDissipation_ = 0;
46  //Setting also parameters corresponding to the van der Waals force to zero by default
49  charge_ = 0;
50 #ifdef DEBUG_CONSTRUCTOR
51  std::cout<<"ChargedBondedSpecies::ChargedBondedSpecies() finished"<<std::endl;
52 #endif
53 }
54 
60 {
67  charge_ = s.charge_;
68 #ifdef DEBUG_CONSTRUCTOR
69  std::cout<<"ChargedBondedSpecies::ChargedBondedSpecies(const ChargedBondedSpecies &p) finished"<<std::endl;
70 #endif
71 }
72 
76 void ChargedBondedSpecies::write(std::ostream& os) const
77 {
78  os << " adhesionForceMax " << adhesionForceMax_;
79  os << " adhesionStiffness " << adhesionStiffness_;
80  os << " charge " << charge_;
81  os << " bondForceMax " << bondForceMax_;
82  os << " bondDissipation " << bondDissipation_;
83  os << " vanDerWaalsForceMax " << vanDerWaalsForceMax_;
84  os << " vanDerWaalsStiffness " << vanDerWaalsStiffness_;
85 }
86 
90 void ChargedBondedSpecies::read(std::istream& is)
91 {
92  std::string dummy;
93  is >> dummy >> adhesionForceMax_;
94  is >> dummy >> adhesionStiffness_;
95  is >> dummy >> charge_;
96  is >> dummy >> bondForceMax_;
97  is >> dummy >> bondDissipation_;
98  is >> dummy >> vanDerWaalsForceMax_;
99  is >> dummy >> vanDerWaalsStiffness_;
100 }
101 
107 {
108  return "ChargedBonded";
109 }
110 
120 {
121  //'mixing' properties relating to the charged force interactions between particles
124 
125  //ensuring that, in addition, bond properties are also 'mixed'
128 
129  //and that the van der Waals force also is computed correctly
132 
133  charge_ = 0; //note mixedSpecies dont need charge, it's a particle property.
134 }
135 
138 {
139  logger.assert(adhesionStiffness_ != 0.0,"ChargedBondedSpecies::getInteractionDistance(): adhesionStiffness cannot be zero");
141 }
142 
143 
146 {
147  if (new_k0 >= 0) {
148  adhesionStiffness_ = new_k0;
150  } else {
151  logger(ERROR, "Error in setAdhesionStiffness");
152  }
153 }
154 
157 {
158  return adhesionStiffness_;
159 }
160 
163 {
164  if (new_f0 >= 0) {
165  adhesionForceMax_ = new_f0;
167  } else {
168  logger(ERROR, "Error in setAdhesionForceMax");
169  }
170 }
171 
174 {
175  return adhesionForceMax_;
176 }
177 
178 //overwrites the baseSpecies version of this function, allowing particles' charges to be accessed from the
179 //program running
181 {
182  return charge_;
183 }
184 
185 //allows the user to manually set the charge of a particle
187 {
188  //making sure that the user can only enter 1 (positive charge) -1 (negative charge)
189  //or zero (no charge)
190  if (newCharge == 0 || newCharge == 1 || newCharge == -1)
191  charge_ = newCharge;
192  else
193  {
194  std::cerr << "Error in setCharge - charge must be +1, -1 or zero" << std::endl;
195  exit(-1);
196  }
197 }
198 
199 //*********************************************************************************************************************
200 //******************************ADDING ADDITIONAL VARIABLES FOR BOND INTERACTIONS**************************************
201 //*********************************************************************************************************************
202 
207 {
208  if (new_f0 >= 0)
209  {
210  bondForceMax_ = new_f0;
211  }
212  else
213  {
214  std::cerr << "Error in setBondForceMax" << std::endl;
215  exit(-1);
216  }
217 }
218 
221 {
222  return bondForceMax_;
223 }
224 
229 {
230  if (disp >= 0)
231  bondDissipation_ = disp;
232  else
233  {
234  std::cerr << "Error in setAdhesionDissipation" << std::endl;
235  exit(-1);
236  }
237 }
238 
243 {
244  return bondDissipation_;
245 }
246 
247 
248 //*********************************************************************************************************************
249 //****************************ADDING ADDITIONAL VARIABLES VAN DER WAALS INTERACTIONS***********************************
250 //*********************************************************************************************************************
251 //Adding parameters to recreate a highly simplified (but relatively computationally efficient!)
252 // van der Waals-like force at short distances
253 
254 //A function to set the maximum strength of the van der Waals force.
255 //Note that this should, by definition, be great enough to overcome the maximal repulsive force experienced by
256 //a particle, as the net force must be attractive in order to correctly represent vand der Waals
258 {
259  if (fMax < 0)
260  {
261  std::cerr << "Error in setVanDerWaalsForceMax." << std::endl;
262  exit(-1);
263  }
264  else
265  {
266  vanDerWaalsForceMax_ = fMax;
267  }
268 }
269 
270 //a function to return the value of the van der Waals maximal force
272 {
273  return vanDerWaalsForceMax_;
274 }
275 
276 //A function to set the stiffness and hence - when combined with the maximal van der Waals force - *range*
277 //of the van der Waals force applied to closely interacting particles.
279 {
280  vanDerWaalsStiffness_ = stiffness;
281 }
282 
283 //a function to return the value of the van der Waals maximal force
285 {
286  return vanDerWaalsStiffness_;
287 }
Mdouble adhesionForceMax_
adhesion force at zero overlap
BaseSpecies * getBaseSpecies() const
Definition: BaseForce.h:35
Mdouble getVanDerWaalsForceMax() const
void setAdhesionForceMax(Mdouble new_f0)
Allows the spring constant to be changed.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
void setBondForceMax(Mdouble new_f0)
Allows the spring constant for the BOND to be changed (Do not confuse with the charged interaction st...
Mdouble getAdhesionForceMax() const
Allows the spring constant to be accessed.
void setInteractionDistance(Mdouble interactionDistance)
Sets BaseSpecies::interactionDistance_.
Definition: BaseSpecies.cc:156
void read(std::istream &is)
Reads the species properties from an input stream.
std::string getBaseName() const
Used in Species::getName to obtain a unique name for each Species.
ChargedBondedSpecies contains the parameters used to describe a linear reversible short-range force...
Mdouble getBondDissipation() const
Allows the additional dissipation used to damp oscillations between bondd particles to be accessed...
void setBondDissipation(Mdouble disp)
Allows the additional dissipation used to damp oscillations between bondd particles to be changed...
Mdouble getVanDerWaalsStiffness() const
void setVanDerWaalsForceMax(Mdouble)
Mdouble bondForceMax_
The maximal force which acts to bind together particles which are "bondd" into a single body...
static Mdouble average(Mdouble a, Mdouble b)
Returns the harmonic mean of two variables.
Definition: BaseSpecies.cc:110
void setVanDerWaalsStiffness(Mdouble)
Mdouble getAdhesionStiffness() const
Allows the spring constant to be accessed.
Mdouble bondDissipation_
dissipation in bond
void setCharge(int newCharge)
void setInteractionDistance()
returns the largest separation distance at which adhesive short-range forces can occur.
void setAdhesionStiffness(Mdouble new_k0)
Allows the spring constant to be changed.
ChargedBondedSpecies()
The default constructor.
Mdouble getBondForceMax() const
Allows the maximal force for 'bonding' particles together to be accessed.
void mix(ChargedBondedSpecies *S, ChargedBondedSpecies *T)
creates default values for mixed species
void write(std::ostream &os) const
Writes the species properties to an output stream.
Mdouble adhesionStiffness_
stiffness of linear adhesion force