Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error in GaussBeamSource.cxx #138

Open
blahoslav opened this issue Feb 17, 2022 · 1 comment
Open

Syntax error in GaussBeamSource.cxx #138

blahoslav opened this issue Feb 17, 2022 · 1 comment

Comments

@blahoslav
Copy link

blahoslav commented Feb 17, 2022

Hello,
I think that I have spotted a syntax error in one of the latest commits in System/source/GaussBeamSource.cxx

There is missing code between GaussBeamSource::writePHITS and GaussBeamSource::writeFLUKA methods leading to the syntax error when building CombLayer.

The code for these methods is now:

void
GaussBeamSource::writePHITS(std::ostream& OX) const
  /*!
    Write out as a PHITS source system
    This is an approximate gaussian sauce b
    base no 100 x / 100 z units  
    - Rotation done by transform
    \param OX :: Output stream
  */
{
  ELog::RegMethod RegA("GaussBeamSource","writePHITS");

  const long int nStep(20);
  
  SourceBase::writePHITS(OX);
  // PHITS are z axis sources

  // Construct a transform to build the source
  
  const double xStep=3.0*xWidth/static_cast<double>(nStep);
  const double zStep=3.0*zWidth/static_cast<double>(nStep);

  const double xSigma = sqrt(8.0*std::log(2.0)) * xWidth;
  const double zSigma = sqrt(8.0*std::log(2.0)) * zWidth;

  // y is implicitly zero  
  for(long int i=-nStep;i<nStep;i++)
    for(long int j=-nStep;j<nStep;j++)
      {
	const double x= static_cast<double>(i)*xStep;
	const double z= static_cast<double>(j)*zStep;
	
GaussBeamSource::writeFLUKA(std::ostream& OX) const
  /*!
    Write out as a FLUKA source system
    \param OX :: Output stream
  */
{
  ELog::RegMethod RegA("GaussBeamSource","writeFLUKA");

  const flukaGenParticle& PC=flukaGenParticle::Instance();
  masterWrite& MW=masterWrite::Instance();
  
  // can be two for an energy range
  if (Energy.size()!=1)
    throw ColErr::SizeError<size_t>
      (Energy.size(),1,"Energy only single point supported");

  std::ostringstream cx;
  // energy : energy divirgence : angle spread [mrad]
  // radius : innerRadius : -1 t o means radius
  cx<<"BEAM "<<-0.001*Energy.front()<<" 0.0 "<<M_PI*angleSpread/0.180
    <<" "<<-xWidth<<" "<<-zWidth<<" -1.0 ";
  cx<<StrFunc::toUpperString(PC.nameToFLUKA(particleType));
  StrFunc::writeFLUKA(cx.str(),OX);
  cx.str("");

  cx<<"BEAMAXES "<<MW.Num(X)<<" "<<MW.Num(Y);
  StrFunc::writeFLUKA(cx.str(),OX);
  cx.str("");
  cx<<"BEAMPOS "<<Origin;
  StrFunc::writeFLUKA(cx.str(),OX);
  cx.str("");

  return;
}

I suggest to modify the methods to :

void
GaussBeamSource::writePHITS(std::ostream& OX) const
  /*!
    Write out as a PHITS source system
    This is an approximate gaussian sauce b
    base no 100 x / 100 z units  
    - Rotation done by transform
    \param OX :: Output stream
  */
{
  ELog::RegMethod RegA("GaussBeamSource","writePHITS");

  const long int nStep(20);
  
  SourceBase::writePHITS(OX);
  // PHITS are z axis sources

  // Construct a transform to build the source
  
  const double xStep=3.0*xWidth/static_cast<double>(nStep);
  const double zStep=3.0*zWidth/static_cast<double>(nStep);

  const double xSigma = sqrt(8.0*std::log(2.0)) * xWidth;
  const double zSigma = sqrt(8.0*std::log(2.0)) * zWidth;

  // y is implicitly zero  
  for(long int i=-nStep;i<nStep;i++)
    for(long int j=-nStep;j<nStep;j++)
      {
	const double x= static_cast<double>(i)*xStep;
	const double z= static_cast<double>(j)*zStep;
      }
  return;
}
void
GaussBeamSource::writeFLUKA(std::ostream& OX) const
  /*!
    Write out as a FLUKA source system
    \param OX :: Output stream
  */
{
  ELog::RegMethod RegA("GaussBeamSource","writeFLUKA");

  const flukaGenParticle& PC=flukaGenParticle::Instance();
  masterWrite& MW=masterWrite::Instance();
  
  // can be two for an energy range
  if (Energy.size()!=1)
    throw ColErr::SizeError<size_t>
      (Energy.size(),1,"Energy only single point supported");

  std::ostringstream cx;
  // energy : energy divirgence : angle spread [mrad]
  // radius : innerRadius : -1 t o means radius
  cx<<"BEAM "<<-0.001*Energy.front()<<" 0.0 "<<M_PI*angleSpread/0.180
    <<" "<<-xWidth<<" "<<-zWidth<<" -1.0 ";
  cx<<StrFunc::toUpperString(PC.nameToFLUKA(particleType));
  StrFunc::writeFLUKA(cx.str(),OX);
  cx.str("");

  cx<<"BEAMAXES "<<MW.Num(X)<<" "<<MW.Num(Y);
  StrFunc::writeFLUKA(cx.str(),OX);
  cx.str("");
  cx<<"BEAMPOS "<<Origin;
  StrFunc::writeFLUKA(cx.str(),OX);
  cx.str("");
  return;
}

Thank you very much for your help.

@SAnsell
Copy link
Owner

SAnsell commented Feb 18, 2022

Very sorry -- that was my fault . I have fixed this -- it got deleted by mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants