39 #include <sys/types.h>
112 std::cerr <<
"MD problem constructor finished " << std::endl;
133 static int width =
ene_file.precision() + 6;
135 << std::setw(width) <<
"t" <<
" "
136 << std::setw(width) <<
"ene_gra" <<
" "
137 << std::setw(width) <<
"ene_kin" <<
" "
138 << std::setw(width) <<
"ene_rot" <<
" "
139 << std::setw(width) <<
"ene_ela" <<
" "
140 << std::setw(width) <<
"X_COM" <<
" "
141 << std::setw(width) <<
"Y_COM" <<
" "
142 << std::setw(width) <<
"Z_COM" << std::endl;
177 Mdouble ene_kin = 0, ene_rot = 0, ene_gra = 0, mass_sum= 0, x_masslength=0, y_masslength=0, z_masslength=0;
181 ene_kin += .5 * (*it)->get_Mass() * (*it)->get_Velocity().GetLength2();
182 ene_rot += .5 * (*it)->get_Inertia() * (*it)->get_AngularVelocity().GetLength2();
183 ene_gra -= (*it)->get_Mass() * Dot(
get_gravity(),(*it)->get_Position());
184 mass_sum+= (*it)->get_Mass();
185 x_masslength +=(*it)->get_Mass()*(*it)->get_Position().X;
186 y_masslength +=(*it)->get_Mass()*(*it)->get_Position().Y;
187 z_masslength +=(*it)->get_Mass()*(*it)->get_Position().Z;
191 static int width =
ene_file.precision() + 6;
193 <<
" " << std::setw(width) << ene_gra
194 <<
" " << std::setw(width) << ene_kin
195 <<
" " << std::setw(width) << ene_rot
197 <<
" " << std::setw(width) << (mass_sum?x_masslength/mass_sum:std::numeric_limits<double>::quiet_NaN())
198 <<
" " << std::setw(width) << (mass_sum?y_masslength/mass_sum:std::numeric_limits<double>::quiet_NaN())
199 <<
" " << std::setw(width) << (mass_sum?z_masslength/mass_sum:std::numeric_limits<double>::quiet_NaN())
228 <<
xmax <<
" " <<
ymax <<
" " << std::endl;
232 <<
xmax <<
" " <<
ymax <<
" " <<
zmax <<
" " << std::endl;
237 std::cerr <<
"Have output the properties of the problem to disk " << std::endl;
253 data_file.open( filename, std::fstream::in);
255 std::cout <<
"Loading data file " << filename <<
" failed" << std::endl;
275 file.open( filename, std::fstream::in);
276 if (!file.is_open()||file.bad()) {
291 file >> integerValue;
309 else if (integerValue==1)
319 else if (integerValue==5)
333 else if (integerValue==6)
345 std::cerr <<
"Error in par.ini: line 1, value 1 is " << integerValue << std::endl;
350 file >> integerValue;
361 if (doubleValue<0)
set_t(0);
371 if (doubleValue>=0) {
373 int savecount = round(doubleValue/
get_dt());
379 savecount = round(doubleValue/
get_dt());
388 std::cerr <<
"Error in par.ini: line 3, value 1 is " << doubleValue << std::endl;
409 if (doubleValue) std::cerr <<
"Warning in par.ini: ignored background damping " << doubleValue << std::endl;
415 if (doubleValue) std::cerr <<
"Warning in par.ini: ignored growth rate " << doubleValue << std::endl;
419 if (doubleValue) std::cerr <<
"Warning in par.ini: ignored target volume_fraction " << doubleValue << std::endl;
445 if (verbose) std::cout <<
"Jumping file counter: "<<
get_file_counter() << std::endl;
477 static unsigned int N;
505 std::cout <<
"Number of particles read from file "<<N << std::endl;
518 Vec3D position,velocity;
529 (*it)->set_Position(position);
530 (*it)->set_Velocity(velocity);
531 (*it)->set_Angle(
Vec3D(0.0,0.0,0.0));
532 (*it)->set_AngularVelocity(
Vec3D(0.0,0.0,0.0));
533 (*it)->set_Radius(radius);
534 (*it)->compute_particle_mass(
Species);
546 Vec3D position,velocity,angle,angularVelocity;
557 (*it)->set_Position(position);
558 (*it)->set_Velocity(velocity);
559 (*it)->set_Angle(-angle);
560 (*it)->set_AngularVelocity(-angularVelocity);
561 (*it)->set_Radius(radius);
562 (*it)->compute_particle_mass(
Species);
571 Vec3D position,velocity,angle,angularVelocity;
580 (*it)->set_Position(position);
581 (*it)->set_Velocity(velocity);
582 (*it)->set_Angle(angle);
583 (*it)->set_AngularVelocity(angularVelocity);
584 (*it)->set_Radius(radius);
585 (*it)->compute_particle_mass(
Species);
594 Vec3D position,velocity,angle,angularVelocity;
603 (*it)->set_Position(position);
604 (*it)->set_Velocity(velocity);
605 (*it)->set_Angle(angle);
606 (*it)->set_AngularVelocity(angularVelocity);
607 (*it)->set_Radius(radius);
608 (*it)->compute_particle_mass(
Species);
635 std::string header_string;
637 std::stringstream header (std::stringstream::in | std::stringstream::out);
638 header << header_string;
643 header >> N >> t >> xmin >> ymin >> zmin >> xmax >> ymax >>
zmax;
646 if (header.eof())
return 2;
655 std::stringstream restart_filename;
656 restart_filename.str(
"");
657 restart_filename <<
problem_name.str().c_str() <<
".restart";
661 restart_filename <<
".";
666 save_restart_data_counter++;
669 std::ofstream restart_data(restart_filename.str().c_str());
670 restart_data.precision(8);
671 if( restart_data.good() )
674 restart_data.close();
676 std::cerr <<
"restart_data " << restart_filename.str() <<
" could not be saved" << std::endl;
686 std::stringstream restart_filename;
687 restart_filename.str(
"");
688 restart_filename <<
problem_name.str().c_str() <<
".restart";
693 std::ifstream restart_data(filename.c_str());
694 if( restart_data.good() )
697 restart_data.close();
701 std::cerr <<
"restart_data " << filename <<
" could not be loaded from " << filename << std::endl;
714 if(TangentialSpring==NULL)
718 if(TangentialSpring==NULL)
737 return TangentialSpring;
746 if(TangentialSpring==NULL)
749 return TangentialSpring;
807 {PI=P2;PJ=P1;PJreal=P1;isPeriodic=
false;}
809 {PI=P1;PJ=P2;PJreal=P2;isPeriodic=
false;}
811 {PI=P1;PJ=P2;PJreal=P2Per;isPeriodic=
true;}
814 {PI=P2;PJ=P1;PJreal=P1Per;isPeriodic=
true;}
819 std::cerr <<
"In computing internal forces between particle "<<PI->
get_Position()<<
" and "<<PJ->
get_Position()<<std::endl;
826 #ifdef DEBUG_OUTPUT_FULL
827 std::cerr <<
"Square of distance between " << dist_squared <<
" square sum of radii " << radii_sum*radii_sum <<std::endl;
831 if (dist_squared<(interactionRadii_sum*interactionRadii_sum))
838 Mdouble dist=sqrt(dist_squared);
846 Mdouble deltan = std::max(0.0,radii_sum-dist);
871 Mdouble vdotn=-Dot(vrel,normal);
884 Mdouble kn = 4./3. * pSpecies->
k * a;
885 fdotn += kn * deltan + pSpecies->
disp*vdotn;
887 fdotn += pSpecies->
k*deltan+pSpecies->
disp*vdotn;
889 force += normal * fdotn;
903 Vec3D vrelt=vrel+normal*vdotn;
925 Mdouble kt = 8. * pSpecies->
kt * a * pow(1- GetLength(forcet)/pSpecies->
mu/fdotn,0.33);
929 forcet = (-pSpecies->
dispt) * vrelt - pSpecies->
kt * (*delta);
937 double muact=(TangentialSpring->
sliding)?(pSpecies->
mu):(pSpecies->
mus);
938 if( forcet2 <=
sqr(muact*norm_fn) ) {
940 TangentialSpring->
sliding=
false;
943 TangentialSpring->
sliding=
true;
945 Mdouble norm_forcet = sqrt(forcet2);
946 forcet *= pSpecies->
mu * norm_fn / norm_forcet;
958 if (vdott*pSpecies->
dispt <= pSpecies->
mus*norm_fn) {
959 forcet = -pSpecies->
dispt * vrelt;
962 forcet = -(pSpecies->
mu * norm_fn / vdott) * vrelt;
974 Mdouble reducedRadiusIJ = 2.0*reducedRadiusI*reducedRadiusJ/(reducedRadiusI+reducedRadiusJ);
980 (*RollingSpring) += vrolling *
get_dt();
983 forcerolling = (-pSpecies->
disprolling) * vrolling - pSpecies->
krolling * (*RollingSpring);
990 if( forcerolling2 <=
sqr(muact*norm_fn) ) {
996 forcerolling *= pSpecies->
murolling * norm_fn / sqrt(forcerolling2);
997 (*RollingSpring) = (forcerolling + pSpecies->
disprolling * vrolling)/(-pSpecies->
krolling);
1001 Vec3D Torque = reducedRadiusIJ *
Cross(normal, forcerolling);
1019 (*TorsionSpring) = Dot((*TorsionSpring) + vtorsion *
get_dt(),normal)*normal;
1022 forcetorsion = (-pSpecies->
disptorsion) * vtorsion - pSpecies->
ktorsion * (*TorsionSpring);
1029 if( forcetorsion2 <=
sqr(muact*norm_fn) ) {
1036 forcetorsion *= pSpecies->
mutorsion * norm_fn / sqrt(forcetorsion2);
1037 (*TorsionSpring) = (forcetorsion + pSpecies->
disptorsion * vtorsion)/(-pSpecies->
ktorsion);
1041 Vec3D torque = RadiusIJ * forcetorsion;
1054 force += fdotn*normal;
1104 << radii_sum-dist <<
" "
1105 << deltat_norm <<
" "
1109 << -(fdott?forcet/fdott:forcet) << std::endl;
1111 if (!PJreal->
isFixed()&&!isPeriodic)
1119 << radii_sum-dist <<
" "
1120 << deltat_norm <<
" "
1124 << (fdott?forcet/fdott:forcet) << std::endl;
1127 #ifdef FOLLOWPARTICLE
1129 std::cout<<
"Particle collission at time="<<
get_t()<<
" between "<<PI->
get_Index()<<
" and "<<PJ->
get_Index()<<std::endl;
1163 {PI=P2;PJ=P1;PJreal=PJ;}
1165 {PI=P1;PJ=P2;PJreal=PJ;}
1169 {PI=P1;PJ=P2;PJreal=P2Per;}
1175 {PI=P2;PJ=P1;PJreal=P1Per;}
1181 std::cerr <<
"In computing interal forces between particle "<<PI->
get_Position()<<
" and "<<PJ->
get_Position()<<std::endl;
1189 #ifdef DEBUG_OUTPUT_FULL
1190 std::cerr <<
"Square of distance between " << dist_squared <<
" square sum of radii " << radii_sum*radii_sum <<std::endl;
1194 if (dist_squared<(interactionRadii_sum*interactionRadii_sum))
1201 Mdouble dist=sqrt(dist_squared);
1208 Mdouble deltan = std::max(0.0,radii_sum-dist);
1224 if (!pSpecies->
mu) {
1234 Mdouble vdotn=-Dot(vrel,normal);
1238 fdotn += pSpecies->
disp*vdotn;
1254 *deltamax = std::min(deltastar,std::max(*deltamax,deltan));
1258 if (deltan>deltastar) {
1259 k2 = pSpecies->
k2max;
1261 k2 = pSpecies->
k+(pSpecies->
k2max-pSpecies->
k)*((*deltamax)/deltastar);
1265 Mdouble delta0 = (k2-pSpecies->
k)/k2*(*deltamax);
1269 if (deltan>deltastar) {
1270 fdotn += pSpecies->
k2max*(deltan-(delta0));
1271 }
else if (k2*(deltan-(delta0))>=pSpecies->
k*deltan){
1272 fdotn += pSpecies->
k*deltan;
1273 }
else if (k2*(deltan-delta0)>=-pSpecies->
kc*deltan){
1274 fdotn += k2*(deltan-delta0);
1276 fdotn += -pSpecies->
kc*deltan;
1277 *deltamax=(k2+pSpecies->
kc)/(k2-pSpecies->
k)*deltan;
1280 force = normal * fdotn;
1288 Vec3D vrelt=vrel+normal*vdotn;
1294 Mdouble norm_fn = fabs(fdotn);
1296 if (!pSpecies->
kt) {
1300 if (vdott*pSpecies->
dispt <= pSpecies->
mus*norm_fn) {
1301 forcet = -pSpecies->
dispt * vrelt;
1304 forcet = -(pSpecies->
mu * norm_fn / vdott) * vrelt;
1319 forcet = (-pSpecies->
dispt) * vrelt - pSpecies->
kt * deltat;
1325 if( forcet2 <=
sqr(pSpecies->
mus*norm_fn) ) {
1329 Mdouble norm_forcet = sqrt(forcet2);
1330 forcet *= pSpecies->
mu * norm_fn / norm_forcet;
1332 (*delta) = -(forcet + pSpecies->
dispt * vrelt)/pSpecies->
kt;
1343 force = fdotn*normal;
1379 << radii_sum-dist <<
" "
1380 << deltat_norm <<
" "
1384 << -(fdott?forcet/fdott:forcet) << std::endl;
1394 << radii_sum-dist <<
" "
1395 << deltat_norm <<
" "
1399 << (fdott?forcet/fdott:forcet) << std::endl;
1462 if (!pSpecies->
mu) {
1469 Mdouble vdotn = -Dot(vrel, normal);
1481 Mdouble kn = 4./3. * pSpecies->
k * a;
1482 fdotn += kn*deltan - 2*pSpecies->
disp*sqrt(pI->
get_Mass()*2.*pSpecies->
k * a)*vdotn;
1484 fdotn += pSpecies->
k*deltan - pSpecies->
disp*vdotn;
1486 force = normal * (-fdotn);
1495 Mdouble norm_fn = fabs(fdotn);
1500 Vec3D vrelt=vrel+normal*vdotn;
1508 (*delta) += vrelt *
get_dt();
1522 if (
get_t()<0.034/10) {
1524 kt = 8. * pSpecies->
kt * a * pow(1.001- GetLength(forcet)/pSpecies->
mus/fdotn,1./3.);
1525 }
else if (Dot(vrelt,forcet)<=0) {
1527 kt = 8. * pSpecies->
kt * a * pow(.501 - .5 * GetLength(forcet)/pSpecies->
mus/fdotn,1./3.);
1530 kt = 8. * pSpecies->
kt * a * pow(.501 + .5* GetLength(forcet)/pSpecies->
mus/fdotn,1./3.);
1535 forcet = (-pSpecies->
dispt) * vrelt - pSpecies->
kt * (*delta);
1543 double muact=(TangentialSpring->
sliding)?(pSpecies->
mu):(pSpecies->
mus);
1544 if( forcet2 <=
sqr(muact*norm_fn) ) {
1546 TangentialSpring->
sliding=
false;
1549 TangentialSpring->
sliding=
true;
1550 Mdouble norm_forcet = sqrt(forcet2);
1551 forcet *= pSpecies->
mu * norm_fn / norm_forcet;
1563 if (vdott*pSpecies->
dispt <= pSpecies->
mus*norm_fn) {
1564 forcet = -pSpecies->
dispt * vrelt;
1567 forcet = -(pSpecies->
mu * norm_fn / vdott) * vrelt;
1580 Mdouble reducedRadiusIJ = reducedRadiusI;
1586 (*RollingSpring) += vrolling *
get_dt();
1589 forcerolling = (-pSpecies->
disprolling) * vrolling - pSpecies->
krolling * (*RollingSpring);
1596 if( forcerolling2 <=
sqr(muact*norm_fn) ) {
1600 forcerolling *= pSpecies->
murolling * norm_fn / sqrt(forcerolling2);
1601 (*RollingSpring) = (forcerolling + pSpecies->
disprolling * vrolling)/(-pSpecies->
krolling);
1605 Vec3D Torque = reducedRadiusIJ *
Cross(normal, forcerolling);
1624 (*TorsionSpring) = Dot((*TorsionSpring) + vtorsion *
get_dt(),normal)*normal;
1627 forcetorsion = (-pSpecies->
disptorsion) * vtorsion - pSpecies->
ktorsion * (*TorsionSpring);
1634 if( forcetorsion2 <=
sqr(muact*norm_fn) ) {
1641 forcetorsion *= pSpecies->
mutorsion * norm_fn / sqrt(forcetorsion2);
1642 (*TorsionSpring) = (forcetorsion + pSpecies->
disptorsion * vtorsion)/(-pSpecies->
ktorsion);
1646 Vec3D Torque = RadiusIJ * forcetorsion;
1652 Torque = 20 * a * forcetorsion;
1663 force += (-fdotn)*normal;
1695 << -(
static_cast<int>(i)+1) <<
" "
1698 << deltat_norm <<
" "
1702 << -(fdott?forcet/fdott:forcet) << std::endl;
1723 if(TangentialSpring==NULL)
1728 if(TangentialSpring==NULL)
1748 fdotn = std::min(0.0,pSpecies->
k0*std::max(dist-pI->
get_Radius(),0.0)-pSpecies->
f0);
1754 if(TangentialSpring==NULL)
1760 fdotn = std::min(0.0,pSpecies->
k0*std::max(dist-pI->
get_Radius(),0.0)-pSpecies->
f0);
1775 #ifdef USE_SIMPLE_VERLET_INTEGRATION
1777 #else //use velocity verlet
1788 #ifdef FOLLOWPARTICLE
1790 std::cout<<
"In integration before time="<<
get_t()<<
", particle "<<FPID<<
": "<<*iP<<std::endl;
1807 os <<
"problem_name:" <<
problem_name.str().c_str() << std::endl;
1809 os <<
" x:[" <<
xmin <<
"," <<
xmax <<
"], y:[" <<
ymin <<
"," <<
ymax <<
"], z:[" <<
zmin <<
"," <<
zmax <<
"]" << std::endl;
1810 os <<
" dim:" <<
dim <<
", gravity:" <<
gravity << std::endl;
1812 os <<
" ";
Species[0].print(os); os << std::endl;
1814 os <<
" Species: size:" <<
Species.size() << std::endl;
1815 for (
unsigned int i=0; i<
Species.size(); i++) {
1816 os <<
" ";
Species[i].print(os); os << std::endl;
1817 for (
unsigned int j=0; j<
Species[i].MixedSpecies.size(); j++) { os <<
" ";
Species[i].MixedSpecies[j].print(os); os << std::endl; }
1834 unsigned int n =
Species.size();
1835 Species.back().MixedSpecies.resize(n-1);
1836 for (
unsigned int i=0; i<n-1; i++)
1845 #ifdef USE_SIMPLE_VERLET_INTEGRATION
1847 static Vec3D xtemp, atemp;
1853 pI->PrevPosition=xtemp;
1877 #else //use velocity verlet
1881 #ifdef FOLLOWPARTICLE
1883 std::cout<<
"In integration after time="<<
get_t()<<
", particle "<<FPID<<
": "<<*pI<<std::endl;
1925 std::cout << std::setprecision(6) <<
t << std::endl;
1940 (*it)->set_Force(
Vec3D(0.0,0.0,0.0));
1941 (*it)->set_Torque(
Vec3D(0.0,0.0,0.0));
1945 (*it)->set_Force(
Vec3D(0.0,0.0,0.0));
1946 (*it)->set_Torque(
Vec3D(0.0,0.0,0.0));
1951 std::cerr <<
"Have all forces set to zero " << std::endl;
1967 #ifdef ContactListHgrid
1987 <<
"restart_version " << 3
1991 <<
"xmin " <<
xmin <<
" xmax " <<
xmax
1992 <<
" ymin " <<
ymin <<
" ymax " <<
ymax
1993 <<
" zmin " <<
zmin <<
" zmax " <<
zmax
2011 os<<
"Species " <<
Species.size() << std::endl;
2012 for (std::vector<CSpecies>::iterator it =
Species.begin(); it!=
Species.end(); ++it) {
2013 os << (*it) << std::endl;
2014 for (std::vector<CSpecies>::iterator it2 = it->MixedSpecies.begin(); it2!=it->MixedSpecies.end(); ++it2) os << (*it2) <<
" (mixed)" << std::endl;
2030 if (strcmp(dummy.c_str(),
"restart_version"))
2032 dim = atoi(dummy.c_str());
2068 if (!strcmp(dummy.c_str(),
"options_restart")) is >>
options_restart >> dummy;
2075 for (
unsigned int i=0; i<N; i++) {
2077 Species[i].MixedSpecies.resize(i);
2078 for (
unsigned int j=0; j<i; j++) {
2079 Species[i].MixedSpecies[j].read(is);
2083 std::stringstream line (std::stringstream::in | std::stringstream::out);
2088 for (
unsigned int i=0;i<N;i++)
2097 for (
unsigned int i=0;i<N;i++)
2106 for (
unsigned int i=0;i<N;i++)
2146 if (!strcmp(dummy.c_str(),
"options_restart")) is >>
options_restart >> dummy;
2154 for (
unsigned int i=0; i<N; i++) {
2156 Species[i].MixedSpecies.resize(i);
2157 for (
unsigned int j=0; j<i; j++) {
2158 Species[i].MixedSpecies[j].read(is);
2162 std::stringstream line (std::stringstream::in | std::stringstream::out);
2167 for (
unsigned int i=0;i<N;i++)
2176 for (
unsigned int i=0;i<N;i++)
2185 for (
unsigned int i=0;i<N;i++)
2202 <<
dt <<
" " <<
t <<
" " <<
tmax <<
" "
2210 for (std::vector<CSpecies>::iterator it =
Species.begin(); it!=
Species.end(); ++it) os << (*it) << std::endl;
2219 std::cout <<
"reading restart data version 1" << std::endl;
2231 unsigned int NParticles, NWalls, NBoundarys;
2237 for (std::vector<CSpecies>::iterator it =
Species.begin(); it!=
Species.end(); ++it) is >> (*it);
2239 std::stringstream line (std::stringstream::in | std::stringstream::out);
2242 for (
unsigned int i=0;i<NParticles;i++)
2249 for (
unsigned int i=0;i<NWalls;i++)
2255 for (
unsigned int i=0;i<NBoundarys;i++)
2269 std::cerr <<
"Entered solve" << std::endl;
2271 #ifdef ContactListHgrid
2272 std::cout <<
"Using ContactListHgrid"<<std::endl;
2292 std::cerr <<
"Have created the particles initial conditions " << std::endl;
2313 std::fstream::openmode mode;
2314 if (
append) mode=std::fstream::out|std::fstream::app;
2315 else mode=std::fstream::out;
2318 if(!
open_data_file(mode)) {std::cerr <<
"Problem opening data file aborting" << std::endl; exit(-1);}
2324 if(!
open_ene_file(mode)){std::cerr <<
"Problem opening ene file aborting" << std::endl; exit(-1);}
2330 if(!
open_fstat_file(mode)){std::cerr <<
"Problem opening fstat file aborting" << std::endl; exit(-1);}
2333 #ifdef USE_SIMPLE_VERLET_INTEGRATION
2334 std::cout <<
"using simple verlet integration" << std::endl;
2335 for (
int i = 0;i<Particles.size();i++)
2367 std::cerr <<
"Have computed the initial values for the forces " << std::endl;
2421 for (
unsigned int i=0;i<
Species.size();i++) {
2424 for (
unsigned int j=0;j<
Species[i].MixedSpecies.size();j++) {
2520 std::cout << std::endl;
2538 for (
unsigned int i = 1; i<argc; i+=2) {
2539 std::cout <<
"interpreting input argument " << argv[i];
2540 for (
unsigned int j = i+1; j<argc; j++) {
2541 if (argv[j][0]==
'-')
break;
2542 std::cout <<
" " << argv[j];
2544 std::cout << std::endl;
2547 std::cerr <<
"Warning: not all arguments read correctly!" << std::endl;
2557 if (!strcmp(argv[i],
"-name")) {
2559 }
else if (!strcmp(argv[i],
"-xmin")) {
2561 }
else if (!strcmp(argv[i],
"-ymin")) {
2563 }
else if (!strcmp(argv[i],
"-zmin")) {
2565 }
else if (!strcmp(argv[i],
"-xmax")) {
2567 }
else if (!strcmp(argv[i],
"-ymax")) {
2569 }
else if (!strcmp(argv[i],
"-zmax")) {
2574 }
else if (!strcmp(argv[i],
"-dt")) {
2577 std::cout <<
" reset dt from " << old <<
" to " <<
get_dt() << std::endl;
2578 }
else if (!strcmp(argv[i],
"-Hertzian")) {
2581 }
else if (!strcmp(argv[i],
"-tmax")) {
2584 std::cout <<
" reset tmax from " << old <<
" to " <<
get_tmax() << std::endl;
2585 }
else if (!strcmp(argv[i],
"-save_count") || !strcmp(argv[i],
"-savecount")) {
2587 }
else if (!strcmp(argv[i],
"-save_count_data")) {
2589 }
else if (!strcmp(argv[i],
"-save_count_fstat")) {
2591 }
else if (!strcmp(argv[i],
"-save_count_stat")) {
2593 }
else if (!strcmp(argv[i],
"-save_count_ene")) {
2595 }
else if (!strcmp(argv[i],
"-dim")) {
2597 }
else if (!strcmp(argv[i],
"-gravity")) {
2601 }
else if (!strcmp(argv[i],
"-options_fstat")) {
2603 }
else if (!strcmp(argv[i],
"-options_restart")) {
2605 }
else if (!strcmp(argv[i],
"-options_data")) {
2607 }
else if (!strcmp(argv[i],
"-options_stat")) {
2609 }
else if (!strcmp(argv[i],
"-options_ene")) {
2611 }
else if (!strcmp(argv[i],
"-auto_number")) {
2614 }
else if (!strcmp(argv[i],
"-number_of_saves")) {
2616 }
else if (!strcmp(argv[i],
"-restart")||!strcmp(argv[i],
"-r")) {
2620 std::string filename;
2623 if (i+1>=argc||argv[i+1][0]==
'-') {
2626 std::cout <<
get_name() << std::endl;
2627 }
else filename = argv[i+1];
2630 const char* fileextension = (filename.c_str()+std::max(0,(
int)filename.length()-8));
2631 if (strcmp(fileextension,
".restart"))
2632 filename=filename+
".restart";
2634 std::cout <<
"restart from " << filename << std::endl;
2636 }
else if (!strcmp(argv[i],
"-data")) {
2637 std::string filename = argv[i+1];
2639 }
else if (!strcmp(argv[i],
"-k")) {
2641 set_k(atof(argv[i+1]));
2642 std::cout <<
" reset k from " << old <<
" to " <<
get_k() << std::endl;
2643 }
else if (!strcmp(argv[i],
"-disp")) {
2646 std::cout <<
" reset disp from " << old <<
" to " <<
get_disp() << std::endl;
2647 }
else if (!strcmp(argv[i],
"-kt")) {
2650 std::cout <<
" reset kt from " << old <<
" to " <<
get_kt() << std::endl;
2651 }
else if (!strcmp(argv[i],
"-dispt")) {
2654 std::cout <<
" reset dispt from " << old <<
" to " <<
get_dispt() << std::endl;
2655 }
else if (!strcmp(argv[i],
"-krolling")) {
2658 std::cout <<
" reset krolling from " << old <<
" to " <<
get_krolling() << std::endl;
2659 }
else if (!strcmp(argv[i],
"-disprolling")) {
2662 std::cout <<
" reset disprolling from " << old <<
" to " <<
get_disprolling() << std::endl;
2663 }
else if (!strcmp(argv[i],
"-mu")) {
2666 std::cout <<
" reset mu from " << old <<
" to " <<
get_mu() << std::endl;
2667 }
else if (!strcmp(argv[i],
"-murolling")) {
2670 std::cout <<
" reset murolling from " << old <<
" to " <<
get_murolling() << std::endl;
2671 }
else if (!strcmp(argv[i],
"-randomise") || !strcmp(argv[i],
"-randomize")) {
2674 }
else if (!strcmp(argv[i],
"-k0")) {
2676 Species[0].set_k0(atof(argv[i+1]));
2677 std::cout <<
" reset k0 from " << old <<
" to " <<
Species[0].get_k0() << std::endl;
2678 }
else if (!strcmp(argv[i],
"-f0")) {
2680 Species[0].set_f0(atof(argv[i+1]));
2681 std::cout <<
" reset f0 from " << old <<
" to " <<
Species[0].get_f0() << std::endl;
2682 }
else if (!strcmp(argv[i],
"-AdhesionForceType")) {
2684 Species[0].set_AdhesionForceType(argv[i+1]);
2685 std::cout <<
" reset AdhesionForceType from " << old <<
" to " <<
Species[0].get_AdhesionForceType() << std::endl;
2686 }
else if (!strcmp(argv[i],
"-append")) {
2689 }
else if (!strcmp(argv[i],
"-fixedParticles")) {
2691 }
else if (!strcmp(argv[i],
"-rho")) {
2693 }
else if (!strcmp(argv[i],
"-dim_particle")) {
2695 }
else if (!strcmp(argv[i],
"-counter")) {
2697 }
else return false;
2713 std::cerr<<
"ERROR :: Periodic Particles Removed not equal to Periodic Particles Created, it created "<<
PeriodicCreated<<
" Particles, but removed "<<R<<std::endl<<std::endl;
2727 for (
int i=0; i<N; i++)
bool find_next_data_file(Mdouble tmin, bool verbose=true)
virtual void cout_time()
std::couts time
void set_save_count_stat(int new_)
Mdouble get_zmin()
Gets zmin.
std::string xballs_additional_arguments
virtual void setup_particles_initial_conditions()
This function allows the initial conditions of the particles to be set, by default locations is rando...
void set_ene_ela(Mdouble new_)
Sets ene_ela.
void set_krolling(Mdouble new_, unsigned int indSpecies=0)
Allows the spring constant to be changed.
virtual void output_ene()
This function outputs statistical data - The default is to compute the rotational kinetic engergy...
void add_Torque(const Vec3D &_new)
void set_zmax(Mdouble new_zmax)
Sets ymax and walls, assuming the standard definition of walls as in the default constructor.
std::stringstream stat_filename
unsigned int options_restart
bool open_fstat_file(std::fstream::openmode mode=std::fstream::out)
void set_counter(int new_counter)
This set the counter, overriding the defaults.
CTangentialSpring * getTangentialSpring(BaseParticle *PI, BaseParticle *PJ, BaseParticle *PJreal)
void readWall(std::istream &is)
Reads BaseWall into the WallHandler from restart data.
virtual void read_v1(std::istream &is)
Reads all MD data.
Mdouble get_disprolling(unsigned int indSpecies=0)
Allows the tangential viscosity to be accessed.
CSpecies * get_MixedSpecies(int i, int j)
Allows the mixed species to be accessed.
void set_restarted(bool new_)
const Vec3D & get_Velocity() const
bool load_par_ini_file(const char *filename)
allows the user to read par.ini files (useful to read MDCLR files)
std::stringstream data_filename
These store the save file names, by default they are derived from problem_name.
Mdouble get_dispt(unsigned int indSpecies=0)
Allows the tangential viscosity to be accessed.
void set_append(bool new_)
Sets restarted.
Mdouble get_InteractionRadius() const
void rotate(const Vec3D &_new)
Mdouble get_ene_ela()
Gets ene_ela.
bool get_append()
Gets restarted.
void compute_particle_mass(std::vector< CSpecies > &Species)
Compute Particle mass function, which required a reference to the Species vector. It copmuters the Pa...
virtual void start_ene()
Functions for ene file.
void add_ene_ela(Mdouble new_)
Sets ene_ela.
int get_IndSpecies() const
Mdouble get_dt()
Allows the time step dt to be accessed.
void getLineFromStringStream(std::istream &in, std::stringstream &out)
void copyAndAddObject(const T &O)
Creates a copy of a Object and adds it to the BaseHandler.
int read_dim_from_data_file()
void reset_TangentialSprings()
sets the history parameter TangentialSprings of all particles to zero
void set_zmin(Mdouble new_zmin)
Sets ymin and walls, assuming the standard definition of walls as in the default constructor.
T * getObject(const unsigned int id) const
Gets a pointer to the Object at the specified index in the BaseHandler.
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this WallHandler.
void setStorageCapacity(const unsigned int N)
Sets the storage capacity of this BaseHandler.
virtual void do_integration_after_force_computation(BaseParticle *pI)
This is were the integration is done.
int save_restart_data_counter
void angularAccelerate(const Vec3D &_new)
void set_options_data(unsigned int new_)
T * getLastObject() const
Gets a pointer to the last Object in this BaseHandler.
void set_dt()
Sets dt to 1/50-th of the smallest possible collision time.
void set_options_restart(unsigned int new_)
void set_savecount(int new_)
Allows the number of time steps between saves to be changed, see also set_number_of_saves.
void set_fstat_filename()
BaseParticle * get_PeriodicFromParticle() const
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
virtual void HGRID_update_move(BaseParticle *, Mdouble)
bool load_from_data_file(const char *filename, unsigned int format=0)
This allows particle data to be reloaded from data files.
unsigned int options_fstat
Indicators if files are created or not 0: file will not be created 1: file will be written in one fil...
Matrix3D Cross(const Vec3D &A, const Matrix3D &B)
virtual void actions_after_solve()
This is actions at the end of the code, but before the files are closed.
int dim
The dimension of the simulation.
virtual void broad_phase(BaseParticle *i)
Broad phase of contact detection goes here. Default check all contacts.
virtual void compute_external_forces(BaseParticle *PI)
This is were the computation of external forces takes place (e.g. gravity)
void set_xmin(Mdouble new_xmin)
Sets xmin and walls, assuming the standard definition of walls as in the default constructor.
virtual void print(std::ostream &os) const
Particle print function, which accepts an os std::stringstream as input.
void set_tmax(Mdouble new_tmax)
Allows the upper time limit to be changed.
unsigned int get_options_fstat(void)
virtual BaseParticle * getLargestParticle()
void readObject(std::istream &is)
Reads BaseParticle into the ParticleHandler from restart data.
void Remove_Duplicate_Periodic_Particles()
Remove periodic duplicate Particles (i.e. removes particles created by Check_and_Duplicate_Periodic_P...
void constructor()
A public constructor, which sets defaults so the problem can be solved off the shelf.
int readArguments(unsigned int argc, char *argv[])
Can interpret main function input arguments that are passed by the driver codes.
std::vector< CSpecies > Species
These are the particle parameters like dissipation etc.
Mdouble get_krolling(int indSpecies=0)
Allows the spring constant to be accessed.
bool get_save_data_stat()
Mdouble get_InvInertia() const
CDeltaMaxs & get_DeltaMaxs()
virtual void write(std::ostream &os)
Writes all MD data.
AdhesionForceTypes AdhesionForceType
void solve()
The work horse of the code.
virtual void HGRID_RemoveParticleFromHgrid(BaseParticle *obj UNUSED)
Mdouble * select_particle(int P, Mdouble time_, Mdouble dt)
Function selects the tangential spring vector for particle-particle interations (also removed not use...
Mdouble get_murolling(unsigned int indSpecies=0)
Allows the Coulomb friction coefficient to be accessed.
CTangentialSprings & get_TangentialSprings()
const Vec3D & get_Force() const
void set_murolling(Mdouble new_, unsigned int indSpecies=0)
Allows the Coulomb friction coefficient to be changed.
void removeLastObject()
Removes the last Object from the BaseHandler.
void set_t(Mdouble new_t)
Access function for the time.
bool get_save_data_fstat()
void randomise()
sets the random variables such that they differ for each run
Mdouble get_ymax()
Gets ymax.
Mdouble computeShortRangeForceWithParticle(BaseParticle *PI, BaseParticle *PJ, BaseParticle *PJreal, CSpecies *pSpecies, Mdouble dist)
std::stringstream problem_name
Stores the problem_name.
friend Mdouble GetLength2(const Vec3D &A)
virtual void save_restart_data()
Stores all MD data.
Vec3D delta
stores the spring
bool isFixed()
Is fixed Particle function. It returns wether a Particle is fixed or not, by cheking its inverse Mass...
Defines a pair of periodic walls. The particles are in {x: position_left<=normal*x
Mdouble get_Radius() const
void clear()
Empties the whole ParticleHandler by removing all BaseParticle.
virtual void gather_statistics_collision(int index1 UNUSED, int index2 UNUSED, Vec3D Contact UNUSED, Mdouble delta UNUSED, Mdouble ctheta UNUSED, Mdouble fdotn UNUSED, Mdouble fdott UNUSED, Vec3D P1_P2_normal_ UNUSED, Vec3D P1_P2_tangential UNUSED)
virtual bool continue_solve()
CTangentialSpring * select_wall_spring(int W, Mdouble time_, Mdouble dt)
Function selects the tangential spring vector for particle-particle interations (also removed not use...
void set_options_fstat(unsigned int new_)
set and get for file options
void readObject(std::istream &is)
Reads BaseBoundary into the BoundaryHandler from restart data.
std::fstream data_file
Stream used for data files.
void compute_particle_masses()
Computes the mass of each particle.
virtual void set_initial_pressures_for_pressure_controlled_walls()
void set_save_count_fstat(int new_)
void set_kt(Mdouble new_, unsigned int indSpecies=0)
Allows the spring constant to be changed.
Mdouble get_InvMass() const
ParticleHandler particleHandler
BoundaryHandler boundaryHandler
Mdouble dt
These are numerical constants like the time step size.
virtual void output_xballs_data_particle(int i)
This function outputs the location and velocity of the particle in a format the xballs progream can r...
const std::vector< BaseWall * >::const_iterator begin() const
Gets the begin of the const_iterator over all BaseWall in this WallHandler.
virtual void process_statistics(bool usethese UNUSED)
virtual void actions_after_time_step()
This is action after the time step is finished.
virtual void do_integration_before_force_computation(BaseParticle *pI)
This is were the integration is done.
Mdouble get_t()
Access function for the time.
Mdouble get_ymin()
Gets ymin.
const std::vector< BaseWall * >::const_iterator end() const
Gets the end of the const_iterator over all BaseWall in this WallHandler.
virtual void actions_before_time_loop()
This is actions before the start of the main time loop.
void statistics_from_restart_data(const char *name)
Loads all MD data and plots statistics for all timesteps in the .data file.
Mdouble distance(BaseParticle &P)
Returns the distance of the wall to the particle, and sets left_wall = true, if the left wall is the ...
unsigned int get_options_data(void)
virtual void fstat_header()
virtual void finish_statistics()
Mdouble t
This stores the current time.
Mdouble get_xmin()
Get xmin.
void copyAndAddWall(const BaseWall &B)
Creates a copy of a BaseWall and adds it to the WallHandler.
Mdouble computeShortRangeForceWithWall(BaseParticle *pI, int wall, CSpecies *pSpecies, Mdouble dist)
void set_save_count_data(int new_)
virtual int readNextArgument(unsigned int &i, unsigned int argc, char *argv[])
bool increase_counter_fstat(std::fstream::openmode mode)
void setSpecies(std::vector< CSpecies > *)
void set_do_stat_always(bool new_)
Sets how often the data is saved using the number of saves wanted, tmax, and dt. See also set_savecou...
void set_dim_particle(int new_, unsigned int indSpecies=0)
Allows the dimension of the particle (f.e. for mass) to be changed.
virtual bool get_HGRID_UpdateEachTimeStep()
unsigned int getNumberOfWalls() const
Gets the number of BaseWalls in this WallHandler.
virtual void HGRID_actions_after_integration()
Mdouble get_k(int indSpecies=0)
Allows the spring constant to be accessed.
CTangentialSpring * getTangentialSpringWall(BaseParticle *pI, int w)
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
void set_save_count_all(int new_)
virtual void actions_before_time_step()
This is action before the time step is started.
Stores the tangential spring needed to compute a tangential elastic force between particles PI...
void add_Force(const Vec3D &_new)
virtual void initialize_statistics()
Functions for statistics.
Mdouble get_kt(int indSpecies=0)
Allows the spring constant to be accessed.
void set_FixedParticles(unsigned int n)
virtual void compute_all_forces()
This does the force computation.
CTangentialSpring * create_new(int P, Mdouble time_, Mdouble dt)
virtual void HGRID_UpdateParticleInHgrid(BaseParticle *obj UNUSED)
void set_ymax(Mdouble new_ymax)
Sets ymax and walls, assuming the standard definition of walls as in the default constructor.
Mdouble get_tmax()
Allows the upper time limit to be accessed.
const Vec3D & get_Displacement() const
void move(const Vec3D &_new)
virtual void output_statistics()
void shift_position(BaseParticle *F0)
shifts the particle (after distance set the left_wall value)
virtual void write_v1(std::ostream &os)
Writes all MD data.
bool open_data_file(std::fstream::openmode mode=std::fstream::out)
virtual void print(std::ostream &os UNUSED) const =0
outputs boundary
unsigned int get_options_ene(void)
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
const Vec3D & get_Position() const
void set_mu(Mdouble new_, unsigned int indSpecies=0)
Allows the Coulomb friction coefficient to be changed.
void set(Vec3D normal_, Mdouble position_)
Defines a standard wall, given an outward normal vector s. t. normal*x=position.
virtual bool get_distance_and_normal(BaseParticle &P UNUSED, Mdouble &distance UNUSED, Vec3D &normal_return UNUSED)=0
virtual int createPeriodicParticles(BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
Mdouble get_disp(unsigned int indSpecies=0)
Allows the normal dissipation to be accessed.
unsigned int get_options_stat(void)
unsigned int get_options_restart(void)
CTangentialSpring * select_particle_spring(int P, Mdouble time_, Mdouble dt)
Function selects the tangential spring vector for particle-particle interations (also removed not use...
void set_rho(Mdouble new_, unsigned int indSpecies=0)
Allows the density to be changed.
virtual void read(std::istream &is)
Reads all MD data.
void add_Force(Vec3D _new)
virtual void print(std::ostream &os UNUSED) const =0
virtual Vec3D get_Velocity() const =0
void set_Velocity(const Vec3D &_new)
CTangentialSpring * create_new_wall(int W, Mdouble time_, Mdouble dt)
int get_counter()
This returns the current value of the counter.
virtual void HGRID_actions_before_integration()
const Vec3D & get_Torque() const
virtual void output_xballs_data()
Output xball data for Particle i.
Mdouble get_mu(unsigned int indSpecies=0)
Allows the Coulomb friction coefficient to be accessed.
void set_name(const char *name)
Sets the name of the problem, used for the same data files.
Vec3D SlidingForce
Stores the force (for some non-linear, hysteretic spring models)
virtual void read_v2(std::istream &is)
void set_file_counter(int new_)
virtual void removeParticle(int iP)
int load_restart_data()
Loads all MD data.
std::string get_data_filename()
void set_Displacement(const Vec3D &_new)
virtual void HGRID_actions_before_time_loop()
This is actions before the start of the main time loop.
Vec3D gravity
Gravitational acceleration.
This is a class defining walls.
Mdouble ene_ela
used in force calculations
void set_number_of_saves_all(Mdouble N)
void set_Torque(const Vec3D &_new)
Mdouble GetLength() const
ParticleHandler & getParticleHandler()
void compute_plastic_internal_forces(BaseParticle *P1, BaseParticle *P2)
Computes plastic forces between particles.
bool increase_counter_ene(std::fstream::openmode mode)
void set_dim(int new_dim)
Allows the dimension of the simulation to be changed.
virtual void HGRID_actions_before_time_step()
This is action before the time step is started.
void set(Vec3D normal_, Mdouble position_left_, Mdouble position_right_)
Defines a periodic wall, given a normal vector s.t.
ForceTypes get_ForceType() const
bool increase_counter_data(std::fstream::openmode mode)
Mdouble get_xmax()
Get xmax.
unsigned int getStorageCapacity() const
Gets the storage capacity of this BaseHandler.
std::string get_name()
Allows the problem_name to be accessed.
Mdouble xmin
These store the size of the domain, assume walls at the ends.
Mdouble get_k2max(unsigned int indSpecies=0)
virtual BaseParticle * getSmallestParticle()
void set_gravity(Vec3D new_gravity)
Allows the gravitational acceleration to be changed.
BaseWall * getWall(const unsigned int id) const
Gets a pointer to the BaseWall at the specified index in the WallHandler.
Implementation of a 3D vector (by Vitaliy).
virtual void checkInteractionWithBoundaries()
void set_disprolling(Mdouble new_, unsigned int indSpecies=0)
Allows the tangential viscosity to be changed.
unsigned int options_data
bool read_next_from_data_file(unsigned int format=0)
by default format do not pass an argument; only specify format if you have to read a special format (...
Vec3D get_gravity()
Allows the gravitational acceleration to be accessed.
void set_ymin(Mdouble new_ymin)
void set_options_stat(unsigned int new_)
bool increase_counter_stat(std::fstream::openmode mode)
Stores properties of the particles and the contact models such as the elastic modulus.
void set_Position(const Vec3D &_new)
void accelerate(const Vec3D &_new)
virtual void compute_walls(BaseParticle *PI)
This is were the walls are.
bool open_ene_file(std::fstream::openmode mode=std::fstream::out)
void set_dispt(Mdouble new_, unsigned int indSpecies=0)
Allows the tangential viscosity to be changed.
int save_count_data
These are informations for saving.
void update_disp(Mdouble mass1, Mdouble mass2)
Mdouble get_zmax()
Gets zmax.
void clear()
Empties the whole WallHandler by removing all BaseWall.
void set_k(Mdouble new_, unsigned int indSpecies=0)
Allows the spring constant to be changed.
int Check_and_Duplicate_Periodic_Particles()
Calls Check_and_Duplicate_Periodic_Particle for all Particles curently in Particles[] and returns the...
void add_Torque(Vec3D _new)
virtual void compute_internal_forces(BaseParticle *i)
Computes the forces between particles (internal in the sence that the sum over all these forces is ze...
void clear()
Empties the whole BaseHandler by removing all Object.
void set_save_count_ene(int new_)
virtual void print(std::ostream &os, bool print_all=false)
Outputs MD.
void set_RandomSeed(Mdouble new_seed)
This is the seed for the random number generator.
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...
bool get_do_stat_always()
void set_disp(Mdouble new_, unsigned int indSpecies=0)
Allows the normal dissipation to be changed.
const Vec3D & get_AngularVelocity() const
void set_options_ene(unsigned int new_)
void set_xmax(Mdouble new_xmax)
Sets xmax and walls, assuming the standard definition of walls as in the default constructor.
virtual void create_xballs_script()
This creates a scipt which can be used to load the xballs problem to display the data just generated...