/* * Main simulation */ void Simulation::simulationSteadyShear(string in_args, vector<string>& input_files, bool binary_conf, double dimensionless_number, string input_scale, string control_variable, string simu_identifier) { string indent = " Simulation::\t"; control_var = control_variable; setupSimulation(in_args, input_files, binary_conf, dimensionless_number, input_scale, simu_identifier); time_t now; time_strain_1 = 0; now = time(NULL); time_strain_0 = now; setupEvents(); cout << indent << "Time evolution started" << endl << endl; TimeKeeper tk = initTimeKeeper(); int binconf_counter = 0; while (keepRunning()) { timeEvolutionUntilNextOutput(tk); set<string> output_events = tk.getElapsedClocks(sys.get_time(), sys.get_curvilinear_strain()); generateOutput(output_events, binconf_counter); printProgress(); if (time_strain_1 == 0 && sys.get_curvilinear_strain() > 1) { now = time(NULL); time_strain_1 = now; timestep_1 = sys.get_total_num_timesteps(); } } now = time(NULL); time_strain_end = now; timestep_end = sys.get_total_num_timesteps(); outputComputationTime(); string filename_parameters = input_files[1]; if (filename_parameters.find("init_relax", 0) != string::npos) { /* To prepare relaxed initial configuration, * we can use Brownian simulation for a short interval. * Here is just to export the position data. */ string filename_configuration = input_files[0]; outputFinalConfiguration(filename_configuration); } cout << indent << "Time evolution done" << endl << endl; }
void Simulation::simulationInverseYield(string in_args, vector<string>& input_files, bool binary_conf, double dimensionless_number, string input_scale, string control_variable, string simu_identifier) { control_var = control_variable; setupSimulation(in_args, input_files, binary_conf, dimensionless_number, input_scale, simu_identifier); int jammed = 0; time_t now; time_strain_1 = 0; now = time(NULL); time_strain_0 = now; /******************** OUTPUT INITIAL DATA ********************/ sys.calcStress(); outputData(); // new outputConfigurationBinary(); outputConfigurationData(); /*************************************************************/ TimeKeeper tk; tk.addClock("data", LinearClock(p.time_interval_output_data, input_values["time_interval_output_data"].unit == "strain")); tk.addClock("config", LinearClock(p.time_interval_output_config, input_values["time_interval_output_config"].unit == "strain")); int binconf_counter = 0; while (keepRunning()) { pair<double, string> t = tk.nextTime(); pair<double, string> s = tk.nextStrain(); if (t.second.empty()) { // no next time sys.timeEvolution(-1, s.first); } else if (s.second.empty()) { // no next strain sys.timeEvolution(t.first, -1); } else { // either next time or next strain sys.timeEvolution(t.first, s.first); } set<string> output_events = tk.getElapsedClocks(sys.get_time(), sys.get_curvilinear_strain()); generateOutput(output_events, binconf_counter); cout << "time: " << sys.get_time() << " / " << p.time_end << endl; if (!sys.zero_shear && abs(sys.get_shear_rate()) < p.rest_threshold) { cout << "shear jamming " << jammed << endl; jammed ++; if (jammed > 20) { sys.set_shear_rate(1); cout << "target_stress = " << target_stress_input << endl; target_stress_input *= 0.95; sys.target_stress = target_stress_input/6/M_PI; throw runtime_error("use of updateUnscaledContactmodel() invalid"); // sys.updateUnscaledContactmodel(); cout << "new target_stress = " << target_stress_input << endl; jammed = 0; } } else { jammed = 0; } if (time_strain_1 == 0 && sys.get_curvilinear_strain() > 1) { now = time(NULL); time_strain_1 = now; timestep_1 = sys.get_total_num_timesteps(); } } now = time(NULL); time_strain_end = now; timestep_end = sys.get_total_num_timesteps(); outputComputationTime(); string filename_parameters = input_files[1]; if (filename_parameters.find("init_relax", 0) != string::npos) { /* To prepare relaxed initial configuration, * we can use Brownian simulation for a short interval. * Here is just to export the position data. */ string filename_configuration = input_files[0]; outputFinalConfiguration(filename_configuration); } }