Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
93a51acbda | ||
|
|
30b0178e5f | ||
|
|
ab7c6f20cc |
@@ -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 */
|
||||
@@ -56,10 +56,11 @@ class PoissonSolver {
|
||||
double target_accuracy,
|
||||
int num_cycles,
|
||||
int solver_intervall,
|
||||
int solver_offset);
|
||||
int solver_offset,
|
||||
bool reset_after_solving);
|
||||
|
||||
void solvePotential(const blitz::Array<double, 3> charge_density,
|
||||
int cpu_sync);
|
||||
int cpu_sync, bool& reset);
|
||||
blitz::Array<double, 3> potential();
|
||||
std::shared_ptr<VectorField> staticElectricField();
|
||||
const CylinderBinning* densityBinning();
|
||||
@@ -75,6 +76,7 @@ class PoissonSolver {
|
||||
const int num_cycles_;
|
||||
const int solver_intervall_;
|
||||
const int solver_offset_;
|
||||
const bool reset_after_solving_;
|
||||
|
||||
// density binning defined on the cell centers, potential defined
|
||||
// such that it exists on the cell edges so that the azimuthal
|
||||
|
||||
@@ -31,6 +31,8 @@ class CurrentCollector {
|
||||
|
||||
double physicalTime() const;
|
||||
|
||||
void resetCurrentCollector();
|
||||
|
||||
friend class CpuSynchronizer;
|
||||
|
||||
private:
|
||||
|
||||
@@ -38,6 +38,8 @@ class DynamicDensityField : public DensityField {
|
||||
double density(const Coordinate& position);
|
||||
double density(const Coordinate& position, double energy_eV);
|
||||
|
||||
void resetDynamicDensityField();
|
||||
|
||||
blitz::Array<double, 3> densityArray();
|
||||
blitz::Array<double, 4> spectrumArray();
|
||||
blitz::Array<double, 4> timeInBinArray() const;
|
||||
|
||||
@@ -31,4 +31,13 @@ class MagneticField {
|
||||
std::shared_ptr<VectorField> field_;
|
||||
};
|
||||
|
||||
class GravityField {
|
||||
public:
|
||||
GravityField(std::shared_ptr<VectorField> field);
|
||||
CylinderVector value(const Coordinate& position) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<VectorField> field_;
|
||||
};
|
||||
|
||||
#endif /* ELECTROMAGNETIC_FIELD_H */
|
||||
|
||||
@@ -23,6 +23,8 @@ class DeletionLogger {
|
||||
void numDeletions(long int new_value, DeletionType type);
|
||||
long int numDeletions(DeletionType type) const;
|
||||
|
||||
void resetDeletionLogger();
|
||||
|
||||
friend class CpuSynchronizer;
|
||||
|
||||
private:
|
||||
|
||||
@@ -9,7 +9,8 @@ class Mover {
|
||||
virtual void move(particle::Particle* particle,
|
||||
double mfp_m,
|
||||
ElectricField* electric_field,
|
||||
MagneticField* magnetic_field) = 0;
|
||||
MagneticField* magnetic_field,
|
||||
GravityField* gravity_field) = 0;
|
||||
};
|
||||
|
||||
class BorisMover : public Mover {
|
||||
@@ -19,7 +20,8 @@ class BorisMover : public Mover {
|
||||
void move(particle::Particle* particle,
|
||||
double mfp_m,
|
||||
ElectricField* electric_field,
|
||||
MagneticField* magnetic_field);
|
||||
MagneticField* magnetic_field,
|
||||
GravityField* gravity_field);
|
||||
|
||||
private:
|
||||
const double maximal_time_step_s_;
|
||||
@@ -37,14 +39,15 @@ class DriftMover : public Mover {
|
||||
void move(particle::Particle* particle,
|
||||
double mfp_m,
|
||||
ElectricField* electric_field,
|
||||
MagneticField* magnetic_field);
|
||||
MagneticField* magnetic_field,
|
||||
GravityField* gravity_field);
|
||||
|
||||
private:
|
||||
const double maximal_distance_m_;
|
||||
|
||||
blitz::TinyVector<double, 3> driftVelocity(
|
||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
||||
const blitz::TinyVector<double, 3>& electric_field) const;
|
||||
const blitz::TinyVector<double, 3>& force_field_over_charge,
|
||||
const blitz::TinyVector<double, 3>& magnetic_field) const;
|
||||
};
|
||||
|
||||
#endif /* MOVER_H */
|
||||
|
||||
@@ -12,6 +12,7 @@ class RandomNumbers;
|
||||
class InteractionOutput;
|
||||
class MagneticField;
|
||||
class ElectricField;
|
||||
class GravityField;
|
||||
class Timer;
|
||||
class Injector;
|
||||
class SimulationOutput;
|
||||
@@ -57,6 +58,7 @@ class Simulation {
|
||||
|
||||
std::shared_ptr<MagneticField> magnetic_field_;
|
||||
std::shared_ptr<ElectricField> electric_field_;
|
||||
std::shared_ptr<GravityField> gravity_field_;
|
||||
|
||||
std::shared_ptr<PoissonSolver> poisson_solver_;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class Timer {
|
||||
double time() const;
|
||||
void increaseTimestep(double time_s);
|
||||
void setTime(double time_s);
|
||||
void resetTime();
|
||||
|
||||
private:
|
||||
double current_time_s_;
|
||||
|
||||
@@ -25,6 +25,16 @@
|
||||
"Isotropic": {}
|
||||
}
|
||||
},
|
||||
"elastic_example3": {
|
||||
"Type": "ElasticScattering",
|
||||
"Target": "T",
|
||||
"CrossSection": {
|
||||
"PredefinedFunction": "eT_elastic_scattering"
|
||||
},
|
||||
"ScatteringAngleDistribution": {
|
||||
"Isotropic": {}
|
||||
}
|
||||
},
|
||||
"ionization_example1": {
|
||||
"Type": "ElectronIonization",
|
||||
"IonizationModel": "JanevNonDiss",
|
||||
@@ -46,6 +56,13 @@
|
||||
"OutgoingElectron": "e-",
|
||||
"OutgoingIon": "T+"
|
||||
},
|
||||
"ionization_example4": {
|
||||
"Type": "ElectronIonization",
|
||||
"IonizationModel": "JanevAtomic",
|
||||
"Target": "T",
|
||||
"OutgoingElectron": "e-",
|
||||
"OutgoingIon": "T+"
|
||||
},
|
||||
"excitation_example0": {
|
||||
"Type": "Excitation",
|
||||
"Target": "T2",
|
||||
@@ -141,12 +158,53 @@
|
||||
"Target": "T2",
|
||||
"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": {
|
||||
"Type": "FreeMovement"
|
||||
}
|
||||
},
|
||||
"T+ standart interactions": {
|
||||
"elastic scattering": {
|
||||
"elastic scattering1": {
|
||||
"Type": "ElasticScattering",
|
||||
"Target": "T2",
|
||||
"CrossSection": {
|
||||
@@ -156,6 +214,23 @@
|
||||
"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": {
|
||||
"Type": "Clustering",
|
||||
"Target": "T2",
|
||||
@@ -172,6 +247,21 @@
|
||||
"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": {
|
||||
"Type": "FreeMovement"
|
||||
}
|
||||
@@ -192,6 +282,13 @@
|
||||
"PredefinedFunction": "T2pT2_clustering_janev"
|
||||
}
|
||||
},
|
||||
"recombination": {
|
||||
"Type": "Recombination",
|
||||
"Target": "e-",
|
||||
"CrossSection": {
|
||||
"PredefinedFunction": "eT2p_recombination_janev"
|
||||
}
|
||||
},
|
||||
"free_movement_example": {
|
||||
"Type": "FreeMovement"
|
||||
}
|
||||
@@ -207,6 +304,13 @@
|
||||
"Isotropic": {}
|
||||
}
|
||||
},
|
||||
"recombination": {
|
||||
"Type": "Recombination",
|
||||
"Target": "e-",
|
||||
"CrossSection": {
|
||||
"PredefinedFunction": "eT3p_recombination_janev"
|
||||
}
|
||||
},
|
||||
"free_movement_example": {
|
||||
"Type": "FreeMovement"
|
||||
}
|
||||
|
||||
@@ -570,15 +570,60 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"GravityField": {
|
||||
"VectorField": {
|
||||
"VectorFieldFunctionInZ": {
|
||||
"zFunction": {
|
||||
"Constant3D": {
|
||||
"constant": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"SimulatedEvents": 1,
|
||||
"EventStride": 1
|
||||
},
|
||||
"Output": {
|
||||
"folder": "output",
|
||||
"folder": "output_",
|
||||
"filename": "test",
|
||||
"DensityFields": {
|
||||
"Species": "all",
|
||||
@@ -599,9 +644,13 @@
|
||||
],
|
||||
"Intervall": "EachSync",
|
||||
"OverwriteLast": "true"
|
||||
},
|
||||
"PoissonSolver": {
|
||||
"Intervall": "EachSync",
|
||||
"OverwriteLast": "true"
|
||||
}
|
||||
},
|
||||
"RandomNumbers": {
|
||||
"Seed": 1337
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"}));
|
||||
}
|
||||
|
||||
};
|
||||
@@ -51,10 +51,14 @@ namespace generator {
|
||||
|
||||
int num_cycles = parameter.intValue(json_path_append({"PoissonSolver"},
|
||||
{"NumCycles"}));
|
||||
|
||||
bool reset_after_solving = parameter.boolValue(
|
||||
json_path_append({"PoissonSolver"}, {"ResetAfterSolving"}), false);
|
||||
|
||||
return std::shared_ptr<PoissonSolver>(new PoissonSolver(boundaries.at("Bottom"),
|
||||
boundaries.at("Top"), boundaries.at("Hull"), geometry, position_binning,
|
||||
electrodes, target_accuracy, num_cycles, solver_intervall, solver_offset));
|
||||
electrodes, target_accuracy, num_cycles, solver_intervall, solver_offset,
|
||||
reset_after_solving));
|
||||
}
|
||||
|
||||
std::map<std::string, GlobalBoundary> buildBoundaries(Parameter& parameter,
|
||||
|
||||
@@ -17,7 +17,8 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
||||
double target_accuracy,
|
||||
int num_cycles,
|
||||
int solver_intervall,
|
||||
int solver_offset)
|
||||
int solver_offset,
|
||||
bool reset_after_solving)
|
||||
: bottom_boundary_(bottom_boundary),
|
||||
top_boundary_(top_boundary),
|
||||
hull_boundary_(hull_boundary),
|
||||
@@ -34,7 +35,8 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
||||
target_accuracy_(target_accuracy),
|
||||
num_cycles_(num_cycles),
|
||||
solver_intervall_(solver_intervall),
|
||||
solver_offset_(solver_offset) {
|
||||
solver_offset_(solver_offset),
|
||||
reset_after_solving_(reset_after_solving) {
|
||||
|
||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||
@@ -79,13 +81,16 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary,
|
||||
blitz::Range(density_binning.binIndexMin()(2),
|
||||
density_binning.binIndexMax()(2)));
|
||||
zero_chargedensity = 0.;
|
||||
solvePotential(zero_chargedensity, 0);
|
||||
bool reset;
|
||||
solvePotential(zero_chargedensity, 0, reset);
|
||||
}
|
||||
|
||||
void PoissonSolver::solvePotential(
|
||||
const blitz::Array<double, 3> charge_density, int cpu_sync) {
|
||||
const blitz::Array<double, 3> charge_density, int cpu_sync,
|
||||
bool& reset) {
|
||||
if ((cpu_sync % solver_intervall_ != 0) || ((cpu_sync <= solver_offset_)
|
||||
&& (cpu_sync > 0))) {
|
||||
reset = false;
|
||||
return;
|
||||
}
|
||||
DEBUG_LEVEL_3("Interpolating chargedensity.");
|
||||
@@ -102,6 +107,7 @@ void PoissonSolver::solvePotential(
|
||||
}
|
||||
++it;
|
||||
} while (it < num_cycles_);
|
||||
reset = reset_after_solving_;
|
||||
}
|
||||
|
||||
void PoissonSolver::solverIteration(
|
||||
@@ -243,7 +249,7 @@ bool PoissonSolver::converged(
|
||||
double normalized_maximum =
|
||||
maximum_difference*SI::eps0/(fabs(blitz::max(interpolated_density)) + 1e-12);
|
||||
std::ostringstream message;
|
||||
message << "Maximum Differenece normalized by order of magnitude: "
|
||||
message << "Maximum Difference normalized by order of magnitude: "
|
||||
<< normalized_difference;
|
||||
DEBUG_LEVEL_0(message.str());
|
||||
return normalized_difference < target_accuracy_;
|
||||
|
||||
@@ -239,4 +239,15 @@ blitz::Array<double, 3> CurrentCollector::currentInR() const {
|
||||
}
|
||||
double CurrentCollector::physicalTime() const {
|
||||
return timer_->time();
|
||||
}
|
||||
|
||||
void CurrentCollector::resetCurrentCollector() {
|
||||
z_negative_crossings = 0.;
|
||||
z_positive_crossings = 0.;
|
||||
|
||||
phi_negative_crossings = 0.;
|
||||
phi_positive_crossings = 0.;
|
||||
|
||||
r_negative_crossings = 0.;
|
||||
r_positive_crossings = 0.;
|
||||
}
|
||||
@@ -205,6 +205,13 @@ double DynamicDensityField::physicalTime() const {
|
||||
return timer_->time();
|
||||
}
|
||||
|
||||
void DynamicDensityField::resetDynamicDensityField() {
|
||||
timer_->resetTime(); // reductive since shared between species
|
||||
time_in_bin_s_ = 0.;
|
||||
deleted_particles_ = 0.;
|
||||
density_per_m3_ = 0.;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -21,4 +21,15 @@ MagneticField::MagneticField(std::shared_ptr<VectorField> field)
|
||||
|
||||
CylinderVector MagneticField::value(const Coordinate& position) const {
|
||||
return field_->value(position);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GravityField::GravityField(std::shared_ptr<VectorField> field):
|
||||
field_(field) {}
|
||||
|
||||
CylinderVector GravityField::value(const Coordinate& position) const {
|
||||
return field_->value(position);
|
||||
}
|
||||
|
||||
@@ -30,3 +30,9 @@ long int DeletionLogger::numDeletions(DeletionType type) const {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DeletionLogger::resetDeletionLogger() {
|
||||
for(auto& pair : num_deletions) {
|
||||
pair.second = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-11
@@ -22,7 +22,8 @@ BorisMover::BorisMover(double maximal_time_step_s)
|
||||
void BorisMover::move(particle::Particle* particle,
|
||||
double mfp_m,
|
||||
ElectricField* electric_field,
|
||||
MagneticField* magnetic_field) {
|
||||
MagneticField* magnetic_field,
|
||||
GravityField* gravity_field) {
|
||||
double leftover_distance = mfp_m;
|
||||
|
||||
auto old_position = particle->position();
|
||||
@@ -172,7 +173,8 @@ DriftMover::DriftMover(double maximal_distance)
|
||||
void DriftMover::move(particle::Particle* particle,
|
||||
double mfp_m,
|
||||
ElectricField* electric_field,
|
||||
MagneticField* magnetic_field) {
|
||||
MagneticField* magnetic_field,
|
||||
GravityField* gravity_field) {
|
||||
double leftover_distance = mfp_m;
|
||||
|
||||
auto old_position = particle->position();
|
||||
@@ -195,8 +197,10 @@ void DriftMover::move(particle::Particle* particle,
|
||||
|
||||
old_kinetic_energy = particle->kineticEnergy_eV();
|
||||
|
||||
const blitz::TinyVector<double, 3> E =
|
||||
electric_field->value(old_position).cartesianEntries(old_position);
|
||||
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();
|
||||
|
||||
const blitz::TinyVector<double, 3> B =
|
||||
magnetic_field->value(old_position).cartesianEntries(old_position);
|
||||
@@ -212,7 +216,7 @@ void DriftMover::move(particle::Particle* particle,
|
||||
kinematic::perpendicularVector(old_velocity.cartesianEntries(), B);
|
||||
const double v_perp_norm = kinematic::norm(v_perp);
|
||||
|
||||
const blitz::TinyVector<double, 3> v_drift = driftVelocity(B, E);
|
||||
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_);
|
||||
@@ -226,10 +230,10 @@ void DriftMover::move(particle::Particle* particle,
|
||||
v_parallel * timestep;
|
||||
const blitz::TinyVector<double, 3> movement_drift = v_drift * timestep;
|
||||
|
||||
const blitz::TinyVector<double, 3> E_parallel =
|
||||
kinematic::parallelVector(E, B);
|
||||
const blitz::TinyVector<double, 3> force_over_charge_parallel =
|
||||
kinematic::parallelVector(force_over_charge, B);
|
||||
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) {
|
||||
const double gyro_radius = particle->mass_kg() * v_perp_norm /
|
||||
@@ -291,8 +295,8 @@ void DriftMover::move(particle::Particle* particle,
|
||||
}
|
||||
|
||||
blitz::TinyVector<double, 3> DriftMover::driftVelocity(
|
||||
const blitz::TinyVector<double, 3>& magnetic_field,
|
||||
const blitz::TinyVector<double, 3>& electric_field) const {
|
||||
return blitz::cross(magnetic_field, electric_field) /
|
||||
const blitz::TinyVector<double, 3>& force_field_over_charge,
|
||||
const blitz::TinyVector<double, 3>& magnetic_field) const {
|
||||
return blitz::cross(force_field_over_charge, magnetic_field) /
|
||||
blitz::dot(magnetic_field, magnetic_field);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "generators/simulation_output_generator.h"
|
||||
#include "generators/species_generator.h"
|
||||
#include "generators/poisson_solver_generator.h"
|
||||
#include "generators/gravity_field_generator.h"
|
||||
|
||||
#include "tools/simulation_time.h"
|
||||
|
||||
@@ -39,6 +40,7 @@ Simulation::Simulation(std::string parameter_filename)
|
||||
void Simulation::init(Parameter& parameter) {
|
||||
magnetic_field_ = generator::magneticField(parameter);
|
||||
electric_field_ = generator::electricField(parameter);
|
||||
gravity_field_ = generator::gravityField(parameter);
|
||||
|
||||
DEBUG_LEVEL_0("Creating species.");
|
||||
generator::SpeciesBuilder builder(parameter);
|
||||
@@ -104,6 +106,7 @@ void Simulation::start() {
|
||||
int leftover_events = events_this_cpu;
|
||||
|
||||
int num_cpu_syncs = 0;
|
||||
bool reset = false;
|
||||
while (leftover_events > 0) {
|
||||
int events_of_cylcle = eventsOfCycle(event_stride, leftover_events);
|
||||
SIM_INFO("Leftover events on first cpu: " +
|
||||
@@ -121,7 +124,7 @@ void Simulation::start() {
|
||||
|
||||
SIM_INFO("Poisson step.");
|
||||
SimulationTimer::eventStartPoint(std::string("PoissonStep"));
|
||||
poisson_solver_->solvePotential(chargedensity(), num_cpu_syncs);
|
||||
poisson_solver_->solvePotential(chargedensity(), num_cpu_syncs, reset);
|
||||
electric_field_->updateDynamicField(poisson_solver_->staticElectricField());
|
||||
|
||||
SimulationTimer::eventStopPoint(std::string("PoissonStep"));
|
||||
@@ -130,6 +133,20 @@ void Simulation::start() {
|
||||
SimulationTimer::eventStartPoint(std::string("Output"));
|
||||
output_->writeSimulationData(num_cpu_syncs, tracked_species_, poisson_solver_.get());
|
||||
SimulationTimer::eventStopPoint(std::string("Output"));
|
||||
|
||||
if(reset) {
|
||||
SIM_INFO("Reset density, current fields and deletions.");
|
||||
for(auto& pair : tracked_species_) {
|
||||
pair.second->dynamicDensityField()->resetDynamicDensityField();
|
||||
pair.second->lastSyncDensityField()->resetDynamicDensityField();
|
||||
|
||||
pair.second->currentCollector()->resetCurrentCollector();
|
||||
pair.second->lastSyncCurrentCollector()->resetCurrentCollector();
|
||||
|
||||
pair.second->deletionLogger()->resetDeletionLogger();
|
||||
pair.second->lastSyncDeletionLogger()->resetDeletionLogger();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +211,7 @@ void Simulation::processUntilTermination(
|
||||
|
||||
SimulationTimer::eventStartPoint(std::string("Mover"));
|
||||
particle.specie()->mover()->move(&particle, mfp_m, electric_field_.get(),
|
||||
magnetic_field_.get());
|
||||
magnetic_field_.get(), gravity_field_.get());
|
||||
SimulationTimer::eventStopPoint(std::string("Mover"));
|
||||
|
||||
bool was_reflected = false;
|
||||
|
||||
@@ -13,3 +13,7 @@ void Timer::increaseTimestep(double time_s) {
|
||||
void Timer::setTime(double time_s) {
|
||||
current_time_s_ = time_s;
|
||||
}
|
||||
|
||||
void Timer::resetTime() {
|
||||
setTime(0.);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user