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_debug(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  logger(ERROR, "Error in setCharge - charge must be +1, -1 or zero");
195  }
196 }
197 
198 //*********************************************************************************************************************
199 //******************************ADDING ADDITIONAL VARIABLES FOR BOND INTERACTIONS**************************************
200 //*********************************************************************************************************************
201 
206 {
207  if (new_f0 >= 0)
208  {
209  bondForceMax_ = new_f0;
210  }
211  else
212  {
213  logger(ERROR, "Error in setBondForceMax");
214  }
215 }
216 
219 {
220  return bondForceMax_;
221 }
222 
227 {
228  if (disp >= 0)
229  bondDissipation_ = disp;
230  else
231  {
232  logger(ERROR, "Error in setAdhesionDissipation");
233  }
234 }
235 
240 {
241  return bondDissipation_;
242 }
243 
244 
245 //*********************************************************************************************************************
246 //****************************ADDING ADDITIONAL VARIABLES VAN DER WAALS INTERACTIONS***********************************
247 //*********************************************************************************************************************
248 //Adding parameters to recreate a highly simplified (but relatively computationally efficient!)
249 // van der Waals-like force at short distances
250 
251 //A function to set the maximum strength of the van der Waals force.
252 //Note that this should, by definition, be great enough to overcome the maximal repulsive force experienced by
253 //a particle, as the net force must be attractive in order to correctly represent vand der Waals
255 {
256  if (fMax < 0)
257  {
258  logger(ERROR, "Error in setVanDerWaalsForceMax.");
259  }
260  else
261  {
262  vanDerWaalsForceMax_ = fMax;
263  }
264 }
265 
266 //a function to return the value of the van der Waals maximal force
268 {
269  return vanDerWaalsForceMax_;
270 }
271 
272 //A function to set the stiffness and hence - when combined with the maximal van der Waals force - *range*
273 //of the van der Waals force applied to closely interacting particles.
275 {
276  vanDerWaalsStiffness_ = stiffness;
277 }
278 
279 //a function to return the value of the van der Waals maximal force
281 {
282  return vanDerWaalsStiffness_;
283 }
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")
Definition of different loggers with certain modules. A user can define its own custom logger here...
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