MercuryDPM  Alpha
 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-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 #include "ChargedBondedSpecies.h"
27 #include <Logger.h>
28 
36 {
37  //setting adhesion values initially to zero such that, by default, particles do not experience
38  //long range forces
41  //similarly, setting bond properties to zero such that, by default, particles cannot be 'bondd'...
42  bondForceMax_ = 0;
43  //...and do not impart any excess dissipation!
44  bondDissipation_ = 0;
45  //Setting also parameters corresponding to the van der Waals force to zero by default
48  charge_ = 0;
49 #ifdef DEBUG_CONSTRUCTOR
50  std::cout<<"ChargedBondedSpecies::ChargedBondedSpecies() finished"<<std::endl;
51 #endif
52 }
53 
59 {
66  charge_ = s.charge_;
67 #ifdef DEBUG_CONSTRUCTOR
68  std::cout<<"ChargedBondedSpecies::ChargedBondedSpecies(const ChargedBondedSpecies &p) finished"<<std::endl;
69 #endif
70 }
71 
73 {
74 #ifdef DEBUG_DESTRUCTOR
75  std::cout<<"ChargedBondedSpecies::~ChargedBondedSpecies() finished"<<std::endl;
76 #endif
77 }
78 
82 void ChargedBondedSpecies::write(std::ostream& os) const
83 {
84  os << " adhesionForceMax " << adhesionForceMax_;
85  os << " adhesionStiffness " << adhesionStiffness_;
86  os << " charge " << charge_;
87  os << " bondForceMax " << bondForceMax_;
88  os << " bondDissipation " << bondDissipation_;
89  os << " vanDerWaalsForceMax " << vanDerWaalsForceMax_;
90  os << " vanDerWaalsStiffness " << vanDerWaalsStiffness_;
91 }
92 
96 void ChargedBondedSpecies::read(std::istream& is)
97 {
98  std::string dummy;
99  is >> dummy >> adhesionForceMax_;
100  is >> dummy >> adhesionStiffness_;
101  logger(INFO,"adhesionForceMax_ %", adhesionForceMax_);
102  is >> dummy >> charge_;
103  logger(INFO,"charge % %", dummy, charge_);
104  is >> dummy >> bondForceMax_;
105  is >> dummy >> bondDissipation_;
106  is >> dummy >> vanDerWaalsForceMax_;
107  is >> dummy >> vanDerWaalsStiffness_;
108 }
109 
115 {
116  return "ChargedBonded";
117 }
118 
128 {
129  //'mixing' properties relating to the charged force interactions between particles
132 
133  //ensuring that, in addition, bond properties are also 'mixed'
136 
137  //and that the van der Waals force also is computed correctly
140 
141  charge_ = 0; //note mixedSpecies dont need charge, it's a particle property.
142 }
143 
146 {
147  if (adhesionStiffness_ != 0.0)
149  else
150  {
151  std::cerr << "ChargedBondedSpecies::getInteractionDistance(): adhesionStiffness cannot be zero" << std::endl;
152  exit(-1);
153  }
154 }
155 
158 {
159  if (new_k0 >= 0)
160  adhesionStiffness_ = new_k0;
161  else
162  {
163  std::cerr << "Error in setAdhesionStiffness" << std::endl;
164  exit(-1);
165  }
166 }
169 {
170  return adhesionStiffness_;
171 }
172 
175 {
176  if (new_f0 >= 0)
177  adhesionForceMax_ = new_f0;
178  else
179  {
180  std::cerr << "Error in setBondForceMax" << std::endl;
181  exit(-1);
182  }
183 }
186 {
187  return adhesionForceMax_;
188 }
189 
190 //overwrites the baseSpecies version of this function, allowing particles' charges to be accessed from the
191 //program running
193  return charge_;
194 }
195 
196 //allows the user to manually set the charge of a particle
198 {
199  //making sure that the user can only enter 1 (positive charge) -1 (negative charge)
200  //or zero (no charge)
201  if (newCharge == 0 || newCharge == 1 || newCharge == -1)
202  charge_ = newCharge;
203  else
204  {
205  std::cerr << "Error in setCharge - charge must be +1, -1 or zero" << std::endl;
206  exit(-1);
207  }
208 }
209 
210 //*********************************************************************************************************************
211 //******************************ADDING ADDITIONAL VARIABLES FOR BOND INTERACTIONS**************************************
212 //*********************************************************************************************************************
213 
218  if (new_f0 >= 0) {
219  bondForceMax_ = new_f0;
220  }
221  else {
222  std::cerr << "Error in setBondForceMax" << std::endl;
223  exit(-1);
224  }
225 }
226 
229 {
230  return bondForceMax_;
231 }
232 
237 {
238  if (disp >= 0)
239  bondDissipation_ = disp;
240  else
241  {
242  std::cerr << "Error in setAdhesionDissipation" << std::endl;
243  exit(-1);
244  }
245 }
250 {
251  return bondDissipation_;
252 }
253 
254 
255 //*********************************************************************************************************************
256 //****************************ADDING ADDITIONAL VARIABLES VAN DER WAALS INTERACTIONS***********************************
257 //*********************************************************************************************************************
258 //Adding parameters to recreate a highly simplified (but relatively computationally efficient!)
259 // van der Waals-like force at short distances
260 
261 //A function to set the maximum strength of the van der Waals force.
262 //Note that this should, by definition, be great enough to overcome the maximal repulsive force experienced by
263 //a particle, as the net force must be attractive in order to correctly represent vand der Waals
265 {
266  if ( fMax < 0 ) {
267  std::cerr << "Error in setVanDerWaalsForceMax." << std::endl;
268  exit(-1);
269  }
270  else {
271  vanDerWaalsForceMax_ = fMax;
272  }
273 }
274 
275 //a function to return the value of the van der Waals maximal force
277 {
278  return vanDerWaalsForceMax_;
279 }
280 
281 //A function to set the stiffness and hence - when combined with the maximal van der Waals force - *range*
282 //of the van der Waals force applied to closely interacting particles.
284 {
285  vanDerWaalsStiffness_ = stiffness;
286 }
287 
288 //a function to return the value of the van der Waals maximal force
290 {
291  return vanDerWaalsStiffness_;
292 }
Mdouble adhesionForceMax_
adhesion force at zero overlap
Mdouble getVanDerWaalsForceMax() const
void setAdhesionForceMax(Mdouble new_f0)
Allows the spring constant to be changed.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void mix(ChargedBondedSpecies *const S, ChargedBondedSpecies *const T)
creates default values for mixed species
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.
double Mdouble
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
Mdouble getInteractionDistance() const
returns the largest separation distance at which adhesive short-range forces can occur.
virtual ~ChargedBondedSpecies()
The default constructor.
void setVanDerWaalsForceMax(Mdouble)
Mdouble bondForceMax_
The maximal force which acts to bind together particles which are "bondd" into a single body...
Mdouble average(Mdouble a, Mdouble b)
defines the average of two variables by the harmonic mean.
Definition: BaseSpecies.cc:85
void setVanDerWaalsStiffness(Mdouble)
Mdouble getAdhesionStiffness() const
Allows the spring constant to be accessed.
Mdouble bondDissipation_
dissipation in bond
void setCharge(int newCharge)
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 write(std::ostream &os) const
Writes the species properties to an output stream.
Mdouble adhesionStiffness_
stiffness of linear adhesion force