예제 #1
0
void irc_channels_init(void)
{
	signal_add("server looking", (SIGNAL_FUNC) sig_server_looking);
	signal_add("channel destroyed", (SIGNAL_FUNC) sig_channel_destroyed);

	channel_events_init();
	channel_rejoin_init(); /* after channel_events_init() */
        channels_query_init();
	irc_channels_setup_init();

	bans_init();
        modes_init();
	mode_lists_init();
	massjoin_init();
	irc_nicklist_init();
}
예제 #2
0
void io_init()
{
  // input states
  PC_SET_INPUT_PULLUP(PC_IO_ENC_BUTTON);
  PC_SET_INPUT_PULLUP(PC_IO_BITS_SWITCH);
  PC_SET_INPUT_PULLUP(PC_IO_ENC0);
  PC_SET_INPUT_PULLUP(PC_IO_ENC1);

  // read initial encoder state
  uint8_t encInp = IO_READ_ENCODER;
  encInp ^= 0b11;
  io_curr_enc_state = pgm_read_byte(&io_greyToState[encInp]);

  // read initial button statuses
  io_curr_bits_sw = PC_CHECK(PC_IO_BITS_SWITCH);

  // read initial pot values
  for (int i = 0; i < avrAdc_inputVector_length; ++i)
  {
    io_curr_pots[i] = avrAdc_inputVector[i];
  }

  modes_init();
}
예제 #3
0
// ---------------------------------------------------------------------------
/// Function supposes that last cached chapter is photo-electrons with no perturbations and
/// adds perturbation with given spectral properties (to study electrostatic two-stream instability).
// ---------------------------------------------------------------------------
void
tag_seed_PITS (FILE *fp, meshVec_p E)
{
#if 0
  int    mz, mz_start, mz_stop, ID;
  double phase0, gamma_cutOff;
  markerIterator_t page;

  dEz = cfg_readDouble (fp);												// Reads parameters.
  mz_start = cfg_readInt (fp);
  mz_stop  = cfg_readInt (fp);
  gamma_cutOff = cfg_readDouble (fp);
  phase0 = cfg_readDouble (fp)*mc_pi;

  if (mz_start > mz_stop)
    error ("tag_seed2Stream: bad spectrum range\n.");

  modes_init (mz_start, mz_stop, gamma_cutOff, phase0);									// Initializes wave spectrum.

  say ("%s: ", __func__);											// Prints info.
  say ("  - spectrum of the unstable electrostatic modes is excited,");
  say ("  - detailes are written to 'output/tag_seed2Stream.dat',");
  say ("  - modes from %d to %d,", mz_start, mz_stop);
  if (10*abs (mz_start) >= dmn_max[2] - dmn_min[2] || 10*abs (mz_stop) >= dmn_max[2] - dmn_min[2])
    msg_warning (mf_here, "bad resolutions for modes >= %d.", (dmn_max[2] - dmn_min[2])/10);
  if (phase0 < 0)
    say ("  - phases are random,");
  else
    say ("  - phases are fixed to %f \\pi,", phase0/mc_pi);
  say ("  - amplitude %e,", dEz);
  say ("  - gamma-cutoff is %e.", gamma_cutOff);

  if (memEstimateOnly)
    return;

  tag_photoDF_parameters (mc_photoDF_ID, &ID);										// Gets ID to access particles.
  if (ID < 0)
    error ("tag_seed2stream: photo-DF component is not created yet.");

  cache_flush ();													// Flushes cache before doing any updates.
  double dzMax = -1, dzMin = +1;
  double dvMax = -1e10, dvMin = +1e10;
/*
  FILE *seedFile = cfg_open ("output/tag_seed_PITS.dat", "wt", __func__);
  fprintf (seedFile, "variables = z, v_z, `dz, `dv_z, `dz_n_u_m, `dv_z_n_u_m\n");*/
  for (markerPage_first (ID, &page) ; page.df ; markerPage_next (&page))						// Adds perturbation of DF.
  {
    int p;
    marker_t *f = page.df;
    for (p = 0 ; p < page.N ; ++p)
    {
      const double oldZ = f[p].z;
      const double oldVZ = f[p].vz;
      double newZ = oldZ, newVZ = oldVZ;
      for (mz = mz_start ; mz <= mz_stop ; ++mz)									// Adds perturbation for each mode.
      {
        double kz, gamma, phase;											// Parameters of the mode.
        double kzz, kzvz, gamma2, dv, dz;										// Shortcuts for derivatives.

        if (!mz)													// There are no zero mode.
          continue;

        kz = 2*mc_pi*mz/Lz;												// Extracts mode form spectrum arrays.
        gamma = modeGamma[mz-modeM1];
        phase = modePhase[mz-modeM1];

        if (gamma < gamma_cutOff)
          continue;

        kzz = oldZ*kz;													// Adds perturbation of velocity and position.
        kzvz = oldVZ*kz/(2*mc_pi);
        gamma2 = gamma*gamma;
        dv = - page.qDivM*dEz*(kzvz*cos (kzz + phase) - gamma*sin (kzz + phase))/(2*mc_pi*(gamma2 + kzvz*kzvz));
        dz = page.qDivM*dEz*((gamma2 - kzvz*kzvz)*sin (kzz + phase) - 2*gamma*kzvz*cos (kzz + phase))/(4*mc_pi*mc_pi*(gamma2 + kzvz*kzvz)*(gamma2 + kzvz*kzvz));

        newZ += dz;
        newVZ += dv;
      }

      dzMax = (dzMax < newZ - oldZ) ? newZ - oldZ : dzMax;
      dzMin = (dzMin > newZ - oldZ) ? newZ - oldZ : dzMin;
      dvMax = (dvMax < newVZ - oldVZ) ? newVZ - oldVZ : dvMax;
      dvMin = (dvMin > newVZ - oldVZ) ? newVZ - oldVZ : dvMin;

/*      double z = f[p].z, vz = f[p].vz;
*/
      f[p].z = fmod (newZ + 4*Lz, Lz);
      f[p].vz = newVZ;
/*
      fprintf (seedFile, "%e %e %e %e %e %e\n", z, vz, f[p].z - z, f[p].vz - vz, f[p].z - z, f[p].vz - vz);*/
    }
  }
/*  fclose (seedFile);
*/
  for (mz = mz_start ; mz <= mz_stop ; mz++)										// Adds perturbation of electric field.
  {
    int i, j, k;
    double kz, gamma, phase;												// Parameters of the mode.

    if (!mz)														// There are no zero mode.
      continue;

    kz = 2*mc_pi*mz/Lz;													// Extracts mode from spectrum arrays.
    gamma = modeGamma[mz-modeM1];
    phase = modePhase[mz-modeM1];

    if (gamma < gamma_cutOff)
      continue;

    for (i = E->imin ; i <= E->imax ; i++)										// Adds perturbation of electric field.
      for (j = E->jmin ; j <= E->jmax ; j++)
        for (k = E->kmin ; k <= E->kmax ; k++)
        {
          const double kzz = (k - 0.5)*kz*h3;
          mv_fz(E, i, j, k) += dEz*sin (kzz + phase);
        }
  }

  say ("  - %.3e <= dz <= %.3e (h3 = %.3e),", dzMin, dzMax, h3);
  say ("  - %.3e <= dvz <= %.3e,", dvMin, dvMax);
#endif
  assert (0);
}