Added gradB as input, adjusted drift mover
to include gradB (not yet tested for correctness)
This commit is contained in:
@@ -23,12 +23,15 @@ class ElectricField {
|
||||
|
||||
class MagneticField {
|
||||
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 gradientValue(const Coordinate& position) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<VectorField> field_;
|
||||
std::shared_ptr<VectorField> gradient_;
|
||||
};
|
||||
|
||||
class GravityField {
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace generator {
|
||||
std::shared_ptr<MagneticField> magneticField(json_t* object) {
|
||||
DEBUG_LEVEL_2("Generating magnetic field.");
|
||||
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) {
|
||||
|
||||
@@ -16,13 +16,18 @@ void ElectricField::updateDynamicField(std::shared_ptr<VectorField> field) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MagneticField::MagneticField(std::shared_ptr<VectorField> field)
|
||||
: field_(field) {}
|
||||
MagneticField::MagneticField(std::shared_ptr<VectorField> field,
|
||||
std::shared_ptr<VectorField> gradient)
|
||||
: field_(field), gradient_(gradient) {}
|
||||
|
||||
CylinderVector MagneticField::value(const Coordinate& position) const {
|
||||
return field_->value(position);
|
||||
}
|
||||
|
||||
CylinderVector MagneticField::gradientValue(const Coordinate& position) const {
|
||||
return gradient_->value(position);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -208,10 +208,12 @@ void DriftMover::move(particle::Particle* particle,
|
||||
|
||||
old_kinetic_energy = particle->kineticEnergy_eV();
|
||||
|
||||
const blitz::TinyVector<double, 3> force_over_charge =
|
||||
electric_field->value(old_position).cartesianEntries(old_position) +
|
||||
gravity_field->value(old_position).cartesianEntries(old_position) *
|
||||
particle->mass_kg() / particle->charge_C();
|
||||
blitz::TinyVector<double, 3> force_over_charge =
|
||||
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 =
|
||||
magnetic_field->value(old_position).cartesianEntries(old_position);
|
||||
@@ -227,12 +229,20 @@ void DriftMover::move(particle::Particle* particle,
|
||||
kinematic::perpendicularVector(old_velocity.cartesianEntries(), B);
|
||||
const double v_perp_norm = kinematic::norm(v_perp);
|
||||
|
||||
// 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 stepsize = std::min(leftover_distance, maximal_distance_m_);
|
||||
// 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(
|
||||
stepsize / (v_parallel_norm + v_perp_norm + v_drift_norm),
|
||||
max_time_alive);
|
||||
|
||||
Reference in New Issue
Block a user