ElectricField extended by RearwallPotential
This commit is contained in:
@@ -1,6 +1,31 @@
|
||||
#include "ElectricField.h"
|
||||
#include <iostream> //cout
|
||||
|
||||
|
||||
ElectricField::ElectricField(int i){
|
||||
if (i==1)
|
||||
{
|
||||
|
||||
double radius = r_WGTS_m;
|
||||
double height = z_WGTS_end_m;
|
||||
double rearwall_potential = 10.0;
|
||||
vec3 center(0.0, 0.0, 0.0);
|
||||
double minimal_z_for_bessel_calculation = 0.001;
|
||||
int max_bessel_zero_order_ = 1000;
|
||||
double precision = 1e-15;
|
||||
bool potential_in_si = true;
|
||||
|
||||
f = new RearwallPotential(radius, height, rearwall_potential, center, minimal_z_for_bessel_calculation, max_bessel_zero_order_, precision, potential_in_si);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ElectricField();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
vec3 ElectricField::getValue(){
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
@@ -9,18 +34,11 @@ vec3 ElectricField::getValue(const vec3 &loc_m){
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
|
||||
vec3 ElectricField::getValue(const double &z, const double &r, const double &phi){
|
||||
return vec3(0,0,0);
|
||||
vec3 ElectricField::getValue(double z, double r, double phi){
|
||||
return f->getValue(z, r, phi);
|
||||
//return vec3(0,0,0);
|
||||
}
|
||||
|
||||
vec3 ElectricField::getLoc(){
|
||||
return vec3(0,0,0);
|
||||
void ElectricField::print() const {
|
||||
f->print();
|
||||
}
|
||||
|
||||
vec3 ElectricField::getLoc(const vec3 &loc_m){
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
|
||||
vec3 ElectricField::getLoc(const double &z, const double &r, const double &phi){
|
||||
return vec3(0,0,0);
|
||||
}
|
||||
@@ -2,15 +2,18 @@
|
||||
#define ELECTRICFIELD_H
|
||||
|
||||
#include "kinematics.h"
|
||||
#include "Function3d.h"
|
||||
#include "RearwallPotential.h"
|
||||
|
||||
class ElectricField{
|
||||
public:
|
||||
ElectricField(int i);
|
||||
ElectricField(){};
|
||||
virtual vec3 getValue();
|
||||
virtual vec3 getValue(const vec3 &loc_m);
|
||||
virtual vec3 getValue(const double &z, const double &r, const double &phi);
|
||||
virtual vec3 getLoc();
|
||||
virtual vec3 getLoc(const vec3 &loc_m);
|
||||
virtual vec3 getLoc(const double &z, const double &r, const double &phi);
|
||||
virtual vec3 getValue(double z, double r, double phi);
|
||||
virtual void print() const;
|
||||
private:
|
||||
Function3d *f;
|
||||
};
|
||||
#endif /* ELECTRICFIELD_H */
|
||||
|
||||
@@ -13,6 +13,11 @@ std::ostream & operator << (std::ostream &out, const Function3d& function) {
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
void Function3d::print(std::ostream &out) const{
|
||||
out << "Function3d Base:\n";
|
||||
}
|
||||
|
||||
void Function3d::print() const{
|
||||
std::cout << "Function3d Base:\n";
|
||||
}
|
||||
@@ -12,13 +12,14 @@ class Function3d {
|
||||
virtual ~Function3d() {};
|
||||
|
||||
virtual double getValue(double x, double y, double z, int cart_axis) const = 0;
|
||||
virtual blitz::TinyVector<double ,3> getValue(double x, double y, double z) const = 0;
|
||||
virtual blitz::TinyVector<double ,3> getValue(double z, double r, double phi) const = 0;
|
||||
|
||||
double getValue(const blitz::TinyVector<double, 3>& x, int cart_axis) const;
|
||||
blitz::TinyVector<double, 3> getValue(const blitz::TinyVector<double, 3>& x) const;
|
||||
|
||||
friend std::ostream & operator << (std::ostream &out, const Function3d& function);
|
||||
virtual void print(std::ostream &out) const;
|
||||
virtual void print() const;
|
||||
};
|
||||
|
||||
#endif /* FUNCTION3D_H */
|
||||
|
||||
@@ -36,6 +36,7 @@ RearwallPotential::RearwallPotential(double radius, double height,
|
||||
|
||||
RearwallPotential::~RearwallPotential() {};
|
||||
|
||||
|
||||
void RearwallPotential::print(std::ostream &out) const {
|
||||
out << "Function3d: RearwallPotential\n";
|
||||
out << "radius: " << radius_ << "\n";
|
||||
@@ -46,6 +47,15 @@ void RearwallPotential::print(std::ostream &out) const {
|
||||
out << "potential (cgs): " << rearwall_potential_ << "\n";
|
||||
}
|
||||
|
||||
void RearwallPotential::print() const{
|
||||
std::cout << "Function3d: RearwallPotential\n";
|
||||
std::cout << "radius: " << radius_ << "\n";
|
||||
std::cout << "height: " << height_ << "\n";
|
||||
std::cout << "minimal z for bessel calculation: " << minimal_z_for_bessel_calculation_ << "\n";
|
||||
std::cout << "maximal z for bessel calculation: " << maximal_z_for_bessel_calculation_ << "\n";
|
||||
std::cout << "center: " << center_ << "\n";
|
||||
std::cout << "potential (cgs): " << rearwall_potential_ << "\n";
|
||||
}
|
||||
|
||||
double RearwallPotential::getValue(double x, double y, double z,
|
||||
int cart_axis) const {
|
||||
@@ -88,7 +98,7 @@ blitz::TinyVector<double, 3> RearwallPotential::getValue(double z, double r,
|
||||
// convert to local coordinates
|
||||
//x += -center_(0);
|
||||
//y += -center_(1);
|
||||
//z += -center_(2);
|
||||
z += -center_(2);
|
||||
/*
|
||||
// get cylinder coordinates
|
||||
gsl_sf_result r = {0.0, 0.0};
|
||||
@@ -101,7 +111,7 @@ blitz::TinyVector<double, 3> RearwallPotential::getValue(double z, double r,
|
||||
gsl_sf_rect_to_polar(x, y, &r, &phi);
|
||||
}
|
||||
*/
|
||||
//std::cout << "ich wurde aufgerufen" << std::endl;
|
||||
//std::cout << "ich wurde aufgerufen " << height_ << std::endl;
|
||||
|
||||
return blitz::TinyVector<double, 3>(
|
||||
getRadialElectricField(r, z) * gsl_sf_cos(phi),
|
||||
@@ -109,34 +119,6 @@ blitz::TinyVector<double, 3> RearwallPotential::getValue(double z, double r,
|
||||
getLongitudinalElectricField(r, z));
|
||||
}
|
||||
|
||||
vec3 RearwallPotential::getValue(const double &z, const double &r, const double &phi){
|
||||
// convert to local coordinates
|
||||
//x += -center_(0);
|
||||
//y += -center_(1);
|
||||
//z += -center_(2);
|
||||
//double z_loc = z-center_(2);
|
||||
double z_loc = z-center_(2);
|
||||
/*
|
||||
// get cylinder coordinates
|
||||
gsl_sf_result r = {0.0, 0.0};
|
||||
gsl_sf_result phi = {0.0, 0.0};
|
||||
|
||||
if(x == 0.0 && y == 0.0){ // guard for gsl error: 0,0 not defined
|
||||
r.val = 0.0;
|
||||
phi.val = 0.0;
|
||||
} else {
|
||||
gsl_sf_rect_to_polar(x, y, &r, &phi);
|
||||
}
|
||||
*/
|
||||
//std::cout << "ich wurde aufgerufen" << std::endl;
|
||||
//std::cout << getRadialElectricField(r, z_loc) << std::endl;
|
||||
|
||||
efeld_value = vec3(getRadialElectricField(r, z_loc) * gsl_sf_cos(phi),
|
||||
getRadialElectricField(r, z_loc) * gsl_sf_sin(phi),
|
||||
getLongitudinalElectricField(r, z_loc));
|
||||
|
||||
return efeld_value;
|
||||
}
|
||||
|
||||
double RearwallPotential::getElectricField(double radius, double z,
|
||||
int clynder_axis) const {
|
||||
@@ -288,6 +270,19 @@ double RearwallPotential::getRadialFieldComponent(double r, double z,
|
||||
}
|
||||
|
||||
bool RearwallPotential::isCoordinateOutsideCylinder(double radius, double z) const {
|
||||
if (z<=0)
|
||||
{
|
||||
std::cout << "z kleiner null" << std::endl;
|
||||
}
|
||||
else if (z>=maximal_z_for_bessel_calculation_)
|
||||
{
|
||||
//std::cout << z << " größer als "<< maximal_z_for_bessel_calculation_ << std::endl;
|
||||
}
|
||||
else if (radius > radius_)
|
||||
{
|
||||
std::cout << "radius auserhalb" << std::endl;
|
||||
}
|
||||
|
||||
return z<=0.0 || z>= maximal_z_for_bessel_calculation_ || radius > radius_;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "Function3d.h"
|
||||
#include "ElectricField.h"
|
||||
|
||||
class RearwallPotential : public ElectricField, public Function3d {
|
||||
class RearwallPotential : public Function3d {
|
||||
public:
|
||||
RearwallPotential(double radius, double height, double rearwall_potential, const blitz::TinyVector<double, 3>& center,
|
||||
double minimal_z_for_bessel_calculation = 0.05, int max_bessel_zero_order_ = 1000,
|
||||
@@ -13,24 +13,25 @@ class RearwallPotential : public ElectricField, public Function3d {
|
||||
~RearwallPotential();
|
||||
|
||||
void print(std::ostream &out) const;
|
||||
void print() const;
|
||||
|
||||
double getValue(double x, double y, double z, int cart_axis) const;
|
||||
blitz::TinyVector<double, 3> getValue(double x, double y, double z) const;
|
||||
blitz::TinyVector<double, 3> getValue(double z, double r, double phi) const;
|
||||
|
||||
vec3 getValue(const double &z, const double &r, const double &phi);
|
||||
|
||||
|
||||
double getElectricField(double radius, double z, int clinder_axis) const; // only used for debugging
|
||||
double getPotential(double r, double z) const; // only used for debugging
|
||||
|
||||
double height_;
|
||||
private:
|
||||
double radius_;
|
||||
double height_;
|
||||
double max_bessel_zero_order_;
|
||||
double rearwall_potential_;
|
||||
double minimal_z_for_bessel_calculation_;
|
||||
double maximal_z_for_bessel_calculation_;
|
||||
const blitz::TinyVector<double, 3> center_;
|
||||
vec3 efeld_value;
|
||||
|
||||
|
||||
// use that for large values of z the result of the potential/field is smaller than double precision
|
||||
// the bessel calculation is only done up to this z value
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
SCENARIO("Test the vec3_container Constructor with Electric Field class", "[vec3_container]") {
|
||||
GIVEN("Vec3 Container initilazed with a homogene electric field") {
|
||||
RearwallPotential electric_field(r_WGTS_m*100, z_WGTS_end_m*100, 10.0, vec3(0, 0, 0), 0.10, 1000, 1e-15, true);
|
||||
ElectricField electric_field(1);
|
||||
electric_field.print();
|
||||
Vec3_Container efeld(1000, 50, 20, electric_field);
|
||||
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ Vec3_Container::Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins,
|
||||
}
|
||||
|
||||
Vec3_Container::Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins, ElectricField &E){
|
||||
z_scale = Lin_Scale(z_WGTS_start_m*100, z_WGTS_end_m*100, num_z_bins);
|
||||
r_scale = Lin_Scale(0, r_WGTS_m*100, num_r_bins);
|
||||
z_scale = Lin_Scale(z_WGTS_start_m, z_WGTS_end_m, num_z_bins);
|
||||
r_scale = Lin_Scale(0, r_WGTS_m, num_r_bins);
|
||||
phi_scale = Lin_Scale(0, 180, num_phi_bins);
|
||||
int num_tot_bins = num_z_bins * num_r_bins * num_phi_bins;
|
||||
data = new vec3[num_tot_bins];
|
||||
@@ -50,7 +50,7 @@ Vec3_Container::Vec3_Container(int num_z_bins, int num_r_bins, int num_phi_bins,
|
||||
//data[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] = E.getPotential(r, z);
|
||||
//dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] = E.getLoc(z, r, phi);
|
||||
dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] = vec3(z, r, phi);
|
||||
std::cout << i*num_r_bins*num_phi_bins+j*num_phi_bins+k << " " << dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << " " << data[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << std::endl;
|
||||
//std::cout << i*num_r_bins*num_phi_bins+j*num_phi_bins+k << " " << dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << " " << data[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << std::endl;
|
||||
//std::cout << i*num_r_bins*num_phi_bins+j*num_phi_bins+k << " " << dataloc[i*num_r_bins*num_phi_bins+j*num_phi_bins+k] << " " << E.getPotential(r,z) << std::endl;
|
||||
|
||||
output_file_field << r << "," << phi << "," << z << ",";
|
||||
|
||||
Reference in New Issue
Block a user