Ejemplo n.º 1
0
void Crun::init_evolve(void)
{
	//set where to read the initial configuration
	cout<<"Enter the path where the initial configuration files are (without final /) and the number of the file to be read"<<endl;
	cin>>where_read.path>>where_read.current_file;
	
	where_read.check_path('r');		//check wheter the path already exist. If no, stop.
	config.fread(where_read);		//read the config, would stop if the files don't exit
	cout<<"\tNumber of particle: "<< config.P.size()<<endl;
	cout<<"\tNumber of contact: "<< config.C.size()<<endl;
	cout<<"\tSystem syze: ";
	config.cell.L.PRINT();
	cout<<endl<<endl;

	//set where to save the files during th simulation
	cout<<"Enter the path where to write the saving files (without final /)  and the first number of the file to be written"<<endl;
	cin>>where_save.path>>where_save.current_file;
	
	where_save.check_path('w');		//check whether the path already exist. If yes, stop.
	config.fprint(where_save);		// save the initial configuration, would stop if the files can't be opened
 
    // Converting to Keywords system
    config.cell.boundary = BOUNDARY;
	
	//what to simulate
	get_secure("Do you want to simule the thermal conduction", "CONDUCTION",	config.simule_thermal_conduction);
	get_secure("Do you want to simule the thermal production", "PRODUCTION",	config.simule_thermal_production);
	get_secure("Do you want to simule the thermal expansion", "EXPANSION",		config.simule_thermal_expansion);

    // Initial g vector
    config.cell.g.x[0]= 0.0;
    config.cell.g.x[1]= 0.0;
    config.cell.g.x[2]= 0.0;
    
    if(BOUNDARY == "HOLLOW_CYLINDER")
    {
        get_secure("Enter the Hollow Cylinder Geometry (HEIGHT)", "HEIGHT",config.cell.Height);
        get_secure("Enter the Hollow Cylinder Geometry (R External)", "REXTERNAL",config.cell.Rexternal);
        get_secure("Enter the Hollow Cylinder Geometry (R Internal)", "RINTERNAL",config.cell.Rinternal);
        config.cell.L.x[0] = 2*config.cell.Rexternal; // redefine Cell geometry with HOLLOW_CYLINDER KEYWORDS
        config.cell.L.x[1] = config.cell.Height;
        config.cell.L.x[2] = 2*config.cell.Rexternal;
    }
    
    if(BOUNDARY != "PERIODIC_SHEAR") // no gravity component for PERIODIC_SHEAR
    {
        get_secure("Enter the gravity (if no gravity, input 0)","GRAVITY",
                   config.cell.gravity);
        get_secure("Enter the slope angle", "SLOPE",config.cell.slope);}
    
	
	string choice;
	if(config.cell.boundary =="WALL_INCLINED") //input for inclined plane
	{
		config.cell.normal_stress_control=false;
		config.cell.normal_stress_ext=0;
		config.cell.normal_stress_control=false;
		config.cell.Vdilat=0; config.cell.Adilat=0;
        
        config.cell.g.x[0]=  config.cell.gravity*sin(PI/180.0 * config.cell.slope );
        config.cell.g.x[1]= -config.cell.gravity*cos(PI/180.0 * config.cell.slope );
        config.cell.g.x[2]= 0.0;
	}
    else if(config.cell.boundary =="PERIODIC_TILT") // input for tilting box
    {
        get_secure("The pressure at the given depth", "PRESSURE",
                   config.cell.earth_pressure);
        get_secure("The tilting angle speed", "TILT_SPEED",
                   config.cell.tilt_speed);
        config.cell.slope =0.0;
        config.cell.normal_stress_control = true;
        config.cell.shear_stress_control = true;
        config.cell.Vdilat=0; config.cell.Adilat=0;
    }
	else
	{//input for plane shear

        config.cell.Vdilat=0; config.cell.Adilat=0;
		config.cell.shear_stress_control=0;
		config.cell.shear_work_control=0;
		config.cell.stick_slip=0;
        config.cell.cell_vibration_freq = 0.0;
        config.cell.cell_velocity *= 0.0;
        config.cell.vibration_control =false;
        
        config.cell.g.x[1]= -config.cell.gravity; // Gravitational force
		
		//get the normal stress or volume control;
		get_secure("Do you want to control the normal stress or the volume",
                   "NORMAL_STRESS","VOLUME", "STRAIN_RATE", "VIBRATION",
                  choice);
		if(choice=="NORMAL_STRESS"){
            config.cell.normal_stress_control=true; cin>>config.cell.normal_stress_ext;
        }
		if(choice=="VOLUME"){
            config.cell.normal_stress_control=false; config.cell.Vdilat=0; config.cell.Adilat=0;
        }
		if(choice=="STRAIN_RATE"){
			config.cell.normal_stress_control=false; config.cell.Adilat=0;
			config.cell.normal_strain_control=true;
			double strain_rate; cin>>strain_rate; config.cell.Vdilat = -strain_rate*config.cell.L.x[1];
        }
Ejemplo n.º 2
0
void Cconfig::create_random()
{
	int Npart_flow,Npart_wall_bottom,Npart_wall_top;
	
	cout<<endl<<"Attempt to create a random configuration of grains with no overlaping"<<endl<<endl;	
	//System size	
	get_secure("Enter the size of the system","SIZE_CELL",cell.L);
	//Kind of boundary	
//	get_secure("Enter the kind of boundary you want along the y direction", "PERIODIC_SHEAR","WALL_INCLINED","WALL_SHEAR",cell.boundary);
    
    cell.boundary = BOUNDARY;
//    cout<<BOUNDARY<<endl;
    
	Npart_wall_bottom=0;
	Npart_wall_top=0;
    
	if(cell.boundary=="PERIODIC_SHEAR")
	{
	Npart_wall_bottom=0;	
	Npart_wall_top=0;	
	}

	if(cell.boundary=="WALL_INCLINED")
	{
		get_secure("Enter the number of grains of the bottom wall, including the plane (it counts as a grain)", "NPART_WALL_BOTTOM",Npart_wall_bottom);
		Npart_wall_top=0;	
		if(Npart_wall_bottom<1){serror="The number of grains on the bottom wall must be >=1";STOP("cdinit.cpp", "create_random()",serror);}
	}
	
	if(cell.boundary=="WALL_SHEAR")
	{
		get_secure("Enter the number of grains of the bottom wall (>=1), including the plan (it counts as one grain)", "NPART_WALL_BOTTOM",Npart_wall_bottom);
		get_secure("Enter the number of grains of the top wall  (>=1), including the plan (it counts as one grain)", "NPART_WALL_TOP",Npart_wall_top);	
		if(Npart_wall_bottom<1 || Npart_wall_top<1){serror="The number of grains on the wall must be >=1";STOP("cdinit.cpp", "create_random()",serror);}
	}
	

	get_secure("Enter the number of compositions", "COMPOSITION", parameter.COMPOSITION);
	if(parameter.COMPOSITION<1) parameter.COMPOSITION=1;
		
	std::vector <double> radius;
	double packing;

	for(int i=0;i<parameter.COMPOSITION;i++){
	get_secure("Enter the type of grain size distribution", "FRACTAL", "UNIFORM","VOLUME", parameter.GSD);
	get_secure("Enter the minimum diameter", "DMIN", parameter.Dmin);
	get_secure("Enter the minimum diameter", "DMAX", parameter.Dmax);
	if(parameter.GSD=="UNIFORM") get_secure("Enter the number of flowing grains (do not include the wall-grains)","NPART_FLOW",Npart_flow);
	if(parameter.GSD=="VOLUME") get_secure("Enter the number of flowing grains (do not include the wall-grains)","NPART_FLOW",Npart_flow);
	if(parameter.GSD=="FRACTAL")
		{
			 get_secure("Enter the fractal dimention of the grain size distribution","FRACTAL_DIM", parameter.fractal_dim);
			 get_secure("Enter the solid fraction wanted","SOLID_FRACTION", cell.solid_fraction);
		 }
		 
	srand( (unsigned int) time(NULL));//Init of random
	cout<<endl<<"Start the random setting of grains"<<endl;
	
	set_wall_grain(Npart_wall_bottom, Npart_wall_top); //set the grain of the wall and the planes (if there is any wall)
	
	std::vector <double> radius_tmp;
	set_radius(radius_tmp, Npart_flow);
	radius.insert(radius.end(),radius_tmp.begin(),radius_tmp.end());
	}
	
	cout<<"Number of flowing grains\t"<<radius.size()<<endl;
	
	get_secure("Enter the initial packing factor", "PACKING", packing); 
	if(packing<0 || packing>=1) {
		cout<<"This is not a realistic value for the initial packing factor! Setting to 0.5."<<endl;
		packing=0.5;
		}
	cout<<"A high initial packing factor may result in residual stresses after the packing stage."<<endl;
	
	// adjusting cell.L.x[1] for initial packing: fix box size, and expansion of grains.
	double volume=0.0;
	for(int ip=0;ip<radius.size();ip++) volume += pow(radius[ip],3.0);
	cell.L.x[2] = volume *4.0*PI/3.0 / packing /(cell.L.x[0]*cell.L.x[1]);
	cout<<"Adjusted cell depth for the initial packing\t"<<cell.L.x[2]<<endl;

	set_random_grain(Npart_flow, radius); 


	for(int ip=0;ip<P.size();ip++)//example of how to initiate things, mass is to be initiated here, it won't be change after
	{
		double RHO;
        parameter.RHO = 1.0;
//      RHO = 6./PI; //mass 1 for diameter 1, at temperature 20 C (may change with thermal expansion)
        RHO = parameter.RHO;  // default density is 1.0, may be changed during EVOLVE stage.
		
		if(P[ip].AM_I_BOUNDARY==0)//flowing particle
		{
			P[ip].m = 4./3. * PI * pow(P[ip].R_scale,3)*RHO;
			P[ip].T = 20;
		}
		if(P[ip].AM_I_BOUNDARY==-1 ||P[ip].AM_I_BOUNDARY==-2 )//bottom walls
		{
			P[ip].m = 0;  //don't care  the mass
			P[ip].T = 20;    //can be change as wish
		}
		
		if(P[ip].AM_I_BOUNDARY==1 ||P[ip].AM_I_BOUNDARY== 2 )//bottom walls
		{
			P[ip].m = 0;  //don't care the mass
			P[ip].T = 20;    //can be change as wish
		}
	}
	cout<<"Random configuration created: SUCCESS"<<endl<<endl;	

}