Exemplo n.º 1
0
void star2dR::solve_definitions(solver *op) {

	star2d::solve_definitions(op);

	matrix rho0,xi0,eps0;
	double rhoc0,Xc0;

	rho0=rho;xi0=opa.xi;eps0=nuc.eps;rhoc0=rhoc;Xc0=Xc;

	double dXc=1e-8;

	Xc+=dXc;
	init_comp();
	nuclear();
	opacity();
	eq_state();
	matrix drho_dXc,dxi_dXc,deps_dXc,dlnrhoc_dXc;

	dlnrhoc_dXc=(rhoc-rhoc0)/rhoc0/dXc*ones(1,1);
	drho_dXc=(rho-rho0)/dXc+rho0*dlnrhoc_dXc;
	dxi_dXc=(opa.xi-xi0)/dXc;
	deps_dXc=(nuc.eps-eps0)/dXc;

	Xc=Xc0;
	fill();

	for(int n=0;n<ndomains;n++) op->add_d(n,"log_rhoc","Xc",dlnrhoc_dXc);
	op->add_d("rho","Xc",drho_dXc);
	op->add_d("opa.xi","Xc",dxi_dXc);
	op->add_d("nuc.eps","Xc",deps_dXc);

}
Exemplo n.º 2
0
void star2dR::fill() {

	init_comp();
	eq_state();
	m=2*PI*(map.gl.I,rho*r*r*map.rz,map.leg.I_00)(0);
	M=m*rhoc*R*R*R;
	double R0=R;
	star2d::fill();
	R=R0;
	Omega_bk=Omega/Omegac;
	if(Teff_obj==-1) Teff_obj=map.leg.eval_00(Teff(),0)(0);
	if(Re_obj==-1) Re_obj=map.leg.eval_00(r.row(-1),PI/2)(0)*R;
}
Exemplo n.º 3
0
void main( void )
{
  // initialize all system relevant modules like
  // Clock System, Power Managment Module, I/O-Ports
  init_wdta ();
  init_port ();
  init_cs ();
  init_port_sw2 ();
  init_comp ();

//  __bis_SR_register(LPM4_bits+GIE);   // Enter LPM3, enable interrupts

  while (1)
  {
  	 delay_250ms(1);
     if (comp()==0)
	 {
       P1OUT |= 0x01;
       delay_1ms(200);
       P1OUT &= ~0x01;
	 }
  }
}
Exemplo n.º 4
0
int star1d::init(const char *input_file,const char *param_file,int argc,char *argv[]) {
    DEBUG_FUNCNAME;
	cmdline_parser cmd;
	file_parser fp;
	char *arg,*val,default_params[256];
	mapping map0;
	int i,k,change_grid=0;
	matrix Tr;

	sprintf(default_params,"%s/ester/1d_default.par", ESTER_DATADIR);

	if(*input_file) {
		if(read(input_file, 1)) {
			printf("Error reading input file: %s\n",input_file);
			return 1;
		}
		map0=map;
	} else {
		if(!fp.open(default_params)) { 
			printf("Can't open default parameters file %s\n",default_params);
			return 1;
		}
		else {
			while((k=fp.get(arg,val))) {
				if((i=check_arg(arg,val,&change_grid))) {
					printf("Syntax error in parameters file %s, line %d\n",param_file,k);
					if(i==2) {
						printf("Error: Argument to '%s' missing\n",arg);
						return 1;
					}
					if(i==1) {
						printf("Unknown parameter %s\n",arg);
						return 1;
					}
				}
			}
			fp.close();
		}
		change_grid=0;
	}
	
	if(*param_file) {
		if(!fp.open(param_file)) { 
			printf("Can't open parameters file %s\n",param_file);
			return 1;
		}
		else {
			while((k=fp.get(arg,val))) {
				if((i=check_arg(arg,val,&change_grid))) {
					printf("Sintax error in parameters file %s, line %d\n",param_file,k);
					if(i==2) {
						printf("Error: Argument to '%s' missing\n",arg);
						return 1;
					}
					if(i==1) {
						printf("Unknown parameter %s\n",arg);
						return 1;
					}
				}
			}
			fp.close();
		}
	}
	
	cmd.open(argc,argv);
	while(int err_code=cmd.get(arg,val)) {
		if(err_code==-1) exit(1);
		err_code=check_arg(arg,val,&change_grid);
		if(err_code==2) {
			fprintf(stderr,"Error: Argument to '%s' missing\n",arg);
			return 1;
		}
		if(err_code==1) {
			fprintf(stderr,"Unknown parameter '%s'\n",arg);
			return 1;
		}
		cmd.ack(arg,val);
	}
	cmd.close();
	
	if((change_grid&1)&&!(change_grid&2)) {
		fprintf(stderr,"Must specify number of points per domain (npts)\n");
		exit(1);
	}
	if (*input_file) {
		if(change_grid) {
			mapping map_new;
			map_new=map;
			map=map0;
			remap(map_new.ndomains,map_new.gl.npts,map_new.nt,map_new.nex);
		}
	} else {
		map.leg.npts=1;
		map.init();
		T=1-0.5*r*r;
		p=T;
		phi=-T;
		G=0*T;
		w=0*T;
		conv=0;
		domain_type.resize(ndomains);
		for(int n=0;n<ndomains;n++) domain_type[n]=RADIATIVE;
		phiex=zeros(map.nex,map.nt);
	}
	
	init_comp();
	fill();
	
	return 0;
}