Commit 56e68b89 authored by kraus's avatar kraus
Browse files

fixes #262

parent 9c617167
#include "Solvers/CSRIGFWakeFunction.hh"
#include "Algorithms/PartBunchBase.h"
#include "Filters/Filter.h"
#include "Filters/SavitzkyGolay.h"
#include "Physics/Physics.h"
#include "AbsBeamline/RBend.h"
#include "AbsBeamline/SBend.h"
......@@ -19,7 +20,14 @@ CSRIGFWakeFunction::CSRIGFWakeFunction(const std::string &name, ElementBase *ele
dlineDensitydz_m(),
bendRadius_m(0.0),
totalBendAngle_m(0.0)
{ }
{
if (filters_m.size() == 0) {
defaultFilter_m.reset(new SavitzkyGolayFilter(7, 3, 3, 3));
filters_m.push_back(defaultFilter_m.get());
}
diffOp_m = filters_m.back();
}
void CSRIGFWakeFunction::apply(PartBunchBase<double, 3> *bunch) {
Inform msg("CSRWake ");
......@@ -132,7 +140,7 @@ void CSRIGFWakeFunction::calculateLineDensity(PartBunchBase<double, 3> *bunch, s
(*fit)->apply(lineDensity_m);
}
dlineDensitydz_m.assign(lineDensity_m.begin(), lineDensity_m.end());
diffOp_m.calc_derivative(dlineDensitydz_m, meshInfo.second);
diffOp_m->calc_derivative(dlineDensitydz_m, meshInfo.second);
}
void CSRIGFWakeFunction::calculateGreenFunction(PartBunchBase<double, 3> *bunch, double meshSpacing)
......
......@@ -3,11 +3,11 @@
#include "Solvers/WakeFunction.hh"
#include "Filters/Stencil.h"
#include <memory>
#include <vector>
#include <string>
class Filter;
class ElementBase;
class CSRIGFWakeFunction: public WakeFunction {
......@@ -29,7 +29,9 @@ private:
double calcPsi(const double &psiInitial, const double &x, const double &Ds) const;
std::vector<Filter *> filters_m;
StencilFilter diffOp_m;
std::shared_ptr<Filter> defaultFilter_m;
Filter *diffOp_m;
LineDensity lineDensity_m;
LineDensity dlineDensitydz_m;
......
#include "Solvers/CSRWakeFunction.hh"
#include "Algorithms/PartBunchBase.h"
#include "Filters/Filter.h"
#include "Filters/SavitzkyGolay.h"
#include "Physics/Physics.h"
#include "AbsBeamline/RBend.h"
#include "AbsBeamline/SBend.h"
......@@ -19,7 +20,14 @@ CSRWakeFunction::CSRWakeFunction(const std::string &name, ElementBase *element,
dlineDensitydz_m(),
bendRadius_m(0.0),
totalBendAngle_m(0.0)
{ }
{
if (filters_m.size() == 0) {
defaultFilter_m.reset(new SavitzkyGolayFilter(7, 3, 3, 3));
filters_m.push_back(defaultFilter_m.get());
}
diffOp_m = filters_m.back();
}
void CSRWakeFunction::apply(PartBunchBase<double, 3> *bunch) {
Inform msg("CSRWake ");
......@@ -125,7 +133,7 @@ void CSRWakeFunction::calculateLineDensity(PartBunchBase<double, 3> *bunch, std:
}
dlineDensitydz_m.assign(lineDensity_m.begin(), lineDensity_m.end());
diffOp_m.calc_derivative(dlineDensitydz_m, meshInfo.second);
diffOp_m->calc_derivative(dlineDensitydz_m, meshInfo.second);
}
void CSRWakeFunction::calculateContributionInside(size_t sliceNumber, double angleOfSlice, double meshSpacing) {
......
......@@ -3,11 +3,11 @@
#include "Solvers/WakeFunction.hh"
#include "Filters/Stencil.h"
#include <memory>
#include <vector>
#include <string>
class Filter;
class ElementBase;
class CSRWakeFunction: public WakeFunction {
......@@ -28,7 +28,8 @@ private:
double calcPsi(const double &psiInitial, const double &x, const double &Ds) const;
std::vector<Filter *> filters_m;
StencilFilter diffOp_m;
std::shared_ptr<Filter> defaultFilter_m;
Filter *diffOp_m;
LineDensity lineDensity_m;
LineDensity dlineDensitydz_m;
......
......@@ -176,6 +176,11 @@ void OpalWake::initWakefunction(ElementBase &element) {
if (Util::toUpper(Attributes::getString(itsAttr[TYPE])) == "1D-CSR") {
if (filters.size() == 0 && Attributes::getReal(itsAttr[NBIN]) <= 7) {
throw OpalException("OpalWake::initWakeFunction",
"At least 8 bins have to be used, ideally far more");
}
wf_m = new CSRWakeFunction(getOpalName(),
itsElement_m,
filters,
......@@ -183,6 +188,11 @@ void OpalWake::initWakefunction(ElementBase &element) {
} else if (Util::toUpper(Attributes::getString(itsAttr[TYPE])) == "1D-CSR-IGF") {
if (filters.size() == 0 && Attributes::getReal(itsAttr[NBIN]) <= 7) {
throw OpalException("OpalWake::initWakeFunction",
"At least 8 bins have to be used, ideally far more");
}
wf_m = new CSRIGFWakeFunction(getOpalName(),
itsElement_m,
filters,
......
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