Exemple #1
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 #2
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 #3
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;
}