Changeset 32918
- Timestamp:
- Dec 9, 2011, 11:15:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.astro/spex2dgas.c
r32909 r32918 49 49 void sortfriends (float *X, int *IDX1, int N); 50 50 51 void get_pressure_gradient (int iObj ) {51 void get_pressure_gradient (int iObj, int nCloseMax, float farFrac, int nearNeighbors, float maxPressure) { 52 52 53 53 int i; … … 57 57 58 58 // only use the first N friends 59 for (i = 0; (i < 10) && (i <object[iObj].Nindex); i++) {59 for (i = 0; (i < object[iObj].Nindex); i++) { 60 60 int jObj = object[iObj].index[i]; 61 61 62 // only use the 0th object? 63 // if (jObj != 0) continue; 64 62 // some options: 63 // if the iterations are small, we should only worry about getting the near neighbors right 64 // if the iterations are large, we should add in more distant objects 65 if (nearNeighbors && (i >= nCloseMax)) break; 66 if (!nearNeighbors && (i >= nCloseMax)) { 67 if (drand48() > farFrac) continue; 68 } 65 69 66 70 float Dtgt = object[iObj].Dtgt[i]; … … 72 76 // float dF = (Dcur < 0.01*Dtgt) ? -100.0 : (Dcur - Dtgt) / Dcur; XXX modified spring constant : too crazy 73 77 float dF = (Dcur - Dtgt); 74 dF = MIN ( 100.0, MAX (-100.0, dF));78 dF = MIN (maxPressure, MAX (-maxPressure, dF)); 75 79 76 80 float dPdXi = dF * dX / Dcur; … … 83 87 } 84 88 85 // fprintf (stderr, "Dcur,Dtgt : %f %f : dX,dY,dP : %f %f : %f : %f %f\n", Dcur, Dtgt, dX, dY, dF, dPdXi, dPdYi); 89 if (i >= nCloseMax) { 90 fprintf (stderr, "Dcur,Dtgt : %f %f : dX,dY,dP : %f %f : %f : %f %f\n", Dcur, Dtgt, dX, dY, dF, dPdXi, dPdYi); 91 } 86 92 dPdX += dPdXi; 87 93 dPdY += dPdYi; … … 111 117 srand48(B); 112 118 113 if (argc != 5) goto usage;119 if (argc != 9) goto usage; 114 120 115 121 if ((index1 = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) goto escape; … … 117 123 if ((distance = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) goto escape; 118 124 int Niter = atoi (argv[4]); 125 int nCloseMax = atoi (argv[5]); 126 int nCloseIter = atoi (argv[6]); 127 float farFrac = atof (argv[7]); 128 float maxPressure = atof (argv[8]); 119 129 // XXX enforce matching lengths on the three vectors 120 130 … … 204 214 fprintf (stderr, "iter %d\n", iter); 205 215 216 int nearNeighbors = (iter < nCloseIter); 217 206 218 // measure (dP/dX),(dP/dY) for all objects 207 219 for (i = 0; i < Nobject; i++) { 208 get_pressure_gradient (i );220 get_pressure_gradient (i, nCloseMax, farFrac, nearNeighbors, maxPressure); 209 221 move_object (i); 210 222 } … … 229 241 230 242 usage: 231 gprint (GP_ERR, "USAGE: mkclusters (index1) (index2) (distance) scale\n");243 gprint (GP_ERR, "USAGE: spex2dgas (index1) (index2) (distance) (Niter) (nCloseMax) (nCloseIter) (farFrac) (maxPressure)\n"); 232 244 return FALSE; 233 245 }
Note:
See TracChangeset
for help on using the changeset viewer.
