obsolete_codes/SilbertPeriodic.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #include "scr/Chute.h"
6 //~ #include "scr/Time.h"
7 using namespace std;
8 
9 class SilbertPeriodic : public Chute
10 {
11 public:
12 
14  // Problem parameters
15  setName("silbert");
16 
17  //time stepping
18  setTimeStep(1e-4);
19  setTimeMax(2000);
20 
21  //output parameters
22  setSaveCount(50e4);
23 
24  //particle radii
25  setInflowParticleRadius(.5);
26  setFixedParticleRadius(.5);//getInflowParticleRadius());
27  setRoughBottomType(MULTILAYER);
28 
29  //particle properties
30  setDensity(6/constants::pi);
31  setStiffness(2e5);
32  setSlidingStiffness(2.0/7.0*getStiffness());
33  setDissipation(25.0);
34  //setSlidingDissipation(2.0/7.0*getDissipation());
35  setSlidingDissipation(getDissipation());
36  setSlidingFrictionCoefficient(0.5);
37 
38  //chute properties
39  setChuteAngle(24.0, 1.0);
40  setChuteLength(20);
41  setChuteWidth(10);
42  set_H(20);
43 
44  }
45 
46  void fix_hgrid() {
47  //assume 1-2 levels are optimal (which is the case for mono and bidispersed) and set the cell size to min and max
48  // !this is not optimal for polydispersed
49  Mdouble minCell = 2.*min(getFixedParticleRadius(),getMinInflowParticleRadius());
50  Mdouble maxCell = 2.*max(getFixedParticleRadius(),getMaxInflowParticleRadius());
51  if ((minCell==maxCell)|(minCell==0.)) set_HGRID_max_levels(1);
52  else set_HGRID_max_levels(2);
53  set_HGRID_cell_to_cell_ratio (1.0000001*maxCell/minCell);
54  }
55 
57  if (speciesHandler.getNumberOfObjects()>1) return speciesHandler.getMixedObject(1,0)->getSlidingFrictionCoefficient();
58  else return getSlidingFrictionCoefficient();
59  }
60 
62  createBaseSpecies();
63  speciesHandler.getMixedObject(1, 0)->setSlidingFrictionCoefficient(new_);
64  }
65 
66  virtual void createBaseSpecies() {
67  //only create once
68  static bool created=false;
69  if (!created) {
70  speciesHandler.copyAndAddObject(speciesHandler.getObject(0));
71  created = true;
72  for (unsigned int i=0; i<particleHandler.getNumberOfObjects(); i++) {
73  if (particleHandler.getObject(i)->isFixed()) particleHandler.getObject(i)->setSpecies(speciesHandler.getObject(1));
74  }
75  }
76  }
77 
78  void set_study() {
79  stringstream name;
80  name << "H" << getInflowHeight()
81  << "A" << getChuteAngleDegrees()
82  << "L" << round(100.*getFixedParticleRadius()*2.)/100.
83  << "M" << getSlidingFrictionCoefficient()
84  << "B" << getSlidingFrictionCoefficientBottom();
85  setName(name.str().c_str());
86  set_data_filename();
87  }
88 
89  void set_study(int study_num) {
90  //S=0-5: lambda = 0, 3./6., 4./6., 5./6., 1, 2
91  //S=6-8: mu = 0, 1, inf
92  //S=9-13: mub = 0,1,inf,1/4,1/8
93  //S=14-15: mu = 1/4, 1/8
94  //S=16-19: lambda = 1./6., 2./6., 1.5, 4
95  //S=21-25: mub=1/16,1/32,1/64,1/128,1/1024
96  //S=26-28: lambda=1/2, mub=1/16,1/128,1/1024
97  //S=29-32: lambda=0, mub=1/16,1/128,1/1024,0
98 
99  if (study_num < 6) {
100  // set mu_all = 0.5, vary lambda
101  Mdouble Lambdas[] = {0, 3./6., 4./6., 5./6., 1, 2};
102  setFixedParticleRadius(Lambdas[study_num]/2.);
103  setSlidingFrictionCoefficient(0.5);
104  } else if (study_num < 9) { //Case 6,7,8
105  // set lambda = 1, vary mu_all
106  Mdouble MuAll[] = {0, 1., 1e20};
107  setSlidingFrictionCoefficient(MuAll[study_num-6]);
108  setFixedParticleRadius(0.5);
109  } else if (study_num < 12) { //Case 9,10,11
110  // set lambda = 1, mu_all = 0.5, vary mu_bottom
111  Mdouble MuBottom[] = {0, 1., 1e20};
112  setSlidingFrictionCoefficient(0.5);
113  setSlidingFrictionCoefficientBottom(MuBottom[study_num-9]);
114  setFixedParticleRadius(0.5);
115  } else if (study_num < 14) { //Case 12,13
116  // set lambda = 1, mu_all = 0.5, vary mu_bottom
117  Mdouble MuBottom[] = {0.25, 0.125};
118  setSlidingFrictionCoefficient(0.5);
119  setSlidingFrictionCoefficientBottom(MuBottom[study_num-12]);
120  setFixedParticleRadius(0.5);
121  } else if (study_num < 16) { //Case 14,15
122  // set lambda = 1, vary mu_all
123  Mdouble MuAll[] = {0.25, 0.125};
124  setSlidingFrictionCoefficient(MuAll[study_num-14]);
125  setFixedParticleRadius(0.5);
126  } else if (study_num < 21) { //Case 16,17,18,19,20
127  // set mu_all = 0.5, vary lambda
128  Mdouble Lambdas[] = {1./6., 2./6., 1.5, 4, 1./12};
129  setFixedParticleRadius(Lambdas[study_num-16]/2.);
130  setSlidingFrictionCoefficient(0.5);
131  } else if (study_num < 26) { //Case 21 22 23 24 25
132  // set lambda = 1, mu_all = 0.5, vary mu_bottom
133  Mdouble MuBottom[] = {1./16.,1./32.,1./64.,1./128.,1./1024.};
134  setSlidingFrictionCoefficient(0.5);
135  setSlidingFrictionCoefficientBottom(MuBottom[study_num-21]);
136  setFixedParticleRadius(0.5);
137  } else if (study_num < 29) { //Case 26 27 28
138  // set lambda = 1/2, mu_all = 0.5, vary mu_bottom
139  Mdouble MuBottom[] = {1./16.,1./128.,1./1024.};
140  setSlidingFrictionCoefficient(0.5);
141  setSlidingFrictionCoefficientBottom(MuBottom[study_num-26]);
142  setFixedParticleRadius(0.25);
143  } else if (study_num < 33) { //Case 29 30 31 32
144  // set lambda = 0, mu_all = 0.5, vary mu_bottom
145  Mdouble MuBottom[] = {1./16.,1./128.,1./1024.,0};
146  setSlidingFrictionCoefficient(0.5);
147  setSlidingFrictionCoefficientBottom(MuBottom[study_num-29]);
148  setFixedParticleRadius(0);
149  } else if (study_num < 37) { //Case 33-36
150  cout << "S" << study_num << endl;
151  // set lambda = 1, mu_b = 0.5, vary mu
152  Mdouble Mu[] = {1e20,1,1./64,0};
153  setSlidingFrictionCoefficient(Mu[study_num-33]);
154  setSlidingFrictionCoefficientBottom(0.5);
155  setFixedParticleRadius(1);
156  } else {
157  //If study_num is complete quit
158  cout << "Study is complete " << endl;
159  exit(0);
160  }
161  //Note make sure h and a is defined
162  set_study();
163  }
164 
165  void set_study(vector<int> study_num) {
166  Mdouble Heights[] = {10, 20, 30, 40};
167  Mdouble Angles[] = {20, 22, 24, 26, 28, 30, 40, 50, 60};
168  setInflowHeight(Heights[study_num[1]-1]);
169  setChuteAngle(Angles[study_num[2]-1]);
170  set_study(study_num[0]);
171  }
172 
173  //Do not add or remove particles
174  void actionsBeforeTimeStep() override { };
175 
176  //Set up periodic walls, rough bottom, add flow particles
177  void setupInitialConditions() override
178  {
179  fix_hgrid();
180  particleHandler.set_StorageCapacity(particleHandler.getNumberOfObjects()+getChuteLength()*getChuteWidth()*getZMax());//why is this line needed?
181 
182  createBottom();
183  //~ write(std::cout,false);
184  //cout << "correct fixed" << endl;
185  if (Species.size()>1) {
186  for (unsigned int i=0; i<particleHandler.getNumberOfObjects(); i++)
187  if (particleHandler.getObject(i)->isFixed())
188  particleHandler.getObject(i)->setSpecies(speciesHandler.getObject(1));
189  }
190 
191  set_NWall(1);
192  if (getFixedParticleRadius()) {
193  wallHandler.getObject(0)->set(Vec3D(0,0,-1), 3.4*MaxInflowParticleRadius);
194  } else {
195  wallHandler.getObject(0)->set(Vec3D(0,0,-1), 0.);
196  }
197 
198  set_NWallPeriodic(2);
199  WallsPeriodic[0].set(Vec3D( 1.0, 0.0, 0.0), getXMin(), getXMax());
200  WallsPeriodic[1].set(Vec3D( 0.0, 1.0, 0.0), getYMin(), getYMax());
201 
202  add_flow_particles();
203 
204  cout << endl << "Status before solve:" << endl;
205  cout
206  << "tc=" << getCollisionTime()
207  << ", eps=" << getRestitutionCoefficient()
208  << ", vmax=" << getMaximumVelocity()
209  << ", InflowHeight/zmax=" << getInflowHeight()/getZMax()
210  << endl << endl;
211  //~ timer.set(t,tmax);
212 
213  //optimize number of buckets
214  cout << "Nmax" << particleHandler.getStorageCapacity() << endl;
215  set_HGRID_num_buckets_to_power(particleHandler.getNumberOfObjects()*1.5);
216  }
217 
218  //add flow particles
220  {
221  set_HGRID_num_buckets_to_power(particleHandler.getStorageCapacity());
222  hGridActionsBeforeTimeLoop();
223  hGridActionsBeforeTimeStep();
224  unsigned int N=particleHandler.getNumberOfObjects()+getChuteLength()*getChuteWidth()*InflowHeight;
225  particleHandler.set_StorageCapacity(N);
226  Mdouble H = InflowHeight;
227  setZMax(1.2*InflowHeight);
228 
229  writeRestartFile();
230  //try to find new insertable particles
231  while (particleHandler.getNumberOfObjects()<N){
232  create_inflow_particle();
233  if (IsInsertable(P0)) {
234  num_created++;
235  } else InflowHeight += .0001* MaxInflowParticleRadius;
236  }
237  InflowHeight = H;
238  set_HGRID_num_buckets_to_power();
239  write(std::cout,false);
240  }
241 
242  //defines type of flow particles
244  {
245  P0.setRadius(random.get_RN(MinInflowParticleRadius,MaxInflowParticleRadius));
246  P0.computeMass(Species);
247 
248  P0.getPosition().X = random.get_RN(getXMin()+2.0*P0.getRadius(),getXMax());
249  P0.getPosition().Y = random.get_RN(getYMin()+2.0*P0.getRadius(),getYMax());
250  P0.getPosition().Z = random.get_RN(getZMin()+2.0*P0.getRadius(),getInflowHeight());
251  P0.setVelocity(Vec3D(0.0,0.0,0.0));
252  }
253 
254  //set approximate height of flow
255  void set_H(Mdouble new_) {InflowHeight=new_; setZMax(InflowHeight);}
256  Mdouble get_H() {return InflowHeight;}
257 
258  void printTime() {
259  cout << "t=" << setprecision(3) << left << setw(6) << getTime()
260  << ", tmax=" << setprecision(3) << left << setw(6) << getTimeMax()
261  << ", N=" << setprecision(3) << left << setw(6) << particleHandler.getNumberOfObjects()
262  //<< ", time left=" << setprecision(3) << left << setw(6) << timer.getTime2Finish(t)
263  //~ << ", finish by " << setprecision(3) << left << setw(6) << timer.getFinishTime(t)
264  << ". " << endl;
265  }
266 
267  int readNextArgument(unsigned int& i, unsigned int argc, char *argv[]) {
268  if (!strcmp(argv[i],"-muBottom")) {
269  setSlidingFrictionCoefficientBottom(atof(argv[i+1]));
270  cout << "muB=" << getSlidingFrictionCoefficientBottom() << endl;
271  } else return Chute::readNextArgument(i, argc, argv); //if argv[i] is not found, check the commands in Chute
272  return true; //returns true if argv[i] is found
273  }
274 };
int i
Definition: BiCGSTAB_step_by_step.cpp:9
@ MULTILAYER
Definition: Chute.h:32
Array< double, 1, 3 > e(1./3., 0.5, 2.)
MatrixXf H
Definition: HessenbergDecomposition_matrixH.cpp:4
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase).
Definition: Chute.h:44
bool readNextArgument(int &i, int argc, char *argv[]) override
This method can be used for reading object properties from a string.
Definition: Chute.cc:534
Definition: flowRuleDiego_HeightAngle.cpp:14
virtual void createBaseSpecies()
Definition: obsolete_codes/SilbertPeriodic.h:66
void set_study(vector< int > study_num)
Definition: obsolete_codes/SilbertPeriodic.h:165
void setSlidingFrictionCoefficientBottom(Mdouble new_)
Definition: obsolete_codes/SilbertPeriodic.h:61
void add_flow_particles()
Definition: obsolete_codes/SilbertPeriodic.h:219
void create_inflow_particle()
Definition: obsolete_codes/SilbertPeriodic.h:243
void set_study()
Definition: obsolete_codes/SilbertPeriodic.h:78
void set_H(Mdouble new_)
Definition: obsolete_codes/SilbertPeriodic.h:255
SilbertPeriodic()
Definition: obsolete_codes/SilbertPeriodic.h:13
void printTime()
Definition: obsolete_codes/SilbertPeriodic.h:258
void actionsBeforeTimeStep() override
A virtual function which allows to define operations to be executed before the new time step.
Definition: obsolete_codes/SilbertPeriodic.h:174
Mdouble get_H()
Definition: obsolete_codes/SilbertPeriodic.h:256
void fix_hgrid()
Definition: obsolete_codes/SilbertPeriodic.h:46
Mdouble getSlidingFrictionCoefficientBottom()
Definition: obsolete_codes/SilbertPeriodic.h:56
void set_study(int study_num)
Definition: obsolete_codes/SilbertPeriodic.h:89
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: obsolete_codes/SilbertPeriodic.h:177
int readNextArgument(unsigned int &i, unsigned int argc, char *argv[])
Definition: obsolete_codes/SilbertPeriodic.h:267
Contains material and contact force properties.
Definition: Species.h:14
Definition: Kernel/Math/Vector.h:30
@ N
Definition: constructor.cpp:22
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::enable_if_t< dt !=data_source::global_mem, void > write(PacketType &packet_data, DataScalar ptr)
write, a template function used for storing the data to local memory. This function is used to guaran...
Definition: TensorContractionSycl.h:221
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 round(const bfloat16 &a)
Definition: BFloat16.h:646
double Mu
Definition: axisym_linear_elasticity/cylinder/cylinder.cc:53
double P0
Definition: two_dim.cc:101
const Mdouble pi
Definition: ExtendedMath.h:23
MERCURYDPM_DEPRECATED Mdouble getMaximumVelocity(Mdouble k, Mdouble disp, Mdouble radius, Mdouble mass)
Calculates the maximum relative velocity allowed for a normal collision of two particles of radius r ...
Definition: FormulaHelpers.cc:47
string name
Definition: plotDoE.py:33