Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc226a8d53 | ||
|
|
1f4314c527 | ||
|
|
1efcb58d35 | ||
|
|
30b0178e5f | ||
|
|
ab7c6f20cc |
@@ -49,7 +49,7 @@ class SimulationOutput {
|
|||||||
std::vector<OutputTask> tasks_density_fields_;
|
std::vector<OutputTask> tasks_density_fields_;
|
||||||
std::vector<OutputTask> tasks_current_collector_;
|
std::vector<OutputTask> tasks_current_collector_;
|
||||||
std::vector<OutputTask> tasks_deletion_logger_;
|
std::vector<OutputTask> tasks_deletion_logger_;
|
||||||
OutputTask task_potential_; // no meta data written for now
|
OutputTask task_potential_;
|
||||||
|
|
||||||
Hdf5Writer writer;
|
Hdf5Writer writer;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ std::function<double(double)> Constant(double constant);
|
|||||||
|
|
||||||
std::function<double(double)> Product(
|
std::function<double(double)> Product(
|
||||||
std::vector<std::function<double(double)>> functions);
|
std::vector<std::function<double(double)>> functions);
|
||||||
|
|
||||||
|
std::function<double(double)> Exponential(double prefactor, double scale);
|
||||||
}; // namespace D1ToD1
|
}; // namespace D1ToD1
|
||||||
|
|
||||||
namespace D3ToD1 {
|
namespace D3ToD1 {
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef GRAVITY_FIELD_GENERATOR_H
|
||||||
|
#define GRAVITY_FIELD_GENERATOR_H
|
||||||
|
|
||||||
|
#include "simulation/electromagnetic_field.h"
|
||||||
|
#include "simulation/parameter.h"
|
||||||
|
|
||||||
|
namespace generator {
|
||||||
|
std::shared_ptr<GravityField> gravityField(json_t* object);
|
||||||
|
|
||||||
|
std::shared_ptr<GravityField> gravityField(Parameter& parameter);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* GRAVITY_FIELD_GENERATOR_H */
|
||||||
@@ -23,9 +23,21 @@ class ElectricField {
|
|||||||
|
|
||||||
class MagneticField {
|
class MagneticField {
|
||||||
public:
|
public:
|
||||||
MagneticField(std::shared_ptr<VectorField> field);
|
MagneticField(std::shared_ptr<VectorField> field,
|
||||||
|
std::shared_ptr<VectorField> gradient);
|
||||||
|
|
||||||
CylinderVector value(const Coordinate& position) const;
|
CylinderVector value(const Coordinate& position) const;
|
||||||
|
CylinderVector gradientValue(const Coordinate& position) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::shared_ptr<VectorField> field_;
|
||||||
|
std::shared_ptr<VectorField> gradient_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GravityField {
|
||||||
|
public:
|
||||||
|
GravityField(std::shared_ptr<VectorField> field);
|
||||||
|
CylinderVector value(const Coordinate& position) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<VectorField> field_;
|
std::shared_ptr<VectorField> field_;
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ class Mover {
|
|||||||
virtual void move(particle::Particle* particle,
|
virtual void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field) = 0;
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BorisMover : public Mover {
|
class BorisMover : public Mover {
|
||||||
@@ -19,7 +20,8 @@ class BorisMover : public Mover {
|
|||||||
void move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field);
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double maximal_time_step_s_;
|
const double maximal_time_step_s_;
|
||||||
@@ -37,14 +39,15 @@ class DriftMover : public Mover {
|
|||||||
void move(particle::Particle* particle,
|
void move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field);
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const double maximal_distance_m_;
|
const double maximal_distance_m_;
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> driftVelocity(
|
blitz::TinyVector<double, 3> driftVelocity(
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
const blitz::TinyVector<double, 3>& force_field_over_charge,
|
||||||
const blitz::TinyVector<double, 3>& electric_field) const;
|
const blitz::TinyVector<double, 3>& magnetic_field) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MOVER_H */
|
#endif /* MOVER_H */
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class RandomNumbers;
|
|||||||
class InteractionOutput;
|
class InteractionOutput;
|
||||||
class MagneticField;
|
class MagneticField;
|
||||||
class ElectricField;
|
class ElectricField;
|
||||||
|
class GravityField;
|
||||||
class Timer;
|
class Timer;
|
||||||
class Injector;
|
class Injector;
|
||||||
class SimulationOutput;
|
class SimulationOutput;
|
||||||
@@ -57,6 +58,7 @@ class Simulation {
|
|||||||
|
|
||||||
std::shared_ptr<MagneticField> magnetic_field_;
|
std::shared_ptr<MagneticField> magnetic_field_;
|
||||||
std::shared_ptr<ElectricField> electric_field_;
|
std::shared_ptr<ElectricField> electric_field_;
|
||||||
|
std::shared_ptr<GravityField> gravity_field_;
|
||||||
|
|
||||||
std::shared_ptr<PoissonSolver> poisson_solver_;
|
std::shared_ptr<PoissonSolver> poisson_solver_;
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,16 @@
|
|||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"elastic_example3": {
|
||||||
|
"Type": "ElasticScattering",
|
||||||
|
"Target": "T",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT_elastic_scattering"
|
||||||
|
},
|
||||||
|
"ScatteringAngleDistribution": {
|
||||||
|
"Isotropic": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ionization_example1": {
|
"ionization_example1": {
|
||||||
"Type": "ElectronIonization",
|
"Type": "ElectronIonization",
|
||||||
"IonizationModel": "JanevNonDiss",
|
"IonizationModel": "JanevNonDiss",
|
||||||
@@ -46,6 +56,13 @@
|
|||||||
"OutgoingElectron": "e-",
|
"OutgoingElectron": "e-",
|
||||||
"OutgoingIon": "T+"
|
"OutgoingIon": "T+"
|
||||||
},
|
},
|
||||||
|
"ionization_example4": {
|
||||||
|
"Type": "ElectronIonization",
|
||||||
|
"IonizationModel": "JanevAtomic",
|
||||||
|
"Target": "T",
|
||||||
|
"OutgoingElectron": "e-",
|
||||||
|
"OutgoingIon": "T+"
|
||||||
|
},
|
||||||
"excitation_example0": {
|
"excitation_example0": {
|
||||||
"Type": "Excitation",
|
"Type": "Excitation",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
@@ -141,12 +158,53 @@
|
|||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"ExcitationState": "england_rotational_j1_to_j3"
|
"ExcitationState": "england_rotational_j1_to_j3"
|
||||||
},
|
},
|
||||||
|
"excitation_example19": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n2"
|
||||||
|
},
|
||||||
|
"excitation_example20": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n3"
|
||||||
|
},
|
||||||
|
"excitation_example21": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n4"
|
||||||
|
},
|
||||||
|
"excitation_example22": {
|
||||||
|
"Type": "Excitation",
|
||||||
|
"Target": "T",
|
||||||
|
"ExcitationState": "janev_atomic_n5"
|
||||||
|
},
|
||||||
|
"recombination_example1": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "T+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eTp_recombination_kotelnikov"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"recombination_example2": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "T2+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT2p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"recombination_example3": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "T3+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT3p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"T+ standart interactions": {
|
"T+ standart interactions": {
|
||||||
"elastic scattering": {
|
"elastic scattering1": {
|
||||||
"Type": "ElasticScattering",
|
"Type": "ElasticScattering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
"CrossSection": {
|
"CrossSection": {
|
||||||
@@ -156,6 +214,23 @@
|
|||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"elastic scattering2": {
|
||||||
|
"Type": "ElasticScattering",
|
||||||
|
"Target": "T",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "TpT_elastic_scattering_schultz"
|
||||||
|
},
|
||||||
|
"ScatteringAngleDistribution": {
|
||||||
|
"Isotropic": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"charge exchange": {
|
||||||
|
"Type": "ChargeExchange",
|
||||||
|
"Target": "T",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "TpT_charge_exchange_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"clustering1": {
|
"clustering1": {
|
||||||
"Type": "Clustering",
|
"Type": "Clustering",
|
||||||
"Target": "T2",
|
"Target": "T2",
|
||||||
@@ -172,6 +247,21 @@
|
|||||||
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"clustering3": {
|
||||||
|
"Type": "Clustering",
|
||||||
|
"Target": "T",
|
||||||
|
"Product": "T2+",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "TpT_clustering_tertiary_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"recombination": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "e-",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eTp_recombination_kotelnikov"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
@@ -192,6 +282,13 @@
|
|||||||
"PredefinedFunction": "T2pT2_clustering_janev"
|
"PredefinedFunction": "T2pT2_clustering_janev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"recombination": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "e-",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT2p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
@@ -207,6 +304,13 @@
|
|||||||
"Isotropic": {}
|
"Isotropic": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"recombination": {
|
||||||
|
"Type": "Recombination",
|
||||||
|
"Target": "e-",
|
||||||
|
"CrossSection": {
|
||||||
|
"PredefinedFunction": "eT3p_recombination_janev"
|
||||||
|
}
|
||||||
|
},
|
||||||
"free_movement_example": {
|
"free_movement_example": {
|
||||||
"Type": "FreeMovement"
|
"Type": "FreeMovement"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -570,15 +570,60 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"GravityField": {
|
||||||
|
"VectorField": {
|
||||||
|
"VectorFieldFunctionInZ": {
|
||||||
|
"zFunction": {
|
||||||
|
"Constant3D": {
|
||||||
|
"constant": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"PoissonSolver": {
|
"PoissonSolver": {
|
||||||
"UseInSimulation": "false"
|
"BoundaryGeometry": {
|
||||||
|
"Cylinder": {
|
||||||
|
"Radius": {
|
||||||
|
"value": 4.5,
|
||||||
|
"unit": "cm"
|
||||||
|
},
|
||||||
|
"Height": {
|
||||||
|
"value": 1600,
|
||||||
|
"unit": "cm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"PositionBinning": {
|
||||||
|
"CreateSameAs": [
|
||||||
|
"GlobalPositionBinning"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Boundary": {
|
||||||
|
"Top": {
|
||||||
|
"type": "neumann",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Bottom": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
},
|
||||||
|
"Hull": {
|
||||||
|
"type": "dirichlet",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"TargetAccuracy": 1e-7,
|
||||||
|
"NumCycles": 2e4,
|
||||||
|
"Intervall": 1,
|
||||||
|
"Offset": 9
|
||||||
},
|
},
|
||||||
"Simulation": {
|
"Simulation": {
|
||||||
"SimulatedEvents": 1,
|
"SimulatedEvents": 1,
|
||||||
"EventStride": 1
|
"EventStride": 1
|
||||||
},
|
},
|
||||||
"Output": {
|
"Output": {
|
||||||
"folder": "output",
|
"folder": "output_",
|
||||||
"filename": "test",
|
"filename": "test",
|
||||||
"DensityFields": {
|
"DensityFields": {
|
||||||
"Species": "all",
|
"Species": "all",
|
||||||
@@ -599,6 +644,10 @@
|
|||||||
],
|
],
|
||||||
"Intervall": "EachSync",
|
"Intervall": "EachSync",
|
||||||
"OverwriteLast": "true"
|
"OverwriteLast": "true"
|
||||||
|
},
|
||||||
|
"PoissonSolver": {
|
||||||
|
"Intervall": "EachSync",
|
||||||
|
"OverwriteLast": "true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"RandomNumbers": {
|
"RandomNumbers": {
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ std::function<double(double)> Product(
|
|||||||
return product;
|
return product;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::function<double(double)> Exponential(double prefactor, double scale) {
|
||||||
|
return [=](double x) { return prefactor * std::exp(scale * x); };
|
||||||
|
}
|
||||||
}; // namespace D1ToD1
|
}; // namespace D1ToD1
|
||||||
|
|
||||||
namespace D3ToD1 {
|
namespace D3ToD1 {
|
||||||
|
|||||||
@@ -71,6 +71,13 @@ std::function<double(double)> function1D(json_t* object) {
|
|||||||
}
|
}
|
||||||
return D1ToD1::Product(functions);
|
return D1ToD1::Product(functions);
|
||||||
|
|
||||||
|
} else if (json_object_by_path(object, {"Exponential"})) {
|
||||||
|
DEBUG_LEVEL_2("Creating function1d: Exponential.");
|
||||||
|
double prefactor = json_double(json_object_by_path(
|
||||||
|
object, {"Exponential", {"prefactor"}}));
|
||||||
|
double scale = json_double(json_object_by_path(
|
||||||
|
object, {"Exponential", {"scale"}}));
|
||||||
|
return D1ToD1::Exponential(prefactor, scale);
|
||||||
} else {
|
} else {
|
||||||
ERROR("This 1d to 1d function is not implemented.");
|
ERROR("This 1d to 1d function is not implemented.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#include "generators/gravity_field_generator.h"
|
||||||
|
|
||||||
|
#include "generators/vector_field_generator.h"
|
||||||
|
|
||||||
|
namespace generator {
|
||||||
|
|
||||||
|
std::shared_ptr<GravityField> gravityField(json_t* object) {
|
||||||
|
DEBUG_LEVEL_2("Generating gravity field.");
|
||||||
|
return std::shared_ptr<GravityField>(new GravityField(
|
||||||
|
buildVectorField(json_object_by_path(object, {"VectorField"}))));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<GravityField> gravityField(Parameter& parameter) {
|
||||||
|
return gravityField(
|
||||||
|
json_object_by_path(parameter.jsonFile(), {"GravityField"}));
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@@ -7,7 +7,8 @@ namespace generator {
|
|||||||
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
||||||
DEBUG_LEVEL_2("Generating magnetic field.");
|
DEBUG_LEVEL_2("Generating magnetic field.");
|
||||||
return std::shared_ptr<MagneticField>(new MagneticField(
|
return std::shared_ptr<MagneticField>(new MagneticField(
|
||||||
buildVectorField(json_object_by_path(object, {"VectorField"}))));
|
buildVectorField(json_object_by_path(object, {"VectorField"})),
|
||||||
|
buildVectorField(json_object_by_path(object, {"GradientField"}))));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MagneticField> magneticField(Parameter& parameter) {
|
std::shared_ptr<MagneticField> magneticField(Parameter& parameter) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ double buildMass(json_t* object) {
|
|||||||
} else if (json_object_by_path(object, {"value"})) {
|
} else if (json_object_by_path(object, {"value"})) {
|
||||||
return json_double(json_object_by_path(object, {"value"}));
|
return json_double(json_object_by_path(object, {"value"}));
|
||||||
} else {
|
} else {
|
||||||
ERROR("The mass is not given correcty.");
|
ERROR("The mass is not given correctly.");
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ std::shared_ptr<SimulationOutput> buildSimulationOutput(
|
|||||||
intervall = 1;
|
intervall = 1;
|
||||||
}
|
}
|
||||||
ASSERT_POSITIVE(&intervall,
|
ASSERT_POSITIVE(&intervall,
|
||||||
"The intervall for the poisson solver output must be positive");
|
"The output intervall for the poisson solver output must be positive.");
|
||||||
|
|
||||||
bool overwrite_last = json_bool(
|
bool overwrite_last = json_bool(
|
||||||
json_object_by_path(object, {"PoissonSolver", "OverwriteLast"}));
|
json_object_by_path(object, {"PoissonSolver", "OverwriteLast"}));
|
||||||
|
|||||||
@@ -16,9 +16,25 @@ void ElectricField::updateDynamicField(std::shared_ptr<VectorField> field) {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
MagneticField::MagneticField(std::shared_ptr<VectorField> field)
|
MagneticField::MagneticField(std::shared_ptr<VectorField> field,
|
||||||
: field_(field) {}
|
std::shared_ptr<VectorField> gradient)
|
||||||
|
: field_(field), gradient_(gradient) {}
|
||||||
|
|
||||||
CylinderVector MagneticField::value(const Coordinate& position) const {
|
CylinderVector MagneticField::value(const Coordinate& position) const {
|
||||||
return field_->value(position);
|
return field_->value(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CylinderVector MagneticField::gradientValue(const Coordinate& position) const {
|
||||||
|
return gradient_->value(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
GravityField::GravityField(std::shared_ptr<VectorField> field):
|
||||||
|
field_(field) {}
|
||||||
|
|
||||||
|
CylinderVector GravityField::value(const Coordinate& position) const {
|
||||||
|
return field_->value(position);
|
||||||
|
}
|
||||||
|
|||||||
+43
-18
@@ -22,24 +22,28 @@ BorisMover::BorisMover(double maximal_time_step_s)
|
|||||||
void BorisMover::move(particle::Particle* particle,
|
void BorisMover::move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field) {
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field) {
|
||||||
double leftover_distance = mfp_m;
|
double leftover_distance = mfp_m;
|
||||||
|
|
||||||
auto old_position = particle->position();
|
auto old_position = particle->position();
|
||||||
double old_kinetic_energy = particle->kineticEnergy_eV();
|
double old_kinetic_energy = particle->kineticEnergy_eV();
|
||||||
|
|
||||||
if (old_kinetic_energy < 1E-9) {
|
// if (old_kinetic_energy < 1E-9) {
|
||||||
// Guard against small enegies taking up much time without contributing to
|
// DEBUG_LEVEL_2("Particle has too low an energy.");
|
||||||
// density
|
// // Guard against small enegies taking up much time without contributing to
|
||||||
return;
|
// // density
|
||||||
}
|
// //return;
|
||||||
|
// }
|
||||||
|
|
||||||
bool changed_position_bin = false;
|
bool changed_position_bin = false;
|
||||||
bool changed_energy_bin = false;
|
bool changed_energy_bin = false;
|
||||||
bool left_simulation_domain = false;
|
bool left_simulation_domain = false;
|
||||||
|
bool died_in_bin = false;
|
||||||
|
|
||||||
while (
|
while (
|
||||||
!(changed_position_bin || changed_energy_bin || left_simulation_domain) &&
|
!(changed_position_bin || changed_energy_bin
|
||||||
|
|| left_simulation_domain || died_in_bin) &&
|
||||||
(leftover_distance > 0.)) {
|
(leftover_distance > 0.)) {
|
||||||
old_position = particle->position();
|
old_position = particle->position();
|
||||||
old_kinetic_energy = particle->kineticEnergy_eV();
|
old_kinetic_energy = particle->kineticEnergy_eV();
|
||||||
@@ -50,8 +54,13 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
electric_field->value(old_position).cartesianEntries(old_position);
|
electric_field->value(old_position).cartesianEntries(old_position);
|
||||||
const blitz::TinyVector<double, 3> B =
|
const blitz::TinyVector<double, 3> B =
|
||||||
magnetic_field->value(old_position).cartesianEntries(old_position);
|
magnetic_field->value(old_position).cartesianEntries(old_position);
|
||||||
|
const blitz::TinyVector<double, 3> g =
|
||||||
|
gravity_field->value(old_position).cartesianEntries(old_position);
|
||||||
|
|
||||||
movementStep(particle, E, B, moved_distance);
|
const blitz::TinyVector<double, 3> force_over_q =
|
||||||
|
E + particle->mass_kg()/particle->charge_C()*g;
|
||||||
|
|
||||||
|
movementStep(particle, force_over_q, B, moved_distance);
|
||||||
particle->increaseTimeAlive(maximal_time_step_s_);
|
particle->increaseTimeAlive(maximal_time_step_s_);
|
||||||
particle->increaseTimeInBin(maximal_time_step_s_);
|
particle->increaseTimeInBin(maximal_time_step_s_);
|
||||||
|
|
||||||
@@ -68,6 +77,9 @@ void BorisMover::move(particle::Particle* particle,
|
|||||||
left_simulation_domain =
|
left_simulation_domain =
|
||||||
particle->specie()->terminator()->leftSimulationDomain(particle);
|
particle->specie()->terminator()->leftSimulationDomain(particle);
|
||||||
|
|
||||||
|
died_in_bin =
|
||||||
|
particle->specie()->terminator()->reachedMaxTimeAlive(particle);
|
||||||
|
|
||||||
leftover_distance -= moved_distance;
|
leftover_distance -= moved_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +184,8 @@ DriftMover::DriftMover(double maximal_distance)
|
|||||||
void DriftMover::move(particle::Particle* particle,
|
void DriftMover::move(particle::Particle* particle,
|
||||||
double mfp_m,
|
double mfp_m,
|
||||||
ElectricField* electric_field,
|
ElectricField* electric_field,
|
||||||
MagneticField* magnetic_field) {
|
MagneticField* magnetic_field,
|
||||||
|
GravityField* gravity_field) {
|
||||||
double leftover_distance = mfp_m;
|
double leftover_distance = mfp_m;
|
||||||
|
|
||||||
auto old_position = particle->position();
|
auto old_position = particle->position();
|
||||||
@@ -195,9 +208,13 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
old_kinetic_energy = particle->kineticEnergy_eV();
|
old_kinetic_energy = particle->kineticEnergy_eV();
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> E =
|
blitz::TinyVector<double, 3> force_over_charge =
|
||||||
electric_field->value(old_position).cartesianEntries(old_position);
|
electric_field->value(old_position).cartesianEntries(old_position);
|
||||||
|
|
||||||
|
// gravity force / q
|
||||||
|
force_over_charge += gravity_field->value(old_position).cartesianEntries(old_position)
|
||||||
|
* particle->mass_kg() / particle->charge_C();
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> B =
|
const blitz::TinyVector<double, 3> B =
|
||||||
magnetic_field->value(old_position).cartesianEntries(old_position);
|
magnetic_field->value(old_position).cartesianEntries(old_position);
|
||||||
const double B_norm = kinematic::norm(B);
|
const double B_norm = kinematic::norm(B);
|
||||||
@@ -212,12 +229,20 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
kinematic::perpendicularVector(old_velocity.cartesianEntries(), B);
|
kinematic::perpendicularVector(old_velocity.cartesianEntries(), B);
|
||||||
const double v_perp_norm = kinematic::norm(v_perp);
|
const double v_perp_norm = kinematic::norm(v_perp);
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_drift = driftVelocity(B, E);
|
// centrifugal and magnetic moment force / q
|
||||||
|
// not sure if correct. It might be that the centrifugal force includes only the
|
||||||
|
// perpendicular part of grad(B)
|
||||||
|
force_over_charge += -(particle->mass_kg()/particle->charge_C() *
|
||||||
|
(v_parallel_norm*v_parallel_norm + v_perp_norm*v_perp_norm/2) *
|
||||||
|
magnetic_field->gradientValue(old_position).cartesianEntries(old_position) /
|
||||||
|
B_norm);
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> v_drift = driftVelocity(force_over_charge, B);
|
||||||
const double v_drift_norm = kinematic::norm(v_drift);
|
const double v_drift_norm = kinematic::norm(v_drift);
|
||||||
|
|
||||||
const double stepsize = std::min(leftover_distance, maximal_distance_m_);
|
const double stepsize = std::min(leftover_distance, maximal_distance_m_);
|
||||||
// guard against very large timesteps i.e. v ~ 0 -> timestep = Inf
|
// guard against very large timesteps i.e. v ~ 0 -> timestep = Inf
|
||||||
// should be a very rare case (but has happend)
|
// should be a very rare case
|
||||||
const double timestep = std::min(
|
const double timestep = std::min(
|
||||||
stepsize / (v_parallel_norm + v_perp_norm + v_drift_norm),
|
stepsize / (v_parallel_norm + v_perp_norm + v_drift_norm),
|
||||||
max_time_alive);
|
max_time_alive);
|
||||||
@@ -226,10 +251,10 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
v_parallel * timestep;
|
v_parallel * timestep;
|
||||||
const blitz::TinyVector<double, 3> movement_drift = v_drift * timestep;
|
const blitz::TinyVector<double, 3> movement_drift = v_drift * timestep;
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> E_parallel =
|
const blitz::TinyVector<double, 3> force_over_charge_parallel =
|
||||||
kinematic::parallelVector(E, B);
|
kinematic::parallelVector(force_over_charge, B);
|
||||||
const blitz::TinyVector<double, 3> dv_electric =
|
const blitz::TinyVector<double, 3> dv_electric =
|
||||||
timestep * particle->charge_C() * E_parallel / particle->mass_kg();
|
timestep * particle->charge_C() * force_over_charge_parallel / particle->mass_kg();
|
||||||
|
|
||||||
if (v_perp_norm > SimConstants::compare_epsilon) {
|
if (v_perp_norm > SimConstants::compare_epsilon) {
|
||||||
const double gyro_radius = particle->mass_kg() * v_perp_norm /
|
const double gyro_radius = particle->mass_kg() * v_perp_norm /
|
||||||
@@ -291,8 +316,8 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> DriftMover::driftVelocity(
|
blitz::TinyVector<double, 3> DriftMover::driftVelocity(
|
||||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
const blitz::TinyVector<double, 3>& force_field_over_charge,
|
||||||
const blitz::TinyVector<double, 3>& electric_field) const {
|
const blitz::TinyVector<double, 3>& magnetic_field) const {
|
||||||
return blitz::cross(magnetic_field, electric_field) /
|
return blitz::cross(force_field_over_charge, magnetic_field) /
|
||||||
blitz::dot(magnetic_field, magnetic_field);
|
blitz::dot(magnetic_field, magnetic_field);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "generators/simulation_output_generator.h"
|
#include "generators/simulation_output_generator.h"
|
||||||
#include "generators/species_generator.h"
|
#include "generators/species_generator.h"
|
||||||
#include "generators/poisson_solver_generator.h"
|
#include "generators/poisson_solver_generator.h"
|
||||||
|
#include "generators/gravity_field_generator.h"
|
||||||
|
|
||||||
#include "tools/simulation_time.h"
|
#include "tools/simulation_time.h"
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ Simulation::Simulation(std::string parameter_filename)
|
|||||||
void Simulation::init(Parameter& parameter) {
|
void Simulation::init(Parameter& parameter) {
|
||||||
magnetic_field_ = generator::magneticField(parameter);
|
magnetic_field_ = generator::magneticField(parameter);
|
||||||
electric_field_ = generator::electricField(parameter);
|
electric_field_ = generator::electricField(parameter);
|
||||||
|
gravity_field_ = generator::gravityField(parameter);
|
||||||
|
|
||||||
DEBUG_LEVEL_0("Creating species.");
|
DEBUG_LEVEL_0("Creating species.");
|
||||||
generator::SpeciesBuilder builder(parameter);
|
generator::SpeciesBuilder builder(parameter);
|
||||||
@@ -194,7 +196,7 @@ void Simulation::processUntilTermination(
|
|||||||
|
|
||||||
SimulationTimer::eventStartPoint(std::string("Mover"));
|
SimulationTimer::eventStartPoint(std::string("Mover"));
|
||||||
particle.specie()->mover()->move(&particle, mfp_m, electric_field_.get(),
|
particle.specie()->mover()->move(&particle, mfp_m, electric_field_.get(),
|
||||||
magnetic_field_.get());
|
magnetic_field_.get(), gravity_field_.get());
|
||||||
SimulationTimer::eventStopPoint(std::string("Mover"));
|
SimulationTimer::eventStopPoint(std::string("Mover"));
|
||||||
|
|
||||||
bool was_reflected = false;
|
bool was_reflected = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user