示例#1
0
文件: stars.c 项目: domaubert/EMMA
int getNstars2create(struct CELL *cell, struct RUNPARAMS *param, REAL dt, REAL aexp, int level, REAL mstar){
// ----------------------------------------------------------//
/// Compute the number of stars to create in a given cell\n
/// And do a random draw in a Poisson law
// ----------------------------------------------------------//

  REAL dv=pow(0.5,3*level);
  REAL SFR=getSFR(cell,param,aexp,level);
  // Average number of stars created
	REAL lambda =  SFR  / mstar * dt * dv;

#ifdef GSLRAND
	unsigned int N = gsl_ran_poisson (param->stars->rpoiss, (double)lambda);
#else
	unsigned int N = gpoiss(lambda); //Poisson drawing
#endif // GSLRAND

	if(N){
	  //printf("tstar=%e lambda=%e\n",t0/(3600.*24.*365.*1e9),lambda);
	  //printf("AVG star creation =%e /eff %d  SFR=%e\n",lambda,N,SFR);
	}

	REAL M_in_cell = cell->field.d * POW(2.0,-3.0*level); // mass of the curent cell in code unit
	if(N * mstar >= M_in_cell) N = 0.9*M_in_cell / mstar ; // 0.9 to prevent void cells

#ifdef CONTINUOUSSTARS
  N=1;
#endif // CONTINUOUSSTARS

  return N;
}
示例#2
0
文件: stars.c 项目: domaubert/EMMA
REAL getMstars2create(struct CELL *cell, struct RUNPARAMS *param, REAL dt, REAL aexp, int level){

  REAL dv=pow(0.5,3*level);
  REAL SFR=getSFR(cell,param,aexp,level);

//average mass to create in cell
	REAL m_sfr =  SFR  *dt *dv;

	/// TODO drawn in a statistical law

	return m_sfr;
}
示例#3
0
文件: output.c 项目: vmouse/Cowshed
void _output_setup() {
	for (uint8_t i=0; i<_output_index; i++) {
		//DDR
		_SFR_IO8(getSFR(i) + _DDR) |= 1<<getBit(i);
		//state
		if (getState(i) == 0) {
			setLo(i);
		} else {
			setHi(i);
		}

	}
}