Пример #1
0
int p_hor3DTIH(Stiff2D *spar1, int mode, double sangle, double cangle, 	
	       double sazi, double cazi, double *p)
/*****************************************************************************
Given incidence angle and azimuth, compute the horizontal slowness for 
media of TIH symmetry and azimuthal propagation. 

Input
	spar1	density normalized stiffness components
	mode	wave mode (=0 P; =1 SV; =2 SP)
	sangle	sin(incidence angle)
	cangle  cos(incidence angle)
	sazi	sin(azimuth from symmetry axis)
	cazi	cos(azimuth from symmetry axis)

Output 
	p	horizontal slowness
Notes:
	routine returns (-1) if evanescent energy present
	it is assumed that density normalized stiffnesses are
	physically reasonable. 
******************************************************************************
Author:
	  Andreas Rueger, Colorado School of Mines, 01/29/95
******************************************************************************/
{
	double d1=cazi*sangle;
	double d2=sazi*sangle;
	double d3=cangle;
	double v;

	/* get phase velocity for propagation angle */
	if(phasevel3DTIH(spar1,mode,d1,d2,d3,&v) != 1){
		fprintf(stderr,"\n  ERROR in phasevel3DTIH \n ");
		return (-1);
	}

	if(info){
		ddprint(d1);
		ddprint(d2);
		ddprint(d3);
		ddprint(v);
	}

	*p=sangle/v;
	
	return (1);
}
Пример #2
0
/* the main program */
int main (int argc, char **argv)
{
	double vp1,vp2,vs1,vs2,rho1,rho2;
	double eps1,eps2,delta1,delta2;
	double gamma1,gamma2,azimuth;
	float fangle,langle,dangle,angle;
	double *coeff,p=0;
	double sangle,cangle,sazi,cazi;
	float anglef,dummy;
	FILE *outparfp=NULL, *coeffp=NULL;
	int ibin,modei,modet,rort,iangle,iscale,index;
	char *outparfile=NULL,*coeffile=NULL;
	Stiff2D *spar1, *spar2;
	double **a,*rcond,*z;
	int *ipvt;

	/* allocate space for stiffness elements */
	spar1=(Stiff2D*)emalloc(sizeof(Stiff2D));
	spar2=(Stiff2D*)emalloc(sizeof(Stiff2D));

	/* allocate space for matrix system */
	a = alloc2double(6,6);
	coeff = alloc1double(6);
	ipvt=alloc1int(6);
	z = alloc1double(6);
	rcond=alloc1double(6);

	/* hook up getpar to handle the parameters */
	initargs(argc,argv);
	requestdoc(0);

	if (!getparint("ibin",&ibin)) ibin = 1;
	if (!getparint("modei",&modei)) modei = 0;
	if (!getparint("modet",&modet)) modet = 0;
	if (!getparint("rort",&rort)) rort = 1;
        if (!getparint("iscale",&iscale)) iscale = 0;
	if (!getparint("test",&test)) test = 1;
	if (!getparint("info",&info)) info = 0;

	if(modei != 0 && modei !=1 && modei !=2){
		fprintf(stderr," \n ERROR wrong incidence mode \n");
		return (-1);	/* wrong mode */
	}

	if(modet != 0 && modet !=1 && modet !=2){
		fprintf(stderr," \n ERROR wrong scattering mode \n");
		return (-1);	/* wrong mode */
	}

        if(rort != 0 && rort !=1){
                fprintf(stderr," ERROR wrong rort parameter \n");
                return (-1);    /* wrong mode */
        }

        if(iscale != 0 && iscale !=1 && iscale !=2 && iscale!=3 ){
                fprintf(stderr," ERROR wrong iscale parameter \n");
                return (-1);    /* wrong mode */
        }


	if (!getparfloat("fangle",&fangle)) fangle = 0.0;
	if (!getparfloat("langle",&langle)) langle = 45.0;
	if (!getparfloat("dangle",&dangle)) dangle = 1.0;

	if (!getpardouble("azimuth",&azimuth)) azimuth = 0.;
	if (!getpardouble("vp1",&vp1)) vp1 = 2.0;
	if (!getpardouble("vp2",&vp2)) vp2 = 2.0;
	if (!getpardouble("vs1",&vs1)) vs1 = 1.0;
	if (!getpardouble("vs2",&vs2)) vs2 = 1.0;
	if (!getpardouble("rho1",&rho1)) rho1 = 2.7;
	if (!getpardouble("rho2",&rho2)) rho2 = 2.7;

	if (!getpardouble("eps1",&eps1)) eps1 = 0.;
	if (!getpardouble("eps2",&eps2)) eps2 = 0.;

	if (!getpardouble("delta1",&delta1)) delta1 = 0.;
	if (!getpardouble("delta2",&delta2)) delta2 = 0.;
	if (!getpardouble("gamma1",&gamma1)) gamma1 = 0.;
	if (!getpardouble("gamma2",&gamma2)) gamma2 = 0.;

	if (getparstring("outparfile",&outparfile)) {
                 outparfp = efopen(outparfile,"w");
        } else {
                 outparfp = efopen("outpar","w");
        }

	if (getparstring("coeffile",&coeffile)) {
                 coeffp = efopen(coeffile,"w");
        } else {
                 coeffp = efopen("coeff.data","w");
        }


	/******   some debugging information ******************/
	if(info){
		ddprint(azimuth);
		ddprint(vp1); ddprint(vs1); ddprint(rho1);
		ddprint(eps1); ddprint(delta1); ddprint(gamma1);

		ddprint(vp2); ddprint(vs2); ddprint(rho2);
		ddprint(eps2); ddprint(delta2); ddprint(gamma2);
	}


	/* convert into rad */
	azimuth=azimuth*PI /180.;
	sazi=sin(azimuth);
	cazi=cos(azimuth);

	/******   convertion into cij's ************************/
	if (!thom2stiffTI(vp1,vs1,eps1,delta1,gamma1,PI/2.,spar1,1) ){
		fprintf(stderr," \n ERROR in thom2stiffTI (1) \n");
		return (-1);
	}

	if (!thom2stiffTI(vp2,vs2,eps2,delta2,gamma2,PI/2.,spar2,1) ){
		fprintf(stderr,"\n ERROR in thom2stiffTI (2) \n");
		return (-1);
	}

	/*****    more debugging output ************************/
	
	if(info){
		diprint(modei);
		diprint(modet);
		diprint(rort);
		ddprint(spar1->a1111);
		ddprint(spar1->a3333);
		ddprint(spar1->a1133);
		ddprint(spar1->a1313);
		ddprint(spar1->a2323);
		ddprint(spar1->a1212);

		ddprint(spar2->a1111);
		ddprint(spar2->a3333);
		ddprint(spar2->a1133);
		ddprint(spar2->a1313);
		ddprint(spar2->a2323);
		ddprint(spar2->a1212);
	}

	/********  find generated wave type-index     ************/
	/* reflect_P (0) reflect_S (1) transm_P (2) transm_S (3) */

	if(modet == 0 && rort==1)
		index = 0;
	else if(modet == 1 && rort==1)
		index = 1;
	else if(modet == 2 && rort==1)
		index = 2;
	else if(modet == 0 && rort==0)
		index = 3;
	else if(modet == 1 && rort==0)
		index = 4;
	else if(modet == 2 && rort==0)
		index = 5;
	else {
		fprintf(stderr,"\n ERROR wrong (index) \n ");
		return (-1);
	}


	/***************** LOOP OVER ANGLES ************************/
	for(angle=fangle,iangle=0;angle<=langle;angle+=dangle){
		
		if(info) ddprint(angle);
	
		sangle=(double) angle*PI/180;
		cangle=cos(sangle);
		sangle=sin(sangle);


		/* get horizontal slowness */
		if(p_hor3DTIH(spar1,modei,sangle,cangle,sazi,cazi,&p)!=1){
			fprintf(stderr,"\n ERROR in p_hor3DTIH \n ");
			return (-1);
		}

		/* compute reflection/transmission coefficient */
		if(graebner3D(spar1,spar2,rho1,rho2,modei,modet,rort,
		   sazi,cazi,p,coeff,a,ipvt,z,rcond)!=1){
			fprintf(stderr,"\n ERROR in p_hor3DTIH \n ");
			return (-1);
		}

		++iangle;

                if(iscale==0)
                     anglef=(float) angle;
                else if(iscale==1)
                     anglef=(float) angle*PI/180.;
                else if(iscale==2)
                     anglef=(float) p;
                else if(iscale==3) 
                     anglef=(float) sangle*sangle;
                  
                dummy= (float)coeff[index];
                  

                /* Binary output for x_t */
                if(ibin==1){

                        fwrite(&anglef,sizeof(float),1,coeffp);
                        fwrite(&dummy,sizeof(float),1,coeffp);

                /* ASCII output  */
                } else if(ibin==0){

                        fprintf(coeffp,"%f      %f\n",anglef,dummy);
		}
	}

	/*********  No of output pairs for plotting ********/
	if(ibin) fprintf(outparfp,"%i\n",iangle);

	return 1;
}
Пример #3
0
static int
reset(Hci *hp)
{
	Ctlr *ctlr;
	Ecapio *capio;
	Eopio *opio;
	Uhh *uhh;
	static int beenhere;

	if (beenhere)
		return -1;
	beenhere = 1;

	if(getconf("*nousbehci") != nil || probeaddr(PHYSEHCI) < 0)
		return -1;

	ctlr = smalloc(sizeof(Ctlr));
	/*
	 * don't bother with vmap; i/o space is all mapped anyway,
	 * and a size less than 1MB will blow an assertion in mmukmap.
	 */
	ctlr->capio = capio = (Ecapio *)PHYSEHCI;
	ctlr->opio = opio = (Eopio*)((uintptr)capio + (capio->cap & 0xff));

	hp->aux = ctlr;
	hp->port = (uintptr)ctlr->capio;
	hp->irq = 77;
	hp->nports = capio->parms & Cnports;

	ddprint("echi: %s, ncc %lud npcc %lud\n",
		capio->parms & 0x10000 ? "leds" : "no leds",
		(capio->parms >> 12) & 0xf, (capio->parms >> 8) & 0xf);
	ddprint("ehci: routing %s, %sport power ctl, %d ports\n",
		capio->parms & 0x40 ? "explicit" : "automatic",
		capio->parms & 0x10 ? "" : "no ", hp->nports);

	ehcireset(ctlr);
	ehcimeminit(ctlr);

	/* omap35-specific set up */
	/* bit 5 `must be set to 1 for proper behavior', spruf98d §23.2.6.7.17 */
	opio->insn[4] |= 1<<5;
	coherence();

	/* insn[5] is for both utmi and ulpi, depending on hostconfig mode */
	uhh = (Uhh *)PHYSUHH;
	if (uhh->hostconfig & P1ulpi_bypass) {		/* utmi port 1 active */
		/* not doing this */
		iprint("usbehci: bypassing ulpi on port 1!\n");
		opio->insn[5] &= ~(MASK(4) << 13);
		opio->insn[5] |= 1 << 13;		/* select port 1 */
		coherence();
	} else {					/* ulpi port 1 active */
		/* TODO may need to reset gpio port2 here */

		/* disable integrated stp pull-up resistor */
		wrulpi(opio, 1, Ifcctlreg, Phystppullupoff);

		/* force phy to `high-speed' */
		wrulpi(opio, 1, Funcctlreg, 0x40);
	}

	/*
	 * Linkage to the generic HCI driver.
	 */
	ehcilinkage(hp);
	hp->shutdown = shutdown;
	hp->debug = setdebug;

	intrenable(78, hp->interrupt, hp, UNKNOWN, "usbtll");
	intrenable(92, hp->interrupt, hp, UNKNOWN, "usb otg");
	intrenable(93, hp->interrupt, hp, UNKNOWN, "usb otg dma");
	return 0;
}