obsolete_codes/GlasPeriodic.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, 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 "scr/Chute.h"
27 //~ #include "scr/Time.h"
28 using namespace std;
29 
30 class SilbertPeriodic : public Chute
31 {
32 public:
33 
35  // Problem parameters
36  setName("silbert");
37 
38  //time stepping
39  setTimeStep(1e-4);
40  setTimeMax(2000);
41 
42  //output parameters
43  setSaveCount(50e4);
44 
45  //particle radii
46  setInflowParticleRadius(.5);
47  setFixedParticleRadius(.5);//getInflowParticleRadius());
48  setRoughBottomType(MULTILAYER);
49 
50  //particle properties
51  setDensity(6/pi);
52  //~ setStiffnessAndRestitutionCoefficient(2e5,0.97,1);
53  double tc=5e-3, r=0.97, beta=0.44, mu=0.092, mur=0.042;
54  setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(tc,r,beta,1.0,1.0);
55  setSlidingFrictionCoefficient(mu);
56  setSlidingFrictionCoefficientr();
57 
58  //chute properties
59  setChuteAngle(24.0, 1.0);
60  setChuteLength(20);
61  setChuteWidth(10);
62  set_H(20);
63 
64  }
65 
66  void fix_hgrid() {
67  //assume 1-2 levels are optimal (which is the case for mono and bidispersed) and set the cell size to min and max
68  // !this is not optimal for polydispersed
69  double minCell = 2.*min(getFixedParticleRadius(),getMinInflowParticleRadius());
70  double maxCell = 2.*max(getFixedParticleRadius(),getMaxInflowParticleRadius());
71  if ((minCell==maxCell)|(minCell==0.)) set_HGRID_max_levels(1);
72  else set_HGRID_max_levels(2);
73  set_HGRID_cell_to_cell_ratio (1.0000001*maxCell/minCell);
74  }
75 
77  if (speciesHandler.getNumberOfObjects()>1) return speciesHandler.getMixedObject(1,0)->getSlidingFrictionCoefficient();
78  else return getSlidingFrictionCoefficient();
79  }
80 
82  createBaseSpecies();
83  speciesHandler.getMixedObject(1, 0)->setSlidingFrictionCoefficient(new_);
84  }
85 
87  //only create once
88  static bool created=false;
89  if (!created) {
90  speciesHandler.copyAndAddObject(speciesHandler.getObject(0));
91  created = true;
92  for (int i=0; i<get_N(); i++) {
93  if (Particles[i].is_fixed()) Particles[i].indSpecies=1;
94  }
95  }
96  }
97 
98  void set_study() {
99  stringstream name;
100  name << "H" << getInflowHeight()
101  << "A" << getChuteAngleDegrees()
102  << "L" << round(100.*getFixedParticleRadius()*2.)/100.
103  << "M" << getSlidingFrictionCoefficient()
104  << "B" << getSlidingFrictionCoefficientBottom();
105  setName(name.str().c_str());
106  set_data_filename();
107  }
108 
109  void set_study(int study_num) {
110  //S=0-5: lambda = 0, 3./6., 4./6., 5./6., 1, 2
111  //S=6-8: mu = 0, 1, inf
112  //S=9-13: mub = 0,1,inf,1/4,1/8
113  //S=14-15: mu = 1/4, 1/8
114  //S=16-19: lambda = 1./6., 2./6., 1.5, 4
115  //S=21-25: mub=1/16,1/32,1/64,1/128,1/1024
116  //S=26-28: lambda=1/2, mub=1/16,1/128,1/1024
117  //S=29-32: lambda=0, mub=1/16,1/128,1/1024,0
118 
119  if (study_num < 6) {
120  // set mu_all = 0.5, vary lambda
121  double Lambdas[] = {0, 3./6., 4./6., 5./6., 1, 2};
122  setFixedParticleRadius(Lambdas[study_num]/2.);
123  } else {
124  //If study_num is complete quit
125  cout << "Study is complete " << endl;
126  exit(0);
127  }
128  //Note make sure h and a is defined
129  set_study();
130  }
131 
132  void set_study(vector<int> study_num) {
133  double Heights[] = {10, 20, 30, 40};
134  double Angles[] = {20, 22, 24, 26, 28, 30, 40, 50, 60};
135  setInflowHeight(Heights[study_num[1]-1]);
136  setChuteAngle(Angles[study_num[2]-1]);
137  set_study(study_num[0]);
138  }
139 
140  //Do not add or remove particles
141  void actionsBeforeTimeStep() override { };
142 
143  //Set up periodic walls, rough bottom, add flow particles
144  void setupInitialConditions() override
145  {
146  fix_hgrid();
147  set_Nmax(get_N()+getChuteLength()*getChuteWidth()*getZMax());//why is this line needed?
148 
149  createBottom();
150  //~ write(std::cout,false);
151  //cout << "correct fixed" << endl;
152  if (Species.size()>1) {
153  for (int i=0; i<get_N(); i++)
154  if (Particles[i].is_fixed())
155  Particles[i].indSpecies=1;
156  }
157 
158  set_NWall(1);
159  if (getFixedParticleRadius()) {
160  wallHandler.getObject(0)->set(Vec3D(0,0,-1), 3.4*MaxInflowParticleRadius);
161  } else {
162  wallHandler.getObject(0)->set(Vec3D(0,0,-1), 0.);
163  }
164 
165  set_NWallPeriodic(2);
166  WallsPeriodic[0].set(Vec3D( 1.0, 0.0, 0.0), getXMin(), getXMax());
167  WallsPeriodic[1].set(Vec3D( 0.0, 1.0, 0.0), getYMin(), getYMax());
168 
169  add_flow_particles();
170 
171  cout << endl << "Status before solve:" << endl;
172  cout
173  << "tc=" << getCollisionTime()
174  << ", eps=" << getRestitutionCoefficient()
175  << ", vmax=" << getMaximumVelocity()
176  << ", InflowHeight/zmax=" << getInflowHeight()/getZMax()
177  << endl << endl;
178  //~ timer.set(t,tmax);
179 
180  //optimize number of buckets
181  cout << "Nmax" << get_Nmax() << endl;
182  set_HGRID_num_buckets_to_power(get_N()*1.5);
183  }
184 
185  //add flow particles
187  {
188  set_HGRID_num_buckets_to_power(get_Nmax());
189  hGridActionsBeforeTimeLoop();
190  hGridActionsBeforeTimeStep();
191  unsigned int N=get_N()+getChuteLength()*getChuteWidth()*InflowHeight;
192  set_Nmax(N);
193  double H = InflowHeight;
194  setZMax(1.2*InflowHeight);
195 
196  writeRestartFile();
197  //try to find new insertable particles
198  while (Particles.size()<N){
199  create_inflow_particle();
200  if (IsInsertable(P0)) {
201  num_created++;
202  } else InflowHeight += .0001* MaxInflowParticleRadius;
203  }
204  InflowHeight = H;
205  set_HGRID_num_buckets_to_power();
206  write(std::cout,false);
207  }
208 
209  //defines type of flow particles
211  {
212  P0.Radius = MaxInflowParticleRadius;
213  P0.computeMass(Species);
214 
215  P0.Position.X = random(getXMin()+2.0*P0.Radius,getXMax());
216  P0.Position.Y = random(getYMin()+2.0*P0.Radius,getYMax());
217  P0.Position.Z = random(getZMin()+2.0*P0.Radius,getInflowHeight());
218  P0.Velocity = Vec3D(0.0,0.0,0.0);
219  }
220 
221  //set approximate height of flow
222  void set_H(double new_) {InflowHeight=new_; setZMax(InflowHeight);}
223  double get_H() {return InflowHeight;}
224 
225  void printTime() {
226  cout << "t=" << setprecision(3) << left << setw(6) << getTime()
227  << ", tmax=" << setprecision(3) << left << setw(6) << getTimeMax()
228  << ", N=" << setprecision(3) << left << setw(6) << Particles.size()
229  //<< ", time left=" << setprecision(3) << left << setw(6) << timer.getTime2Finish(t)
230  //~ << ", finish by " << setprecision(3) << left << setw(6) << timer.getFinishTime(t)
231  << ". " << endl;
232  }
233 
234  int readNextArgument(unsigned int& i, unsigned int& argc, char *argv[]) {
235  if (!strcmp(argv[i],"-muBottom")) {
236  setSlidingFrictionCoefficientBottom(atof(argv[i+1]));
237  cout << "muB=" << getSlidingFrictionCoefficientBottom() << endl;
238  } else return Chute::readNextArgument(i, argc, argv); //if argv[i] is not found, check the commands in Chute
239  return true; //returns true if argv[i] is found
240  }
241 };
@ MULTILAYER
Definition: Chute.h:53
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase).
Definition: Chute.h:65
bool readNextArgument(int &i, int argc, char *argv[]) override
This method can be used for reading object properties from a string.
Definition: Chute.cc:555
Definition: flowRuleDiego_HeightAngle.cpp:35
void createBaseSpecies()
Definition: obsolete_codes/GlasPeriodic.h:86
void set_study(vector< int > study_num)
Definition: obsolete_codes/GlasPeriodic.h:132
int readNextArgument(unsigned int &i, unsigned int &argc, char *argv[])
Definition: obsolete_codes/GlasPeriodic.h:234
void setSlidingFrictionCoefficientBottom(double new_)
Definition: obsolete_codes/GlasPeriodic.h:81
void add_flow_particles()
Definition: obsolete_codes/GlasPeriodic.h:186
void create_inflow_particle()
Definition: obsolete_codes/GlasPeriodic.h:210
void set_study()
Definition: obsolete_codes/GlasPeriodic.h:98
SilbertPeriodic()
Definition: obsolete_codes/GlasPeriodic.h:34
void printTime()
Definition: obsolete_codes/GlasPeriodic.h:225
void actionsBeforeTimeStep() override
A virtual function which allows to define operations to be executed before the new time step.
Definition: obsolete_codes/GlasPeriodic.h:141
double get_H()
Definition: obsolete_codes/GlasPeriodic.h:223
void fix_hgrid()
Definition: obsolete_codes/GlasPeriodic.h:66
void set_H(double new_)
Definition: obsolete_codes/GlasPeriodic.h:222
void set_study(int study_num)
Definition: obsolete_codes/GlasPeriodic.h:109
double getSlidingFrictionCoefficientBottom()
Definition: obsolete_codes/GlasPeriodic.h:76
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: obsolete_codes/GlasPeriodic.h:144
Contains material and contact force properties.
Definition: Species.h:35
Definition: Vector.h:51
const Mdouble pi
Definition: ExtendedMath.h:45
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble round(Mdouble value, unsigned int precision)
rounds a floating point number with a given precision
Definition: MathHelpers.cc:28
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:68
Mdouble beta(Mdouble z, Mdouble w)
This is the beta function, returns the approximation based on cmath's implementation of ln(gamma)
Definition: ExtendedMath.cc:164
std::string name
Definition: MercuryProb.h:48