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