int main(int argc, char **argv) {
  char buffer[1024];
  float f[6];
  //float cen[6] = {0};
  float cen[6] = //{26.203939, 14.303870, 6.479383, -240.270966, 103.091614, 384.215027};
    {26.203751, 14.304119, 6.480038, -225.746475, 103.026428, 409.277405};
  int64_t i;
  //PARTICLE_MASS = 1.36e8*20;
  SCALE_NOW = 1.0;
  PARTICLE_MASS = 1.36e8;
  while (fgets(buffer, 1024, stdin)) {
    sscanf(buffer, "%f %f %f %f %f %f", f, f+1, f+2, f+3, f+4, f+5);
    //for (i=0; i<6; i++) cen[i]+=f[i];
    memcpy(pot[num_pot].pos, f, sizeof(float)*6);
    pot[num_pot].flags = 0;
    num_pot++;
    if (num_pot == NUM_POT) break;
  }
  //for (i=0; i<6; i++) cen[i]/=(float)num_pot;
  //for (i=0; i<100; i++)
  compute_kinetic_energy(pot, num_pot, cen);
  compute_potential(pot, num_pot);
  calc_circ_potential(pot, num_pot, cen);
  qsort(pot, num_pot, sizeof(struct potential), compare_x);
  for (i=0; i<num_pot; i++) {
    printf("%f %f %f %g %g %g\n", pot[i].pos[0], pot[i].pos[1], pot[i].pos[2],
	   pot[i].pe, pot[i].pe2, pot[i].pe-pot[i].ke); //, pot[i].ke, 
    //(pot[i].pe > pot[i].ke) ? 1 : 0);
  }
}
Esempio n. 2
0
void calc_potentials(void) {
  int64_t i,j=0,count=0,last_id=-1;
  for (i=0; i<num_p; i++) {
    if (p[i].hid != last_id) {
      if (last_id >= 0) h[last_id].num_p = i-h[last_id].p_start;
      last_id = p[i].hid;
      h[last_id].p_start = i;      
    }
  }
  if (last_id >= 0) h[last_id].num_p = i-h[last_id].p_start;

  for (i=0; i<num_h; i++) {
    struct halo *the_h = h+i;
    if (the_h->id < 0) continue;
    if (max_num_po < the_h->num_p) {
      max_num_po = the_h->num_p;
      po = check_realloc(po, sizeof(struct potential)*max_num_po, 
			 "Allocating potentials");
    }

    for (j=0; j<the_h->num_p; j++) {
      po[j].id = p[the_h->p_start+j].id;
      memcpy(po[j].pos, p[the_h->p_start+j].pos, sizeof(float)*6);
      po[j].pe = po[j].ke = 0;
    }
    compute_kinetic_energy(po, the_h->num_p, the_h->pos+3, the_h->pos);
    compute_potential(po, the_h->num_p);
    count=0;
    for (j=0; j<the_h->num_p; j++) if (po[j].pe >= po[j].ke) count++;
    printf("%"PRId64" %"PRId64"\n", the_h->id, count);
    for (j=0; j<the_h->num_p; j++) 
      if (po[j].pe >= po[j].ke) printf("%"PRId64"\n", po[j].id);
  }
}
Esempio n. 3
0
int compute_energy_error(double new_u[MAXSIZE][MAXSIZE], double new_w[MAXSIZE][MAXSIZE],
			 double new_r[MAXSIZE][MAXSIZE], double new_z[MAXSIZE][MAXSIZE],
			 double new_p[MAXSIZE][MAXSIZE], double new_q[MAXSIZE][MAXSIZE],
			 double new_epsilon[MAXSIZE][MAXSIZE], double new_theta[MAXSIZE][MAXSIZE],
			 double new_rho[MAXSIZE][MAXSIZE], double new_alpha[MAXSIZE][MAXSIZE],
			 double Gamma_k[MAXSIZE][MAXSIZE], double Gamma_l[MAXSIZE][MAXSIZE],
			 double deltat, double *new_c)
{
  double internal_energy = compute_internal_energy();
  double kinetic_energy =  compute_kinetic_energy(new_u,new_w);
  double boundary_work = compute_boundary_work(new_r,new_z,new_u,new_w,new_p,new_q,deltat);
  double boundary_heat = compute_boundary_heat(Gamma_k,Gamma_l,new_theta,deltat);
  *new_c = internal_energy + kinetic_energy - 
    boundary_heat - boundary_work;
};