1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
/////////////////////////////////////////////////////////////
/*
HertzianViscoElasticFrictionInteraction.cpp:
Written by Laura Heredia and Pablo Richeri, 2009.
*/
#include "Model/HertzianViscoElasticFrictionInteraction.h"
#include "Foundation/console.h"
#include "tml/message/packed_message_interface.h"
CHertzianViscoElasticFrictionIGP::CHertzianViscoElasticFrictionIGP()
: AIGParam(), m_A(0.0), m_E(0.0), m_nu(0.0), mu(0.0), k_s(0.0), dt(0.0)
{
}
CHertzianViscoElasticFrictionIGP::CHertzianViscoElasticFrictionIGP(
const std::string &name,
double A,
double E,
double nu,
double fricCoef,
double shearK,
double dT
)
: AIGParam(name),
m_A(A),
m_E(E),
m_nu(nu),
mu(fricCoef),
k_s(shearK),
dt(dT)
{
}
CHertzianViscoElasticFrictionInteraction
::CHertzianViscoElasticFrictionInteraction()
{
m_A=0.0;
m_E=0.0;
m_nu=0.0;
m_dn=0.0;
m_mu=0.0;
m_r0=0.0;
m_ks=0.0;
m_dt=0.0;
m_is_slipping=false;
m_is_touching=false;
m_E_diss=0.0;
}
void CHertzianViscoElasticFrictionIGP::setTimeStepSize(double timeStepSize)
{
this->dt = timeStepSize;
}
/*!
constructor for CHertzianViscoElasticFrictionInteraction without friction
and viscoelastic parameters, only calls the constructor of APairInteraction
with the 2 particle pointers
*/
CHertzianViscoElasticFrictionInteraction
::CHertzianViscoElasticFrictionInteraction(
CParticle* p1,
CParticle* p2
)
: APairInteraction(p1,p2)
{
m_is_slipping=false;
m_is_touching=false;
m_E_diss=0.0;
}
CHertzianViscoElasticFrictionInteraction
::CHertzianViscoElasticFrictionInteraction(
CParticle* p1,
CParticle* p2,
const CHertzianViscoElasticFrictionIGP& param
)
: APairInteraction(p1,p2)
{
m_A=param.m_A;
m_E=param.m_E;
m_nu=param.m_nu;
m_dn=0.0;
m_mu=param.mu;
m_ks=param.k_s;
m_r0=p1->getRad()+p2->getRad();
m_dt=param.dt;
m_cpos=p1->getPos()+((p2->getPos()-p1->getPos())*p1->getRad()/m_r0);
m_is_slipping=false;
m_is_touching=false;
m_E_diss=0.0;
}
CHertzianViscoElasticFrictionInteraction
::~CHertzianViscoElasticFrictionInteraction()
{
}
void CHertzianViscoElasticFrictionInteraction::setTimeStepSize(double dt)
{
m_dt = dt;
}
/*!
Calculate viscoelastic and frictional forces.
*/
void CHertzianViscoElasticFrictionInteraction::calcForces()
{
// calculate distance
Vec3 D=m_p1->getPos()-m_p2->getPos();
double dist=D*D;
double eq_dist=m_p1->getRad()+m_p2->getRad();
// check if there is contact
if(dist<(eq_dist*eq_dist))
{ // contact -> calculate forces
//--- viscoelastic force ---
double R_ij=1.0/(1.0/m_p1->getRad()+1.0/m_p2->getRad());
dist=sqrt(dist);
m_dn=eq_dist-dist;
Vec3 dir=D.unit();
//Calculate d m_dn / dt
double ex=D.X()/dist;
double ey=D.Y()/dist;
double ez=D.Z()/dist;
double dvx=m_p1->getVel().X()-m_p2->getVel().X();
double dvy=m_p1->getVel().Y()-m_p2->getVel().Y();
double dvz=m_p1->getVel().Z()-m_p2->getVel().Z();
double m_dn_dot=-(ex*dvx+ey*dvy+ez*dvz);
double norm_m_normal_force =
(2.0*m_E*sqrt(R_ij)) /
(3.0*(1.0-m_nu*m_nu)) *
(pow(m_dn,1.5)+m_A*sqrt(m_dn)*m_dn_dot);
m_normal_force =
norm_m_normal_force < 0 ?
Vec3(0.0,0.0,0.0) :
dir*norm_m_normal_force;
Vec3 pos=m_p2->getPos()+(m_p2->getRad()/eq_dist)*D;
// apply viscoelastic force
m_p1->applyForce(m_normal_force,pos);
m_p2->applyForce(-1.0*m_normal_force,pos);
//--- frictional force ---
// particle movement since last timestep
const Vec3 d1=m_p1->getVel()*m_dt;
const Vec3 d2=m_p2->getVel()*m_dt;
Vec3 dFF=m_ks*(d2-d1);
// Compute tangential part by subtracting off normal component.
dFF -= ((dFF*D)/(D.norm2()))*D;
m_Ffric+=dFF;
const double FfricNorm = m_Ffric.norm();
const double forceNorm = m_normal_force.norm();
// decide static/dynamic
if (FfricNorm > forceNorm*m_mu)
{ // tangential force greater than static friction -> dynamic
m_Ffric=m_Ffric*((m_mu*forceNorm)/FfricNorm);
m_force_deficit=Vec3(0.0,0.0,0.0);
m_is_slipping=true;
m_E_diss=m_mu*fabs(m_normal_force*(d2-d1)); // energy dissipated
}
else if (FfricNorm > 0.0)
{ // static friction
m_is_slipping=false;
m_E_diss=0.0; // no energy dissipated
}
else
{ // no frictional force -> force deficit=mu*F_n
m_is_slipping=false;
m_E_diss=0.0; // no energy dissipated
}
m_p1->applyForce(m_Ffric, pos);
m_p2->applyForce(-1.0*m_Ffric, pos);
m_cpos=pos;
m_is_touching=true;
}
else
{ // no contact -> all forces are 0
m_Ffric=Vec3(0.0,0.0,0.0);
m_normal_force=Vec3(0.0,0.0,0.0);
m_is_slipping=false;
m_is_touching=false;
m_E_diss=0.0; // no energy dissipated
}
}
bool CHertzianViscoElasticFrictionInteraction::isPersistent()
{
const Vec3 D=m_p1->getPos()-m_p2->getPos();
const double dist=D*D;
const double eq_dist=m_p1->getRad()+m_p2->getRad();
return (dist <= (eq_dist*eq_dist));
}
/*!
get the force needed to overcome friction and make the interaction slip
*/
double CHertzianViscoElasticFrictionInteraction::getAbsForceDeficit()const
{
return m_force_deficit.norm();
}
/*!
get current frictional/stopping force
*/
pair<bool,double>
CHertzianViscoElasticFrictionInteraction::getAbsFrictionalForce() const
{
pair<bool,double> res;
// calculate distance
Vec3 D=m_p1->getPos()-m_p2->getPos();
double dist=D*D;
double eq_dist=m_p1->getRad()+m_p2->getRad();
// check if there is contact
if(dist<(eq_dist*eq_dist))
{
res.first=true;
res.second=m_Ffric.norm();
}
else
{
res.first=false;
}
return res;
}
/*!
get current frictional/stopping stress (f_fric/r^2)
*/
pair<bool,double>
CHertzianViscoElasticFrictionInteraction::getAbsFrictionalStress() const
{
pair<bool,double> res;
// calculate distance
Vec3 D=m_p1->getPos()-m_p2->getPos();
double dist=D*D;
double eq_dist=m_p1->getRad()+m_p2->getRad();
// check if there is contact
if(dist<(eq_dist*eq_dist))
{
res.first=true;
double Ac=eq_dist*eq_dist*0.7854; // contact area
res.second=m_Ffric.norm()/Ac;
}
else
{
res.first=false;
}
return res;
}
/*!
get max. frictional force, i.e. coeff. of friction * normal force
*/
pair<bool,double> CHertzianViscoElasticFrictionInteraction::getAbsMuFN() const
{
pair<bool,double> res;
// calculate distance
Vec3 D=m_p1->getPos()-m_p2->getPos();
double dist=D*D;
double eq_dist=m_p1->getRad()+m_p2->getRad();
// check if there is contact
if(dist<(eq_dist*eq_dist))
{ // contact -> calculate forces
//--- viscoelastic force ---
double R_ij=1.0/(1.0/m_p1->getRad()+1.0/m_p2->getRad());
dist=sqrt(dist);
double dn=eq_dist-dist;
Vec3 dir=D.unit();
//Calculate d m_dn / dt
double ex=D.X()/dist;
double ey=D.Y()/dist;
double ez=D.Z()/dist;
double dvx=m_p1->getVel().X()-m_p2->getVel().X();
double dvy=m_p1->getVel().Y()-m_p2->getVel().Y();
double dvz=m_p1->getVel().Z()-m_p2->getVel().Z();
double m_dn_dot=-(ex*dvx+ey*dvy+ez*dvz);
double norm_force =
(2.0*m_E*sqrt(R_ij)) /
(3.0*(1.0-m_nu*m_nu)) *
(pow(dn,1.5)+m_A*sqrt(dn)*m_dn_dot);
Vec3 force = norm_force < 0 ? Vec3(0.0,0.0,0.0) : dir*norm_force;
res.first=true;
res.second=force.norm();
}
else
{
res.first=false;
}
return res;
}
/*!
get max. frictional stress, i.e. coeff. of friction * normal stress
*/
pair<bool,double>
CHertzianViscoElasticFrictionInteraction::getMaxFricStress() const
{
pair<bool,double> res;
// calculate distance
Vec3 D=m_p1->getPos()-m_p2->getPos();
double dist=D*D;
double eq_dist=m_p1->getRad()+m_p2->getRad();
// check if there is contact
if(dist<(eq_dist*eq_dist))
{ // contact -> calculate forces
//--- viscoelastic force ---
double R_ij=1.0/(1.0/m_p1->getRad()+1.0/m_p2->getRad());
dist=sqrt(dist);
double dn=eq_dist-dist;
Vec3 dir=D.unit();
//Calculate d m_dn / dt
double ex=D.X()/dist;
double ey=D.Y()/dist;
double ez=D.Z()/dist;
double dvx=m_p1->getVel().X()-m_p2->getVel().X();
double dvy=m_p1->getVel().Y()-m_p2->getVel().Y();
double dvz=m_p1->getVel().Z()-m_p2->getVel().Z();
double m_dn_dot=-(ex*dvx+ey*dvy+ez*dvz);
double norm_force =
(2.0*m_E*sqrt(R_ij)) /
(3.0*(1.0-m_nu*m_nu)) *
(pow(dn,1.5)+m_A*sqrt(dn)*m_dn_dot);
Vec3 force = norm_force < 0 ? Vec3(0.0,0.0,0.0) : dir*norm_force;
res.first=true;
double Ac=eq_dist*eq_dist*0.7854; // contact area
res.second=force.norm()/Ac;
}
else
{
res.first=false;
}
return res;
}
/*!
get current normal force
*/
pair<bool,double> CHertzianViscoElasticFrictionInteraction::getAbsFN() const
{
return make_pair(m_is_touching,m_normal_force.norm());
}
/*!
get current normal stress
*/
pair<bool,double>
CHertzianViscoElasticFrictionInteraction::getNormalStress() const
{
pair<bool,double> res;
if(m_is_touching){
res.first=true;
double eq_dist=m_p1->getRad()+m_p2->getRad();
double Ac=eq_dist*eq_dist*0.7854; // contact area
res.second=m_normal_force.norm()/Ac;
} else {
res.first=false;
}
return res;
}
/*!
get "force deficit", i.e. the force needed to make the contact dynamic
*/
/*!
get the slipping velocity, i.e. the absolute value of the
tangential part of the relatve particle velocity
*/
pair<bool,double>
CHertzianViscoElasticFrictionInteraction::getSlipVelocity() const
{
pair<bool,double> res;
// calculate distance
Vec3 D=m_p1->getPos()-m_p2->getPos();
if(D.norm()<=(m_p1->getRad()+m_p2->getRad()))
{ // if contact
// normal
Vec3 normal=D.unit();
// relative velocity
Vec3 v_rel=m_p2->getVel()-m_p1->getVel();
// tangential component
Vec3 v_tan=v_rel-(v_rel*normal)*normal;
res=make_pair(true,v_tan.norm());
} else {
res.first=false;
}
return res;
}
/*!
get the potential energy stored in the interaction
*/
double CHertzianViscoElasticFrictionInteraction::getPotentialEnergy() const
{
const double e_pot_norm=0.5*m_normal_force*m_normal_force/m_E;
return e_pot_norm;
}
/*!
Get the static/dynamic status of the interaction. Returns 1 for a contact in
dynamic friction, 0 for static or no contact
*/
double CHertzianViscoElasticFrictionInteraction::getSlipping() const
{
const double res=m_is_slipping ? 1.0 : 0.0;
return res;
}
/*!
Get "sticking" contacts, i.e. return 1 if the contact is touching but not
slipping, 0 otherwise
*/
double CHertzianViscoElasticFrictionInteraction::getSticking() const
{
const double res=(m_is_touching && !m_is_slipping) ? 1.0 : 0.0;
return res;
}
/*!
return the amount of energy dissipated during the last time step
*/
double CHertzianViscoElasticFrictionInteraction::getDissipatedEnergy() const
{
return m_E_diss;
}
/*!
get net force on particle1 imposed by this interaction.
Returns Vec3::ZERO if particles are not in contact.
*/
Vec3 CHertzianViscoElasticFrictionInteraction::getForce() const
{
const Vec3 f=m_is_touching ? m_Ffric-m_normal_force : Vec3(0.0,0.0,0.0);
return f;
}
/*!
If the particles are in contact, get normal force, if not in contact return
(0,0,0)
*/
Vec3 CHertzianViscoElasticFrictionInteraction::getNormalForce() const
{
const Vec3 f=m_is_touching ? m_normal_force : Vec3(0.0,0.0,0.0);
return f;
}
/*!
return 1 if particles are in contact, 0 otherwise
*/
double CHertzianViscoElasticFrictionInteraction::Count() const
{
double res=m_is_touching ? 1.0 : 0.0;
return res;
}
/*!
Calculate effective coefficient of friction for this interaction for a given
direction of the applied shear force. If the effective coefficient of
friction is infinite, -1 is returned.
\param dir the direction of the applied shear force
\return the effective coefficient of friction if it is finite, -1 otherwise
and -2 for no contact
*/
pair<bool,double> CHertzianViscoElasticFrictionInteraction::getMuEff(
const Vec3& dir,
const Vec3& norm
) const
{
pair<bool,double> res;
CParticle* p1;
CParticle* p2;
// sort particles, so that p1 is "above" the slip plane
const Vec3 h=m_p1->getPos()-m_p2->getPos();
if(h*norm>0.0)
{
p1=m_p1;
p2=m_p2;
}
else
{
p1=m_p2;
p2=m_p1;
}
// get contact normal
Vec3 nc=p1->getPos()-p2->getPos();
// get distance
double dist=nc.norm();
// check if contact
if(dist<=(p1->getRad()+p2->getRad()))
{ // if contact
// get direction of current movement
Vec3 d=p1->getVel()-p2->getVel();
// get tangential part
d-=(d*nc.unit())*nc.unit();
// calculate effective coefficient of friction
double h1=(dir.unit()*d.unit())-m_mu*(dir.unit()*nc.unit());
double h2=m_mu*(norm.unit()*nc.unit())+(norm.unit()*d.unit());
if(h1>0)
{
res.first=true;
res.second=h2/h1;
}
else
{
res.first=false;
}
cout << "positions : " << p1->getPos() << " , " << p2->getPos() << endl;
cout << "velocities: " << p1->getVel() << " , " << p2->getVel() << endl;
cout << "v_tan : " << d << endl;
cout << "h1,h2 : " << h1 << " , " << h2 << endl;
cout << "mu_eff : " << res.second << endl;
}
else
{
res.first=false;
}
return res;
}
/*!
Get the particle member function which returns a scalar field of a given name.
\param name the name of the field
*/
CHertzianViscoElasticFrictionInteraction::ScalarFieldFunction
CHertzianViscoElasticFrictionInteraction::getScalarFieldFunction(
const string& name
)
{
CHertzianViscoElasticFrictionInteraction::ScalarFieldFunction sf;
if (name=="potential_energy")
{
sf=&CHertzianViscoElasticFrictionInteraction::getPotentialEnergy;
}
else if (name=="slipping")
{
sf=&CHertzianViscoElasticFrictionInteraction::getSlipping;
}
else if (name=="sticking")
{
sf=&CHertzianViscoElasticFrictionInteraction::getSticking;
}
else if (name=="count")
{
sf=&CHertzianViscoElasticFrictionInteraction::Count;
}
else if (name=="dissipated_energy")
{
sf=&CHertzianViscoElasticFrictionInteraction::getDissipatedEnergy;
}
else
{
sf=NULL;
cerr
<< "ERROR - invalid name for interaction scalar access function"
<< endl;
}
return sf;
}
/*!
Get the particle member function which returns a checked scalar field of a given name.
\param name the name of the field
*/
CHertzianViscoElasticFrictionInteraction::CheckedScalarFieldFunction
CHertzianViscoElasticFrictionInteraction::getCheckedScalarFieldFunction(
const string& name
)
{
CHertzianViscoElasticFrictionInteraction::CheckedScalarFieldFunction sf;
if (name=="mu_eff_xy")
{
sf=&CHertzianViscoElasticFrictionInteraction::getMuEffXY;
}
else if (name=="mu_eff_xz")
{
sf=&CHertzianViscoElasticFrictionInteraction::getMuEffXZ;
}
else if (name=="f_fric")
{
sf=&CHertzianViscoElasticFrictionInteraction::getAbsFrictionalForce;
}
else if (name=="fric_stress")
{
sf=&CHertzianViscoElasticFrictionInteraction::getAbsFrictionalStress;
}
else if (name=="f_normal")
{
sf=&CHertzianViscoElasticFrictionInteraction::getAbsFN;
}
else if (name=="normal_stress")
{
sf=&CHertzianViscoElasticFrictionInteraction::getNormalStress;
}
else if (name=="muF_n")
{
sf=&CHertzianViscoElasticFrictionInteraction::getAbsMuFN;
}
else if (name=="max_fric_stress")
{
sf=&CHertzianViscoElasticFrictionInteraction::getMaxFricStress;
}
else if (name=="v_slip")
{
sf=&CHertzianViscoElasticFrictionInteraction::getSlipVelocity;
}
else
{
sf=NULL;
cerr
<< "ERROR - invalid name for interaction scalar access function"
<< endl;
}
return sf;
}
/*!
Get the particle member function which returns a vector field of a given name.
\param name the name of the field
*/
CHertzianViscoElasticFrictionInteraction::VectorFieldFunction
CHertzianViscoElasticFrictionInteraction::getVectorFieldFunction(
const string& name
)
{
CHertzianViscoElasticFrictionInteraction::VectorFieldFunction vf;
if (name=="force"){
vf=&CHertzianViscoElasticFrictionInteraction::getForce;
} else if (name=="normal_force") {
vf = &CHertzianViscoElasticFrictionInteraction::getNormalForce;
} else {
vf=NULL;
cerr
<< "ERROR - invalid name for interaction vector access function"
<< endl;
}
return vf;
}
/*!
Pack a CHertzianViscoElasticFrictionInteraction into a TML packed message
\param I the interaction
*/
template<>
void TML_PackedMessageInterface
::pack<CHertzianViscoElasticFrictionInteraction>(
const CHertzianViscoElasticFrictionInteraction& I
)
{
append(I.m_r0);
append(I.m_A);
append(I.m_E);
append(I.m_nu);
append(I.m_dn);
append(I.m_mu);
append(I.m_ks);
append(I.m_dt);
append(I.m_id[0]);
append(I.m_id[1]);
append(I.m_Ffric);
}
/*!
Unpack a CHertzianViscoElasticFrictionInteraction from a TML packed message
\param I the interaction
*/
template<>
void TML_PackedMessageInterface
::unpack<CHertzianViscoElasticFrictionInteraction>(
CHertzianViscoElasticFrictionInteraction& I
)
{
I.m_r0=pop_double();
I.m_A=pop_double();
I.m_E=pop_double();
I.m_nu=pop_double();
I.m_dn=pop_double();
I.m_mu=pop_double();
I.m_ks=pop_double();
I.m_dt=pop_double();
I.m_id.erase(I.m_id.begin(),I.m_id.end());
I.m_id.push_back(pop_int());
I.m_id.push_back(pop_int());
I.m_Ffric=pop_vec3();
}
ostream& operator<<(
ostream& ost,
const CHertzianViscoElasticFrictionInteraction& BI
)
{
ost << "[" << BI.m_p1->getID() << " - " << BI.m_p2->getID() << "]";
return ost;
}
|