inclusion gradB in DriftMover
This commit is contained in:
@@ -197,7 +197,7 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
old_kinetic_energy = particle->kineticEnergy_eV();
|
old_kinetic_energy = particle->kineticEnergy_eV();
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> force_over_charge =
|
blitz::TinyVector<double, 3> force_over_charge =
|
||||||
electric_field->value(old_position).cartesianEntries(old_position) +
|
electric_field->value(old_position).cartesianEntries(old_position) +
|
||||||
gravity_field->value(old_position).cartesianEntries(old_position) *
|
gravity_field->value(old_position).cartesianEntries(old_position) *
|
||||||
particle->mass_kg() / particle->charge_C();
|
particle->mass_kg() / particle->charge_C();
|
||||||
@@ -205,6 +205,9 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
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);
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> gradB =
|
||||||
|
magnetic_field->gradientValue(old_position).cartesianEntries(old_position);
|
||||||
// Todo: add calculation of divB here
|
// Todo: add calculation of divB here
|
||||||
// use Kassiopeia paper for reference
|
// use Kassiopeia paper for reference
|
||||||
|
|
||||||
@@ -216,6 +219,17 @@ 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);
|
||||||
|
|
||||||
|
// magnetic moment
|
||||||
|
const double magnetic_moment = (particle->mass_kg()*(v_perp_norm*v_perp_norm)/2)/B_norm;
|
||||||
|
|
||||||
|
force_over_charge += -(magnetic_moment / particle->charge_C() * gradB);
|
||||||
|
|
||||||
|
// curvature force
|
||||||
|
force_over_charge += -(particle->mass_kg()/particle->charge_C() *
|
||||||
|
(v_parallel_norm*v_parallel_norm) *
|
||||||
|
kinematic::perpendicularVector(gradB, B) /
|
||||||
|
B_norm);
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_drift = driftVelocity(force_over_charge, B);
|
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);
|
||||||
|
|
||||||
@@ -232,6 +246,7 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
const blitz::TinyVector<double, 3> force_over_charge_parallel =
|
const blitz::TinyVector<double, 3> force_over_charge_parallel =
|
||||||
kinematic::parallelVector(force_over_charge, 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() * force_over_charge_parallel / particle->mass_kg();
|
timestep * particle->charge_C() * force_over_charge_parallel / particle->mass_kg();
|
||||||
|
|
||||||
@@ -247,20 +262,43 @@ void DriftMover::move(particle::Particle* particle,
|
|||||||
|
|
||||||
const double gyro_frequency =
|
const double gyro_frequency =
|
||||||
particle->charge_C() * B_norm / particle->mass_kg();
|
particle->charge_C() * B_norm / particle->mass_kg();
|
||||||
const double total_rotation_angle = gyro_frequency * timestep;
|
const double total_rotation_angle = -gyro_frequency * timestep;
|
||||||
const blitz::TinyVector<double, 3> movement_around_gyro_center =
|
const blitz::TinyVector<double, 3> movement_around_gyro_center =
|
||||||
|
offset_to_gyro_center -
|
||||||
kinematic::rotateVector(offset_to_gyro_center, B,
|
kinematic::rotateVector(offset_to_gyro_center, B,
|
||||||
total_rotation_angle) -
|
total_rotation_angle);
|
||||||
offset_to_gyro_center;
|
|
||||||
|
|
||||||
const blitz::TinyVector<double, 3> v_perp_rotated =
|
const blitz::TinyVector<double, 3> v_perp_rotated =
|
||||||
kinematic::rotateVector(v_perp, B, total_rotation_angle);
|
kinematic::rotateVector(v_perp, B, total_rotation_angle);
|
||||||
|
|
||||||
|
const double v_parallel_norm_new = kinematic::norm(v_parallel + dv_electric);
|
||||||
|
// might be better to do after the actual movement and then just extract
|
||||||
|
// the position again from the particle
|
||||||
|
const blitz::TinyVector<double, 3> new_position = old_position.cartesianEntries()
|
||||||
|
+ movement_parallel
|
||||||
|
+ movement_drift
|
||||||
|
+ movement_around_gyro_center;
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> B_new =
|
||||||
|
magnetic_field->value(CartesianCoordinate(new_position)).
|
||||||
|
cartesianEntries(CartesianCoordinate(new_position));
|
||||||
|
|
||||||
|
const double v_perp_norm_new =
|
||||||
|
sqrt(2*magnetic_moment*kinematic::norm(B_new)/particle->mass_kg());
|
||||||
|
|
||||||
particle->move(CartesianCoordinate(movement_parallel + movement_drift +
|
particle->move(CartesianCoordinate(movement_parallel + movement_drift +
|
||||||
movement_around_gyro_center));
|
movement_around_gyro_center));
|
||||||
|
|
||||||
|
const blitz::TinyVector<double, 3> v_parallel_new =
|
||||||
|
kinematic::parallelVector(v_parallel + dv_electric, B_new);
|
||||||
|
const blitz::TinyVector<double, 3> v_perp_new =
|
||||||
|
kinematic::perpendicularVector(v_perp_rotated, B_new);
|
||||||
|
|
||||||
particle->velocity(
|
const blitz::TinyVector<double, 3> v_new =
|
||||||
CartesianVector(v_parallel + v_perp_rotated + dv_electric));
|
v_parallel_new/kinematic::norm(v_parallel_new)*v_parallel_norm_new +
|
||||||
|
v_perp_new/kinematic::norm(v_perp_new)*v_perp_norm_new;
|
||||||
|
|
||||||
|
particle->velocity(CartesianVector(v_new));
|
||||||
} else {
|
} else {
|
||||||
particle->move(CartesianCoordinate(movement_parallel + movement_drift));
|
particle->move(CartesianCoordinate(movement_parallel + movement_drift));
|
||||||
particle->velocity(CartesianVector(v_parallel + dv_electric));
|
particle->velocity(CartesianVector(v_parallel + dv_electric));
|
||||||
|
|||||||
Reference in New Issue
Block a user