Introduction
Introduction Statistics Contact Development Disclaimer Help
tadd time loop - slidergrid - grid of elastic sliders on a frictional surface
git clone git://src.adamsgaard.dk/slidergrid
Log
Files
Refs
README
LICENSE
---
commit bbe4664bdeb5aaaabec87ef1036e9ff95562e00d
parent fd19f30421f1a2866fbe554a73b8eff43f786ec5
Author: Anders Damsgaard <[email protected]>
Date: Tue, 15 Mar 2016 14:19:45 -0700
add time loop
Diffstat:
M main.c | 19 +++++++++++++++++++
M slider.c | 2 +-
M slider.h | 2 +-
3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/main.c b/main.c
t@@ -6,13 +6,32 @@
int main(int argc, char** argv)
{
+ // initialize grid of sliders
int nx = 4;
int ny = 4;
int nz = 4;
+ const int N = nx*ny*nz;
slider* sliders = create_regular_slider_grid(nx, ny, nz, 1.0, 1.0, 1.0);
+ // set slider masses
+ int i;
+ for (i=0; i<N; i++)
+ sliders[i].mass = 1.;
+ // temporal loop
+ Float t = 0.;
+ const Float t_end = 1.;
+ //Float dt = calculate_time_step();
+ Float dt = 1.0;
+ long int iteration = 0;
+ for (t=0.0; t<=t_end; t+=dt) {
+ for (i=0; i<N; i++) {
+ update_kinematics(sliders[i], dt, iteration);
+ }
+ iteration++;
+ }
+ // end program
free(sliders);
return EXIT_SUCCESS;
}
diff --git a/slider.c b/slider.c
t@@ -11,7 +11,7 @@ void print_slider_position(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. */
-void integrate_kinematics(slider s, Float dt, int iteration)
+void update_kinematics(slider s, Float dt, long int iteration)
{
s.acc = divide_float3_scalar(s.force, s.mass);
diff --git a/slider.h b/slider.h
t@@ -16,6 +16,6 @@ typedef struct {
void print_slider_position(slider s);
-void integrate_kinematics(slider s, Float dt, int iteration);
+void update_kinematics(slider s, Float dt, long int iteration);
#endif
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.