Home My Page Projects Code Snippets Project Openings diderot
 Summary Activity Tracker Tasks SCM

# SCM Repository

[diderot] Diff of /branches/lamont/test/implicit-surface/unit-circle.diderot
 [diderot] / branches / lamont / test / implicit-surface / unit-circle.diderot

# Diff of /branches/lamont/test/implicit-surface/unit-circle.diderot

revision 2137, Thu Feb 14 12:39:47 2013 UTC revision 2138, Thu Feb 14 20:49:22 2013 UTC
# Line 2  Line 2
2  //  //
3  // Demo of distributing particles on the unit circle  // Demo of distributing particles on the unit circle
4  //  //
5  real{} initPosns = load("data/implicit-surface/circlePosns.nrrd");  real{} initPosns = load("../../data/implicit-surface/circlePosns.nrrd");
6  int numOfParticles = length(initVelocities)/2;  int numOfParticles = 100;
7  input real r;  // particle radius  input real r = 0.2;  // particle radius
8  input real d;  // desired difference of radius (d < r && d > 0)  input real d = 0.1;  // desired difference of radius (d < r && d > 0)
9  input real R;  // neighbor radius  input real R = 0.9;  // neighbor radius
10  input real h;  // integration stepsize scaling ∇E update lenght  input real h;  // integration stepsize scaling ∇E update lenght
11  input real maxi; // maximum number of steps in the program  input int maxi = 1000; // maximum number of steps in the program
12
13  strand Particle (real posx, real posy) {  strand Particle (real posx, real posy) {
14      output vec2 pos = [posx,posy];      vec2 pos = [posx,posy];
15      real isoval = 1;      real isoval = 1;
16      int steps = 0;      int steps = 0;
17        output vec2 outPos  = pos;
18      update {      update {
19          real energy = 0.0;          real energy = 0.0;
20          real force = 0.0;          real force = 0.0;
real raduis =0.01;
21
22          for(Particle neighbor in sphere(raidus) {          foreach(Particle neighbor in sphere(R)){
23              real d = distance (pos,neighbor.pos);              real d = dist (pos,neighbor.pos);
24              if(d >= 0 && d <= 1) {              if(d >= 0 && d <= 1) {
25                     force += -4.0 * ((1 - d)^3);                     force += -4.0 * ((1 - d)^3);
26                     energy += ((1 - d)^4);                     energy += ((1 - d)^4);
27               }               }
28          }          }
29          pos = pos + force;          printf("f : ", force, "\n");
30            pos *= force;
31          pos = pos / |pos|;          pos = pos / |pos|;
32            outPos = pos;
33            steps+=1;
34            if(steps >= maxi)
35                stabilize;
36      }      }
37  }  }
38  initially {Particle(initPosns{i*2},initPosns{i*2+1}) | i in 0 .. numOfParticles-1 };  initially {Particle(initPosns{i*2},initPosns{i*2+1}) | i in 0 .. numOfParticles-1 };

Legend:
 Removed from v.2137 changed lines Added in v.2138

 root@smlnj-gforge.cs.uchicago.edu ViewVC Help Powered by ViewVC 1.0.0