Exemple #1
0
double CS_Total_CP(const char compound[], double E) {
	struct compoundData *cd;
	struct compoundDataNIST *cdn;
	int i;
	double rv = 0.0;

	if ((cd = CompoundParser(compound)) == NULL) {
		ErrorExit("CS_Total_CP: CompoundParser failed. Trying NIST compound database.");
		if ((cdn = GetCompoundDataNISTByName(compound)) == NULL) {
			ErrorExit("CS_Total_CP: Compound not found in NIST compound database.");
			return rv;
		}
		else {
			for (i = 0 ; i < cdn->nElements ; i++) 
				rv += CS_Total(cdn->Elements[i], E)*cdn->massFractions[i];

			FreeCompoundDataNIST(cdn);
		}
	} 
	else {
		for (i = 0 ; i < cd->nElements ; i++) 
			rv += CS_Total(cd->Elements[i], E)*cd->massFractions[i];

		FreeCompoundData(cd);
	}

	return rv;
}
Exemple #2
0
int getXRayCS (int mode, double massThickness)
{
  int     i, Z=0;
  float   energy_keV;
  double  cosThetaIn;
  
  if (verbose > 3) { fprintf(stdout, "getXRayCS: targetFormula = %s\n", targetFormula); }
  if (mode > 9 )  { Z = SymbolToAtomicNumber ( targetFormula ); }
  if (verbose > 2) { 
    fprintf(stdout, "\n Index  PhotonEnergy   TotalCS    PhotoCS    coherentCS  incohrentCS");
    if ( mode==2 || mode==12 ) { fprintf(stdout, "    Transmission  Absorption "); 
    } else if ( mode==4 || mode==14 ) { fprintf(stdout, "  Transmission  Absorption  FrontTEY(QE)  BackTEY(QE)  TEY(QE) "); 
    }
    fprintf(stdout, "\n            (eV)       (cm2/g)    (cm2/g)      (cm2/g)     (cm2/g)  ");
  }

  cosThetaIn  = cos(thetaIn  * degToRad);
  for ( i = 0; i < npts; i++ ) {
    energy_keV  = 0.001 * energy[i];
    if ( mode < 10 ) {
      total[i]    = CS_Total_CP ( targetFormula, energy_keV );
      photo[i]    = CS_Photo_CP ( targetFormula, energy_keV );
      rayleigh[i] = CS_Rayl_CP  ( targetFormula, energy_keV );
      compton[i]  = CS_Compt_CP ( targetFormula, energy_keV );
    } else {
      total[i]    = CS_Total ( Z, energy_keV );
      photo[i]    = CS_Photo ( Z, energy_keV );
      rayleigh[i] = CS_Rayl  ( Z, energy_keV );
      compton[i]  = CS_Compt ( Z, energy_keV );
    }
    if (verbose>2) { fprintf(stdout, "\n %4d %10.1f %12.4g %10.4g %12.4g %12.4g", i, energy[i], total[i], photo[i], rayleigh[i], compton[i]); }
    
    if ( mode==2 || mode==4 || mode==12 || mode==14 ) {
      transmission [i] = exp(-1.0 * massThickness * total[i] / cosThetaIn ); 
      absorption[i]    = 1.0 - transmission[i];
      if (verbose>2) { fprintf(stdout, " %12.4f %12.4g", transmission[i], absorption[i]); }
      if ( mode==4 || mode==14 ) {
        eYieldFront[i]   = teyEfficiency * energy[i] * total[i] / cosThetaIn ; 	/* Front surface total electron yield */
        eYieldBack[i]    = teyEfficiency * energy[i] * total[i] / cosThetaIn * transmission [i]; /* Back surface total electron yield */
        electronYield[i] = eYieldFront[i]  + eYieldBack[i];
        if (verbose>2) { fprintf(stdout, "%12.4g %12.4g %12.4g", eYieldFront[i], eYieldBack[i], electronYield[i] ); }
      }
    }
  }
  if (verbose)
  fprintf(stdout, "\n");
  return 0;
}
Exemple #3
0
float CS_Total_CP(const char compound[], float E) {
	struct compoundData *cd;
	int i;
	double rv = 0.0;

	if ((cd = CompoundParser(compound)) == NULL) {
		ErrorExit("CS_Total_CP: CompoundParser error");
		return 0.0;
	} 
	
	for (i = 0 ; i < cd->nElements ; i++) 
		rv += CS_Total(cd->Elements[i], E)*cd->massFractions[i];

	FreeCompoundData(cd);

	return rv;
}
Exemple #4
0
int main(int argc, char **argv) {
	xrl_error *error = NULL;
	double cs_photo, cs_compt, cs_rayl, cs_total, cs_energy;
	double (* const cs[])(int, double, xrl_error **) = {CS_Photo, CS_Compt, CS_Rayl, CS_Total, CS_Energy};
	int i;

	/* CS_Photo */
	cs_photo = CS_Photo(10, 10.0, &error);
	assert(error == NULL);
	assert(fabs(cs_photo - 11.451033638148562) < 1E-4);

	/* CS_Compt */
	cs_compt = CS_Compt(10, 10.0, &error);
	assert(error == NULL);
	assert(fabs(cs_compt - 0.11785269096475783) < 1E-4);

	/* CS_Rayl */
	cs_rayl = CS_Rayl(10, 10.0, &error);
	assert(error == NULL);
	assert(fabs(cs_rayl - 0.39841164641058013) < 1E-4);

	/* CS_Total */
	cs_total = CS_Total(10, 10.0, &error);
	assert(error == NULL);
	/* internal consistency check */
	assert(fabs(cs_total - cs_photo - cs_compt - cs_rayl) < 1E-3);

	/* CS_Energy */
	cs_energy = CS_Energy(10, 10.0, &error);
	assert(error == NULL);
	assert(fabs(cs_energy - 11.420221747941419) < 1E-4);

	/* bad input */
	for (i = 0 ; i < sizeof(cs)/sizeof(cs[0]) ; i++) {
		double v;

		/* bad Z */
		v = cs[i](-1, 10.0, &error);
		assert(error != NULL);
		assert(error->code == XRL_ERROR_INVALID_ARGUMENT);
		assert(strcmp(error->message, Z_OUT_OF_RANGE) == 0);
		assert(v == 0.0);
		xrl_clear_error(&error);

		v = cs[i](ZMAX, 10.0, &error);
		assert(error != NULL);
		assert(error->code == XRL_ERROR_INVALID_ARGUMENT);
		assert(strcmp(error->message, Z_OUT_OF_RANGE) == 0);
		assert(v == 0.0);
		xrl_clear_error(&error);

		/* bad energy */
		v = cs[i](26, 0.0, &error);
		assert(error != NULL);
		assert(error->code == XRL_ERROR_INVALID_ARGUMENT);
		assert(strcmp(error->message, NEGATIVE_ENERGY) == 0);
		assert(v == 0.0);
		xrl_clear_error(&error);

		v = cs[i](26, -1.0, &error);
		assert(error != NULL);
		assert(error->code == XRL_ERROR_INVALID_ARGUMENT);
		assert(strcmp(error->message, NEGATIVE_ENERGY) == 0);
		assert(v == 0.0);
		xrl_clear_error(&error);
	}
		

	return 0;	
}
Exemple #5
0
int main()
{
  double th1_deg = 45;
  int th2_deg;
  double E=50, E1, Erc, Ecc;
  double RhoAl=2.7;
  double SAl = 0.01;
  double PAbsR, PAbsC, PAbsRC, PAbsCC;
  double d1=20, r1=0.2, d2=10, r2=0.1, Omega1, A1, Omega2, A2;

  double th1, th2;
  double PR, PC, P1;
  double PRRa, PRCa, PCRa, PCCa;

  XRayInit();

  th1 = th1_deg*PI/180;


  A1 = PI*r1*r1;
  Omega1 = A1/d1/d1;

  PAbsR = exp(-1.19*2.*(0.0805*CS_Total(1,E) + 0.5999*CS_Total(6,E) +
			  0.3196*CS_Total(8,E)));
  E1 = ComptonEnergy(E, th1);
  PAbsC = exp(-1.19*2.*(0.0805*CS_Total(1,E1) + 0.5999*CS_Total(6,E1) +
			  0.3196*CS_Total(8,E1)));

  PR = RhoAl*SAl*DCSP_Rayl(13, E, th1, PI/2)*Omega1*PAbsR;
  PC = RhoAl*SAl*DCSP_Compt(13, E, th1, PI/2)*Omega1*PAbsC;

  A2 = PI*r2*r2;
  Omega2 = A2/d2/d2;

  for (th2_deg=-90; th2_deg<=90; th2_deg+=1) { 
    if(th2_deg==0) th2=1e-5;
    else th2 = fabs(PI/180*th2_deg);
    Erc = ComptonEnergy(E, th2);
    PAbsRC = exp(-1.19*2.*(0.0805*CS_Total(1,Erc) + 0.5999*CS_Total(6,Erc) +
			   0.3196*CS_Total(8,Erc)));
    Ecc = ComptonEnergy(E1, th2);
    PAbsCC = exp(-1.19*2.*(0.0805*CS_Total(1,Ecc) + 0.5999*CS_Total(6,Ecc) +
			   0.3196*CS_Total(8,Ecc)));
    PRRa = PR*RhoAl*SAl*DCSP_Rayl(13, E, th2, PI/2)*Omega2*PAbsR;
    PRCa = PR*RhoAl*SAl*DCSP_Compt(13, E, th2, PI/2)*Omega2*PAbsRC;
    PCRa = PC*RhoAl*SAl*DCSP_Rayl(13, E1, th2, PI/2)*Omega2*PAbsC;
    PCCa = PC*RhoAl*SAl*DCSP_Compt(13, E1, th2, PI/2)*Omega2*PAbsCC;
    
    P1 = 1e10*(PRRa+PRCa+PCRa+PCCa);
    printf("%d\t%g\n", th2_deg, P1);
  }

  return 0;
}
Exemple #6
0
int getAtomicXRayCS_Kissel (int shellID)
{
  int   i, Z;
  float energy_keV;
  
  Z = SymbolToAtomicNumber ( targetFormula );
  edgeEnergy = 0.0;
  fluorYield = 1.0;
  jumpFactor = 1.0;
  levelWidth = 0.0;
  electronConfig  = Z;

  if (verbose > 3) { 
    fprintf(stdout, "getAtomicXRayCS: Z = %d\n", Z);
    fprintf(stdout, "getAtomicXRayCS_Kissel: shellID = %d\n", shellID);
    if (verbose>2) { fprintf(stdout, "Index  PhotonEnergy   TotalCS      PhotoCS     coherentCS   incohrentCS \n"); }
  }

  if (shellID <= 30 && shellID >= 0) {
    edgeEnergy = 1000.0 * EdgeEnergy(Z, shellID);
    fluorYield = FluorYield(Z, shellID);
    jumpFactor = JumpFactor(Z, shellID);
    electronConfig  = ElectronConfig(Z, shellID);
    levelWidth = AtomicLevelWidth(Z, shellID);
    for ( i = 0; i < npts; i++ ) {
      energy_keV  = 0.001 * energy[i];
      if ( energy[i] > edgeEnergy ) {
        photo[i]  = CS_Photo_Partial (Z, shellID, energy_keV);
      } else {
        photo[i]  = 0.0;
      }
      total[i]    = 0.0;
      rayleigh[i] = 0.0;
      compton[i]  = 0.0;
      if (verbose>2) { fprintf(stdout, "%4d %12.1f %12.4g %12.4g %12.4g %12.4g \n", i, energy[i], total[i], photo[i], rayleigh[i], compton[i]); }
    }
  } else if (shellID > 99) {
    for ( i = 0; i < npts; i++ ) {
      energy_keV  = 0.001 * energy[i];
      total[i]    = CS_Total_Kissel ( Z, energy_keV );
      photo[i]    = CS_Photo_Total  ( Z, energy_keV );
      rayleigh[i] = CS_Rayl  ( Z, energy_keV );
      compton[i]  = CS_Compt ( Z, energy_keV );
      if (verbose>2) { fprintf(stdout, "%4d %12.1f %12.4g %12.4g %12.4g %12.4g \n", i, energy[i], total[i], photo[i], rayleigh[i], compton[i]); }
    }
  } else {
    for ( i = 0; i < npts; i++ ) {
      energy_keV  = 0.001 * energy[i];
      photo[i]    = CS_Photo ( Z, energy_keV );
      total[i]    = CS_Total ( Z, energy_keV );
      rayleigh[i] = CS_Rayl  ( Z, energy_keV );
      compton[i]  = CS_Compt ( Z, energy_keV );
      if (verbose>2) { fprintf(stdout, "%4d %12.1f %12.4g %12.4g %12.4g %12.4g \n", i, energy[i], total[i], photo[i], rayleigh[i], compton[i]); }
    }
  }

  if (verbose > 1) { 
    fprintf(stdout, "edgeEnergy = %f, fluorYield = %f,  jumpFactor = %f,", edgeEnergy, fluorYield, jumpFactor);
    fprintf(stdout, " electronConfig = %f, levelWidth = %f \n", electronConfig, levelWidth);
  }
  return 0;
}