Introduction
Introduction Statistics Contact Development Disclaimer Help
tshow status during verbose runs, define bond stiffnesses, set temporal paramet…
git clone git://src.adamsgaard.dk/slidergrid
Log
Files
Refs
README
LICENSE
---
commit bd4fc9c6e32224ee34ffce1e727317cc3b8375f5
parent 5d6e81a04a1e2fe6151185a4afeab15f67fc41b7
Author: Anders Damsgaard <[email protected]>
Date: Wed, 16 Mar 2016 15:39:54 -0700
show status during verbose runs, define bond stiffnesses, set temporal paramete…
Diffstat:
M slidergrid/main.c | 45 +++++++++++++++++++++++------…
M slidergrid/simulation.c | 9 ++++++++-
M slidergrid/slider.c | 14 ++++++++------
M test.c | 11 +++++++++--
4 files changed, 59 insertions(+), 20 deletions(-)
---
diff --git a/slidergrid/main.c b/slidergrid/main.c
t@@ -14,7 +14,8 @@ void print_usage(char* argv0)
"usage: %s [OPTION[S]]\n"
"options:\n"
" -h, --help\t\tprint this information\n"
- " -V, --version \tprint version information and exit\n"
+ " -v, --version \tprint version information and exit\n"
+ " -V, --verbose \tshow status during simulation\n"
, argv0, argv0);
}
t@@ -28,6 +29,13 @@ void print_version(char* argv0)
, argv0, VERSION);
}
+void print_status(simulation sim)
+{
+ printf("\r%s: t = %.3f s, t_end = %.3f s (%2.0f%%) ",
+ sim.id, sim.time, sim.time_end,
+ sim.time/sim.time_end*100.);
+}
+
int main(int argc, char** argv)
{
int i;
t@@ -43,22 +51,18 @@ int main(int argc, char** argv)
return 0;
}
- if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--version") == 0) {
+ if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
print_version(argv[0]);
return 0;
}
-
-
+ if (strcmp(argv[i], "-V") == 0 || strcmp(argv[i], "--verbose") == 0) {
+ verbose = 1;
+ continue;
+ }
}
-
-
-
-
-
-
// external function which defines the simulation setup and parameters
simulation sim = setup_simulation();
t@@ -78,14 +82,21 @@ int main(int argc, char** argv)
// check simulation parameters for missing or wrong parameter values
if (check_simulation_values(sim)) {
fprintf(stderr, "\nFatal error: The simulation configuration is "
- "invalid.\nPlease check the setup_simulation() configuration, "
+ "invalid.\n\n"
+ "Please check the setup_simulation() configuration, "
"which is verified in the function check_simulation_values "
"(simulation.c).\n");
return EXIT_FAILURE;
}
+ if (verbose) {
+ printf("starting simulation '%s'\n", sim.id);
+ printf("time step length: dt = %f s\n", sim.dt);
+ }
+
// main temporal loop
sim.iteration = 0;
+ Float time_since_status = 0.0;
for (sim.time = 0.0;
sim.time <= sim.time_end;
sim.time += sim.dt) {
t@@ -104,9 +115,21 @@ int main(int argc, char** argv)
update_kinematics(sim.sliders[i], sim.dt, sim.iteration);
}
+ if (verbose) {
+ if (time_since_status > sim.dt*100. ||
+ time_since_status >= sim.file_interval) {
+ print_status(sim);
+ time_since_status = 0.;
+ }
+ }
+
sim.iteration++;
+ time_since_status += sim.dt;
}
+ print_status(sim);
+ puts("");
+
// end program
free(sim.sliders);
return EXIT_SUCCESS;
diff --git a/slidergrid/simulation.c b/slidergrid/simulation.c
t@@ -38,8 +38,10 @@ int check_simulation_values(const simulation sim)
i, sim.sliders[i].moment_of_inertia);
return_status = 1;
}
+
}
+
// General parameters
if (sim.N <= 0) {
fprintf(stderr, "Error: The number of sliders (N = %d) must be a "
t@@ -53,6 +55,12 @@ int check_simulation_values(const simulation sim)
return_status = 1;
}
+ if (sim.dt > 1.0e9) {
+ fprintf(stderr, "Error: The numerical time step (dt = %f) is "
+ "invalid. Did you set bond_parallel_stiffness?\n", sim.dt);
+ return_status = 1;
+ }
+
if (sim.time > sim.time_end) {
fprintf(stderr, "Error: Current time (time = %f s) exceeds "
"total time (time_end = %f s)\n",
t@@ -74,7 +82,6 @@ int check_simulation_values(const simulation sim)
return_status = 1;
}
-
return return_status;
}
diff --git a/slidergrid/slider.c b/slidergrid/slider.c
t@@ -8,6 +8,14 @@ void print_slider_position(slider s)
printf("%f\t%f\t%f\n", s.pos.x, s.pos.y, s.pos.z);
}
+slider create_slider()
+{
+ slider s;
+
+
+ return s;
+}
+
void initialize_slider_values(slider s)
{
s.force = zeroes_float3();
t@@ -24,12 +32,6 @@ void initialize_slider_values(slider s)
}
-void check_slider_values(slider s)
-{
-
-
-}
-
/* Explicit temporal integration scheme based on three-term Taylor expansion.
* Truncation error O(dt^4) for positions, O(dt^3) for velocities. Accelerati…
* change is approximated by backwards differences. */
diff --git a/test.c b/test.c
t@@ -7,6 +7,7 @@ simulation setup_simulation()
{
// create empty simulation structure with default values
simulation sim = create_simulation();
+ sim.id = "test";
// initialize grid of sliders
int nx = 4;
t@@ -20,9 +21,15 @@ simulation setup_simulation()
// set slider masses and moments of inertia
int i;
for (i=0; i<sim.N; i++) {
- sim.sliders[i].mass = 1.;
- sim.sliders[i].moment_of_inertia = 1.;
+ sim.sliders[i].mass = 1.0e3;
+ sim.sliders[i].moment_of_inertia = 1.0e3;
+ sim.sliders[i].bond_parallel_stiffness = 1.0e5;
}
+ // set temporal parameters
+ sim.time = 0.0;
+ sim.time_end = 1.0;
+ sim.file_interval = 0.1;
+
return sim;
}
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.