Commit 78e2043f authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Merge branch '640-update-time-unit-in-loss-output-file-of-some-elements' into 'master'

Resolve "Update time unit in loss output file of some elements"

Closes #640

See merge request !479
parents 663f1fa9 9805ed89
......@@ -205,7 +205,7 @@ void ParallelCyclotronTracker::bgf_main_collision_test() {
if(res >= 0) {
lossDs_m->addParticle(OpalParticle(itsBunch_m->ID[i],
itsBunch_m->R[i], itsBunch_m->P[i],
itsBunch_m->getT()*1e9,
itsBunch_m->getT(),
itsBunch_m->Q[i], itsBunch_m->M[i]),
std::make_pair(turnnumber_m, itsBunch_m->bunchNum[i]));
itsBunch_m->Bin[i] = -1;
......@@ -2079,7 +2079,7 @@ bool ParallelCyclotronTracker::applyPluginElements(const double dt) {
for (PluginElement* element : pluginElements_m) {
bool tmp = element->check(itsBunch_m,
turnnumber_m,
itsBunch_m->getT() * 1e9 /*[ns]*/,
itsBunch_m->getT(),
dt);
flag |= tmp;
......@@ -3526,4 +3526,4 @@ void ParallelCyclotronTracker::initPathLength() {
// we need to reset the path length of each bunch
itsDataSink->setMultiBunchInitialPathLengh(mbHandler_m.get());
}
}
\ No newline at end of file
}
......@@ -66,7 +66,7 @@ bool CCollimator::doPreCheck(PartBunchBase<double, 3> *bunch) {
double rbunch_min = std::hypot(xmin, ymin);
double rbunch_max = std::hypot(xmax, ymax);
if( rbunch_max > rmin_m && rbunch_min < rmax_m ){ // check similar to z
if ( rbunch_max > rmin_m && rbunch_min < rmax_m ){ // check similar to z
return true;
}
}
......@@ -75,7 +75,7 @@ bool CCollimator::doPreCheck(PartBunchBase<double, 3> *bunch) {
// rectangle collimators in cyclotron cylindrical coordinates
// when there is no particlematterinteraction, the particle hitting collimator is deleted directly
bool CCollimator::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, const double /*t*/, const double /*tstep*/) {
bool CCollimator::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, const double t, const double /*tstep*/) {
bool flagNeedUpdate = false;
size_t tempnum = bunch->getLocalNum();
......@@ -90,7 +90,7 @@ bool CCollimator::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber,
if (!parmatint_m)
lossDs_m->addParticle(OpalParticle(bunch->ID[i],
bunch->R[i], bunch->P[i],
bunch->getT(), bunch->Q[i], bunch->M[i]),
t, bunch->Q[i], bunch->M[i]),
std::make_pair(turnnumber, bunch->bunchNum[i]));
bunch->Bin[i] = -1;
flagNeedUpdate = true;
......
......@@ -56,6 +56,7 @@ Cyclotron::Cyclotron():
Cyclotron::Cyclotron(const Cyclotron& right):
Component(right),
fieldType_m(right.fieldType_m),
fmapfn_m(right.fmapfn_m),
rffrequ_m(right.rffrequ_m),
rfphi_m(right.rfphi_m),
......@@ -403,7 +404,7 @@ bool Cyclotron::apply(const size_t& id, const double& t, Vector_t& E, Vector_t&
if (flagNeedUpdate) {
lossDs_m->addParticle(OpalParticle(id, RefPartBunch_m->R[id], RefPartBunch_m->P[id],
t, RefPartBunch_m->Q[id], RefPartBunch_m->M[id]),
t*1.0e-9, RefPartBunch_m->Q[id], RefPartBunch_m->M[id]),
std::make_pair(0, RefPartBunch_m->bunchNum[id]));
RefPartBunch_m->Bin[id] = -1;
}
......@@ -671,7 +672,7 @@ double Cyclotron::gutdf5d(double* f, double dx, const int kor,
result += C[j][krl][kor] * *(f + j * lpr);
}
return result / (FAC[kor] * pow(dx, (kor + 1)));
return result / (FAC[kor] * std::pow(dx, (kor + 1)));
}
......@@ -782,7 +783,7 @@ void Cyclotron::read(const double& scaleFactor) {
break;
}
case BFieldType::AVFEQBF: {
*gmsg << "* Read AVFEQ data (Riken)" << endl;
*gmsg << "* Read AVFEQ data (Riken)" << endl;
getFieldFromFile_AVFEQ(scaleFactor);
break;
}
......@@ -802,7 +803,7 @@ void Cyclotron::read(const double& scaleFactor) {
break;
}
}
// calculate the radii of initial grid.
initR(BP.rmin, BP.delr, Bfield.nrad);
......@@ -1538,4 +1539,4 @@ void Cyclotron::getFieldFromFile_Synchrocyclotron(const double& scaleFactor) {
void Cyclotron::getDimensions(double& /*zBegin*/, double& /*zEnd*/) const
{ }
#undef CHECK_CYC_FSCANF_EOF
\ No newline at end of file
#undef CHECK_CYC_FSCANF_EOF
......@@ -20,8 +20,10 @@
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunchBase.h"
#include "Physics/Physics.h"
#include "Structure/LossDataSink.h"
#include "Utilities/Options.h"
#include "Utilities/Util.h"
PluginElement::PluginElement():PluginElement("")
......@@ -243,4 +245,4 @@ void PluginElement::save() {
}
lossDs_m->save(1, openMode);
numPassages_m++;
}
\ No newline at end of file
}
......@@ -101,15 +101,15 @@ bool Probe::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, const
// dist1 > 0, right hand, dt > 0; dist1 < 0, left hand, dt < 0
double dist1 = (A_m * bunch->R[i](0) + B_m * bunch->R[i](1) + C_m) / R_m; // [m]
double dist2 = dist1 * std::sqrt(1.0 + 1.0 / tangle / tangle);
double dt = dist2 / (std::sqrt(1.0 - 1.0 / (1.0 + dot(bunch->P[i], bunch->P[i]))) * Physics::c) * 1.0e9;
double dt = dist2 / (std::sqrt(1.0 - 1.0 / (1.0 + dot(bunch->P[i], bunch->P[i]))) * Physics::c);
probepoint = bunch->R[i] + dist2 * bunch->P[i] / euclidean_norm(bunch->P[i]);
// peak finder uses millimetre not metre
peakfinder_m->addParticle(probepoint * 1e3);
lossDs_m->addParticle(OpalParticle(bunch->ID[i], probepoint, bunch->P[i], t+dt,
bunch->Q[i], bunch->M[i]),
lossDs_m->addParticle(OpalParticle(bunch->ID[i], probepoint, bunch->P[i],
t+dt, bunch->Q[i], bunch->M[i]),
std::make_pair(turnnumber, bunch->bunchNum[i]));
}
......@@ -121,4 +121,4 @@ bool Probe::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, const
ElementBase::ElementType Probe::getType() const {
return PROBE;
}
\ No newline at end of file
}
......@@ -78,7 +78,7 @@ bool Septum::doPreCheck(PartBunchBase<double, 3> *bunch) {
return false;
}
bool Septum::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, const double /*t*/, const double /*tstep*/) {
bool Septum::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, const double t, const double /*tstep*/) {
bool flag = false;
const double slope = (yend_m - ystart_m) / (xend_m - xstart_m);
......@@ -102,8 +102,7 @@ bool Septum::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, cons
lossDs_m->addParticle(OpalParticle(bunch->ID[i],
R, bunch->P[i],
bunch->getT(),
bunch->Q[i], bunch->M[i]),
t, bunch->Q[i], bunch->M[i]),
std::make_pair(turnnumber, bunch->bunchNum[i]));
bunch->Bin[i] = -1;
flag = true;
......
......@@ -127,14 +127,13 @@ bool Stripper::doCheck(PartBunchBase<double, 3> *bunch, const int turnnumber, co
// dist1 > 0, right hand, dt > 0; dist1 < 0, left hand, dt < 0
double dist1 = (A_m * bunch->R[i](0) + B_m * bunch->R[i](1) + C_m) / R_m; // [m]
double dist2 = dist1 * std::sqrt(1.0 + 1.0 / tangle / tangle);
double dt = dist2 / (std::sqrt(1.0 - 1.0 / (1.0 + dot(bunch->P[i], bunch->P[i]))) * Physics::c) * 1.0e9; // [ns]
double dt = dist2 / (std::sqrt(1.0 - 1.0 / (1.0 + dot(bunch->P[i], bunch->P[i]))) * Physics::c);
strippoint(0) = (B_m * B_m * bunch->R[i](0) - A_m * B_m* bunch->R[i](1) - A_m * C_m) / (R_m * R_m);
strippoint(1) = (A_m * A_m * bunch->R[i](1) - A_m * B_m* bunch->R[i](0) - B_m * C_m) / (R_m * R_m);
strippoint(2) = bunch->R[i](2);
lossDs_m->addParticle(OpalParticle(bunch->ID[i],
strippoint, bunch->P[i],
t+dt,
bunch->Q[i], bunch->M[i]),
t+dt, bunch->Q[i], bunch->M[i]),
std::make_pair(turnnumber, bunch->bunchNum[i]));
flagNeedUpdate = true;
......
......@@ -104,22 +104,22 @@ BeamStrippingPhysics::~BeamStrippingPhysics() {
void BeamStrippingPhysics::apply(PartBunchBase<double, 3>* bunch,
const std::pair<Vector_t, double>& /*boundingSphere*/) {
dT_m = bunch->getdT();
ParticleType pType = bunch->getPType();
if (pType == ParticleType::PROTON ||
pType == ParticleType::HMINUS ||
pType == ParticleType::H2P ||
pType == ParticleType::HYDROGEN ) {
if (pType != ParticleType::PROTON &&
pType != ParticleType::HMINUS &&
pType != ParticleType::H2P &&
pType != ParticleType::HYDROGEN) {
if (bunch->get_sPos() != 0) {
doPhysics(bunch);
}
} else {
throw GeneralClassicException(
"BeamStrippingPhysics::apply",
"Particle " + bunch->getPTypeString() +
" is not supported for residual stripping interactions!");
"BeamStrippingPhysics::apply",
"Particle " + bunch->getPTypeString() +
" is not supported for residual stripping interactions!");
}
dT_m = bunch->getdT();
if (bunch->get_sPos() != 0) {
doPhysics(bunch);
}
}
......@@ -167,8 +167,9 @@ void BeamStrippingPhysics::doPhysics(PartBunchBase<double, 3>* bunch) {
}
if (pdead_GS == true || pdead_LS == true) {
lossDs_m->addParticle(OpalParticle(bunch->ID[i], bunch->R[i], bunch->P[i],
bunch->getT() * 1e9,
lossDs_m->addParticle(OpalParticle(bunch->ID[i],
bunch->R[i], bunch->P[i],
bunch->getT(),
bunch->Q[i], bunch->M[i]));
if (stop) {
bunch->Bin[i] = -1;
......@@ -691,4 +692,4 @@ const double BeamStrippingPhysics::csCoefHydrogenProduction_H2plus_Chebyshev[11]
2.00E+03, 1.00E+05, -70.670173645, -0.632612288, -0.6065212488, -0.0915143117, -0.0121710282, 0.0168179292, 0.0104796877, 0, 0
};
double BeamStrippingPhysics::a_m[9] = {};
double BeamStrippingPhysics::b_m[3][9] = {};
\ No newline at end of file
double BeamStrippingPhysics::b_m[3][9] = {};
......@@ -152,7 +152,7 @@ ScatteringPhysics::ScatteringPhysics(const std::string& name,
hitTester_m.reset(new FlexCollimatorInsideTester(element_ref_m));
break;
default:
throw OpalException("ScatteringPhysics::ScatteringPhysics",
throw GeneralClassicException("ScatteringPhysics::ScatteringPhysics",
"Unsupported element type");
}
......@@ -723,4 +723,4 @@ void ScatteringPhysics::gatherStatistics() {
bunchToMatStat_m = partStatistics[1];
rediffusedStat_m = partStatistics[2];
stoppedPartStat_m = partStatistics[3];
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment