4 Commits
15 changed files with 426 additions and 433 deletions
+7 -2
View File
@@ -166,7 +166,7 @@ def tubeCurrentVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
areas_in_r = radialAreas(filename, path_to_species)
current_in_r = radialCurrent(filename, path_to_species, output_period)
particles = current_in_r * areas_in_r
return (np.sum(particles, axis=(1)) / np.sum(areas_in_r, axis=(1)))[-2, :]
return (np.sum(particles, axis=(1)) / np.sum(areas_in_r, axis=(1)))[-1, :]
def densityVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
@@ -212,14 +212,19 @@ def plotSpectrumAtZ(filename, path_to_species, z_position, plot_axis, output_per
r"Diff. Density $\frac{\mathrm{d}n_e}{\mathrm{d}\log_{10}E}$ $\left(\frac{1}{\mathrm{m}^{3} \log_{10}(\mathrm{eV})}\right)$")
def plotAllSpectrumAtZ(filename, z_position, output_period, specie_keys, output_folder):
def plotAllSpectrumAtZ(filename, z_position, output_period, specie_keys, output_folder, plot_instructions={}):
pst.setRcParams()
fig, ax = plt.subplots(figsize=pst.set_size('thesis'))
for key in specie_keys:
plotSpectrumAtZ(filename, key, z_position, ax, output_period)
ax.set_facecolor('#e7e7e7ff')
ax.grid(color='white')
ax.legend()
if "xlim" in plot_instructions.keys():
ax.set_xlim(plot_instructions["xlim"])
if "ylim" in plot_instructions.keys():
ax.set_ylim(plot_instructions["ylim"])
fig.savefig(output_folder +
"/spectrum_at_z={}_at_period={}.pdf".format(z_position, output_period))
+34
View File
@@ -0,0 +1,34 @@
{
"DriftVelocityExample1": {
"DriftVelocity": {
"VectorField": {
"VectorFieldFunctionInZ": {
"zFunction": {
"Product": {
"fi": {
"Constant": {
"constant": 1
}
},
"fj": {
"Constant": {
"constant": 1
}
},
"fk": {
"Constant": {
"constant": 1
}
}
}
}
}
}
}
},
"DriftVelocityExample2": {
"null": {}
}
}
@@ -0,0 +1,20 @@
{
"EnergyDistributionFunctionExample1": {
"MaxwellBoltzmann": {
"Temperature": {
"value": 80,
"unit": "K"
}
}
},
"EnergyDistributionFunctionExample2": {
"TritiumBetaDecay": {}
},
"EnergyDistributionFunctionExample3": {
"Constant": {
"constant": {
"value": 1
}
}
}
}
+64 -94
View File
@@ -1,104 +1,74 @@
{
"Functions": {
"1Dto1D examples": {
"f1": {
"PiecewiseLinear": {
"xValues": [
0,
1.43,
3,
8,
13,
14.57,
16
],
"yValues": [
5E-4,
0.002,
0.02,
1,
0.02,
0.002,
5E-4
],
"prefactor": 1
}
},
"f2": {
"Constant": {
"constant": 1
}
},
"f3": {
"Product": [
{
"Constant": {
"constant": 2
"Functions": {
"1Dto1D examples": {
"f1": {
"PiecewiseLinear": {
"xValues": [0, 1.43, 3],
"yValues": [5E-4, 0.002, 0.02],
"prefactor": 1
}
},
"f2": {
"Constant": {
"constant": 1
}
},
"f3": {
"Product": [
{
"Constant": {
"constant": 2
}
},
{
"Constant": {
"constant": 3
}
}
},
{
"Constant": {
"constant": 3
}
]
},
"f4": {
"PiecewiseLinearFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "path/relative",
"Filename": "data.h5"
},
"xValuesKey": "/xvalues",
"yValuesKey": "/yvalues",
"prefactor": 1
}
},
"f5": {
"PiecewiseLinearFromFile": {
"PathToH5": {
"Type": "AbsolutPath",
"RelativePath": "/some/absolut/path",
"Filename": "data.h5"
},
"xValuesKey": "/xvalues",
"yValuesKey": "/yvalues",
"prefactor": 1
}
]
},
"f4": {
"PiecewiseLinearFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/velocityDistributions/T2_vz/KuckertPaper",
"Filename": "T2_vz_vs_z_kuckert_approximated.h5"
},
"xValuesKey": "/z_position(m)",
"yValuesKey": "/vz(ms)",
"prefactor": 1
}
}
},
"3dto1D examples": {
"f1": {
"Constant3D": {
"constant": 2
}
},
"f2": {
"Product": {
"fi": {
"Constant": {
"constant": 2
}
},
"fj": {
"Constant": {
"constant": 2
}
},
"fk": {
"PiecewiseLinear": {
"xValues": [
0,
1.43,
3,
8,
13,
14.57,
16
],
"yValues": [
5E-4,
0.002,
0.02,
1,
0.02,
0.002,
5E-4
],
"prefactor": 1
"3dto1D examples": {
"f1": {
"Constant3D": {
"constant": 2
}
},
"f2": {
"Product": {
"fi": { "Constant": {"constant": 2 }},
"fj": { "Constant": {"constant": 2 }},
"fk": { "PiecewiseLinear": {
"xValues": [0, 1.43, 3],
"yValues": [5E-4, 0.002, 0.02],
"prefactor": 1 }
}
}
}
}
}
}
}
}
@@ -141,6 +141,16 @@
"Target": "T2",
"ExcitationState": "england_rotational_j1_to_j3"
},
"recombination_example1": {
"Type": "Recombination",
"Target": "T2+",
"CrossSection": "eT2p_recombination_janev"
},
"recombination_example2": {
"Type": "Recombination",
"Target": "T3+",
"CrossSection": "eT3p_recombination_janev"
},
"free_movement_example": {
"Type": "FreeMovement"
}
@@ -172,6 +182,11 @@
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
}
},
"recombination_example1": {
"Type": "Recombination",
"Target": "e-",
"CrossSection": "eT2p_recombination_janev"
},
"free_movement_example": {
"Type": "FreeMovement"
}
@@ -207,6 +222,11 @@
"Isotropic": {}
}
},
"recombination_example1": {
"Type": "Recombination",
"Target": "e-",
"CrossSection": "eT3p_recombination_janev"
},
"free_movement_example": {
"Type": "FreeMovement"
}
+18
View File
@@ -0,0 +1,18 @@
{
"MoverExample1":{
"Boris": {
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
}
}
},
"MoverExample2":{
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
}
}
@@ -2,21 +2,21 @@
"GlobalPositionBinning": {
"CylinderBinning": {
"Radial": {
"NumberOfBins": 15,
"NumberOfBins": 5,
"MaxRadius": {
"value": 4.5,
"unit": "cm"
}
},
"Longitudinal": {
"NumberOfBins": 1657,
"NumberOfBins": 166,
"MaxLength": {
"value": 1657,
"unit": "cm"
}
},
"Azimuthal": {
"NumberOfBins": 4
"NumberOfBins": 1
}
}
},
@@ -56,11 +56,11 @@
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/densityDistributions/T2",
"Filename": "T2_n_vs_z_kuckert_approximated.h5"
"Filename": "T2_n_vs_z_kuckert_approximated_relative.h5"
},
"xValuesKey": "/z_position(m)",
"yValuesKey": "/n(m3)",
"prefactor": 1E20
"prefactor": 6.337599E19
}
}
}
@@ -125,11 +125,10 @@
"e-": {
"ParticleType": "electron",
"Mover": {
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-12,
"unit": "s"
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
},
@@ -210,7 +209,7 @@
"CompositeAngleDistribution": {
"LowerDistribution": {
"Isotropic": {}
},
},
"HigherDistribution": {
"AngleDistributionFromFile": {
"PathToH5": {
@@ -348,18 +347,17 @@
"T2+": {
"ParticleType": "T2+",
"Mover": {
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 1,
"value": 10,
"unit": "s"
},
"BoundaryGeometry": {
@@ -441,18 +439,17 @@
"T+": {
"ParticleType": "T+",
"Mover": {
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 1,
"value": 10,
"unit": "s"
},
"BoundaryGeometry": {
@@ -545,18 +542,17 @@
"T3+": {
"ParticleType": "T3+",
"Mover": {
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 1,
"value": 10,
"unit": "s"
},
"BoundaryGeometry": {
@@ -694,7 +690,7 @@
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/densityDistributions/T2",
"Filename": "T2_n_vs_z_kuckert_approximated.h5"
"Filename": "T2_n_vs_z_kuckert_approximated_relative.h5"
},
"xValuesKey": "/z_position(m)",
"yValuesKey": "/n(m3)",
@@ -757,7 +753,7 @@
}
},
"Activity": {
"value": 1E15,
"value": 1E14,
"unit": "Bq"
}
},
@@ -795,15 +791,8 @@
"VectorField": {
"VectorFieldFunctionInZ": {
"zFunction": {
"PiecewiseLinearFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/magneticField/Kassiopeia",
"Filename": "B_vs_z_kassiopeia_approximated.h5"
},
"xValuesKey": "/z_position(m)",
"yValuesKey": "/B(T)",
"prefactor": 1
"Constant3D": {
"constant": 2.5
}
}
}
@@ -813,12 +802,12 @@
"UseInSimulation": "false"
},
"Simulation": {
"SimulatedEvents": 1000000,
"EventStride": 10
"SimulatedEvents": 10000000,
"EventStride": 1000
},
"Output": {
"folder": "output",
"filename": "karl_output",
"filename": "katrin",
"DensityFields": {
"Species": "all",
"Intervall": 1,
+17
View File
@@ -0,0 +1,17 @@
{
"ReflectorExample1": {
"Reflector": {
"ReflectorDPS": {
"position_z": {
"value": 1657,
"unit": "cm"
}
}
}
},
"ReflectorExample2": {
"Reflector": {
"NoReflector": {}
}
}
}
@@ -1,15 +0,0 @@
{
"Example1": {
"Reflector": {
"NoReflector": {}
}
},
"Example2": {
"ReflectorDPS": {
"position_z": {
"value": 1600,
"unit": "cm"
}
}
}
}
@@ -1,11 +1,9 @@
{
"ScalarFields": {
"field1": {
"ScalarFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
}
"ScalarFieldsExample1": {
"ScalarFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
}
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"TerminatorExample1": {
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 1,
"unit": "s"
},
"BoundaryGeometry": {
"Cylinder": {
"Radius": {
"value": 4.5,
"unit": "cm"
},
"Height": {
"value": 1657,
"unit": "cm"
}
}
}
}
}
}
+90 -190
View File
@@ -2,7 +2,7 @@
"GlobalPositionBinning": {
"CylinderBinning": {
"Radial": {
"NumberOfBins": 15,
"NumberOfBins": 1,
"MaxRadius": {
"value": 4.5,
"unit": "cm"
@@ -16,7 +16,7 @@
}
},
"Azimuthal": {
"NumberOfBins": 4
"NumberOfBins": 1
}
}
},
@@ -55,23 +55,21 @@
"PiecewiseLinear": {
"xValues": [
0,
1.43,
3,
8,
13,
14.57,
7.4999,
7.5,
8.5,
8.5001,
16
],
"yValues": [
5E-4,
0.002,
0.02,
0,
0,
1,
0.02,
0.002,
5E-4
1,
0,
0
],
"prefactor": 1E20
"prefactor": 1E22
}
}
}
@@ -114,20 +112,8 @@
}
},
"fk": {
"PiecewiseLinear": {
"xValues": [
0,
7.99,
8.01,
16
],
"yValues": [
-100,
-100,
100,
100
],
"prefactor": 1
"Constant": {
"constant": 0
}
}
}
@@ -141,122 +127,10 @@
"e-": {
"ParticleType": "electron",
"Mover": {
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-12,
"unit": "s"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 1,
"unit": "s"
},
"BoundaryGeometry": {
"Cylinder": {
"Radius": {
"value": 4.5,
"unit": "cm"
},
"Height": {
"value": 1600,
"unit": "cm"
}
}
}
},
"Reflector": {
"ReflectorDPS": {
"position_z": {
"value": 1600,
"unit": "cm"
}
}
},
"DensityField": {
"DynamicDensityField": {
"PositionBinning": {
"CreateSameAs": [
"GlobalPositionBinning"
]
},
"EnergyBinning": {
"Type": "Logarithmic",
"NumberOfBins": 100,
"MinEnergy": {
"value": 1E-6,
"unit": "eV"
},
"MaxEnergy": {
"value": 20E3,
"unit": "eV"
}
}
}
},
"VelocityDistribution": {
"null": {}
},
"DriftVelocity": {
"null": {}
},
"Loggers": {
"Deletion": {
"Type": "all"
}
},
"CurrentCollector": {
"PositionBinning": {
"CreateSameAs": [
"GlobalPositionBinning"
]
}
},
"Interactions": {
"elastic": {
"Type": "ElasticScattering",
"CrossSection": {
"PredefinedFunction": "eT2_elastic_scattering_constant"
},
"Target": "TritiumGas",
"ScatteringAngleDistribution": {
"Isotropic": {}
}
},
"janev_non_diss": {
"Type": "ElectronIonization",
"IonizationModel": "JanevNonDiss",
"Target": "TritiumGas",
"OutgoingElectron": "e-",
"OutgoingIon": "T2+"
},
"janev_diss_to_ground": {
"Type": "ElectronIonization",
"IonizationModel": "JanevDissToGround",
"Target": "TritiumGas",
"OutgoingElectron": "e-",
"OutgoingIon": "T+"
},
"janev_diss_to_first_excited": {
"Type": "ElectronIonization",
"IonizationModel": "JanevDissToFirstExcited",
"Target": "TritiumGas",
"OutgoingElectron": "e-",
"OutgoingIon": "T+"
}
}
},
"T2+": {
"ParticleType": "T2+",
"Mover": {
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
},
@@ -297,7 +171,7 @@
"unit": "eV"
},
"MaxEnergy": {
"value": 1E3,
"value": 1E2,
"unit": "eV"
}
}
@@ -322,19 +196,32 @@
}
},
"Interactions": {
"name1": {
"free": {
"Type": "FreeMovement"
},
"elastic": {
"Type": "ElasticScattering",
"CrossSection": {
"1dFunction": {
"Constant": {
"constant": 1.412E-19
}
}
},
"Target": "TritiumGas",
"ScatteringAngleDistribution": {
"Isotropic": {}
}
}
}
},
"T+": {
"ParticleType": "T+",
"Mover": {
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
},
@@ -400,8 +287,22 @@
}
},
"Interactions": {
"name1": {
"free": {
"Type": "FreeMovement"
},
"elastic": {
"Type": "ElasticScattering",
"CrossSection": {
"1dFunction": {
"Constant": {
"constant": 1.412E-19
}
}
},
"Target": "TritiumGas",
"ScatteringAngleDistribution": {
"Isotropic": {}
}
}
}
}
@@ -414,12 +315,24 @@
"CreationVelocityDistribution": {
"VelocityDistributionFromFunction": {
"VelocityDistributionFunction": {
"IsotropicDistribution": {
"DirectedDistribution": {
"EnergyDistributionFunction": {
"TritiumBetaDecay": {}
"Constant": {
"constant": {
"value": 8E-3,
"unit": "eV"
}
}
},
"Mass": {
"FromParticleType": "electron"
},
"Direction": {
"vector": [
0,
0,
-1
]
}
}
}
@@ -427,21 +340,28 @@
}
},
"specie2": {
"TrackedSpecieName": "T2+",
"TrackedSpecieName": "T+",
"CreationVelocityDistribution": {
"VelocityDistributionFromFunction": {
"VelocityDistributionFunction": {
"IsotropicDistribution": {
"DirectedDistribution": {
"EnergyDistributionFunction": {
"MaxwellBoltzmann": {
"Temperature": {
"value": 80,
"unit": "K"
"Constant": {
"constant": {
"value": 20E-2,
"unit": "eV"
}
}
},
"Mass": {
"FromParticleType": "T2"
"FromParticleType": "T+"
},
"Direction": {
"vector": [
0,
0,
-1
]
}
}
}
@@ -465,26 +385,8 @@
}
},
"fk": {
"PiecewiseLinear": {
"xValues": [
0,
1.43,
3,
8,
13,
14.57,
16
],
"yValues": [
5E-4,
0.002,
0.02,
1,
0.02,
0.002,
5E-4
],
"prefactor": 1E15
"Constant": {
"constant": 0.5
}
}
}
@@ -493,7 +395,7 @@
},
"DensityLimit": {
"min": 0,
"max": 1E15
"max": 1
},
"PositionLimits": {
"rPosition": {
@@ -505,8 +407,8 @@
"max": 6.28318530718
},
"zPosition": {
"min": 0,
"max": 16.0
"min": 7.94,
"max": 7.96
}
}
},
@@ -574,8 +476,8 @@
"UseInSimulation": "false"
},
"Simulation": {
"SimulatedEvents": 1,
"EventStride": 1
"SimulatedEvents": 100,
"EventStride": 100
},
"Output": {
"folder": "output",
@@ -588,15 +490,13 @@
"CurrentBorders": {
"Species": [
"e-",
"T2+"
"T+"
],
"Intervall": "EachSync",
"OverwriteLast": "true"
},
"DeletionLogger": {
"Species": [
"all"
],
"Species": "all",
"Intervall": "EachSync",
"OverwriteLast": "true"
}
+32 -38
View File
@@ -1,45 +1,39 @@
{
"VectorFields": {
"field1": {
"VectorFieldConstant": {
"Constant": {
"vector": [
1,
2,
3
]
}
}
},
"field2": {
"VectorFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
}
}
}
},
"field3": {
"VectorFieldFromArray": {
"ReadArrayFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/velocity/distributions",
"Filename": "drift_velocity.h5"
},
"Keys": [
"/vr",
"/vphi",
"/vz"
]
},
"Radius": 0.045,
"Length": 16
"VectorfieldExample1": {
"VectorFieldConstant": {
"Constant": {
"vector": [ 1, 2, 3]
}
}
},
"field4": {
"VectorfieldExample2": {
"VectorFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
}
}
}
},
"VectorfieldExample3": {
"VectorFieldFromArray": {
"ReadArrayFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/velocity/distributions",
"Filename": "drift_velocity.h5"
},
"Keys": [
"/vr",
"/vphi",
"/vz"
]
},
"Radius": 0.045,
"Length": 16
}
},
"VectorfieldExample4": {
"VectorFieldFromArray": {
"ReadArrayFromFile": {
"PathToH5": {
@@ -0,0 +1,35 @@
{
"VelocityDistributionFunctionExample1": {
"IsotropicDistribution": {
"EnergyDistributionFunction": {
"MaxwellBoltzmann": {
"Temperature": {
"value": 80,
"unit": "K"
}
}
},
"Mass": {
"FromParticleType": "T2"
}
}
},
"VelocityDistributionFunctionExample2": {
"DirectedDistribution": {
"EnergyDistributionFunction": {
"MaxwellBoltzmann": {
"Temperature": {
"value": 80,
"unit": "K"
}
}
},
"Direction": {
"vector": [0,0,1]
},
"Mass": {
"FromParticleType": "T2"
}
}
}
}
+29 -44
View File
@@ -135,23 +135,6 @@ void BorisMover::movementStep(
u_plus_z + (q * electric_field(2) * maximal_time_step_s_) / (2. * m);
const blitz::TinyVector<double, 3> u_new(u_new_x, u_new_y, u_new_z);
/*
Might be slower, but essentially the same code
const blitz::TinyVector<double, 3> u_minus =
v + (q * electric_field * maximal_time_step_s_) / (2. * m);
const double gamma = kinematic::relativisticGamma(u_minus);;
const blitz::TinyVector<double, 3> temp_1 =
(q * magnetic_field * maximal_time_step_s_) / (2. * m * gamma);
const blitz::TinyVector<double, 3> u_prime =
u_minus + (blitz::cross(u_minus, temp_1));
const blitz::TinyVector<double, 3> temp_2 =
(2. * temp_1) / (1. + (blitz::dot(temp_1, temp_1)));
const blitz::TinyVector<double, 3> u_plus =
u_minus + (blitz::cross(u_prime, temp_2));
const blitz::TinyVector<double, 3> u_new =
u_plus + (q * electric_field * maximal_time_step_s_) / (2. * m);
*/
particle->velocity(CartesianVector(u_new));
const CartesianCoordinate distance(u_new * maximal_time_step_s_);
@@ -196,8 +179,6 @@ void DriftMover::move(particle::Particle* particle,
const blitz::TinyVector<double, 3> B =
magnetic_field->value(old_position).cartesianEntries(old_position);
const double B_norm = kinematic::norm(B);
// Todo: add calculation of divB here
// use Kassiopeia paper for reference
const blitz::TinyVector<double, 3> v_parallel =
kinematic::parallelVector(old_velocity.cartesianEntries(), B);
@@ -207,15 +188,6 @@ void DriftMover::move(particle::Particle* particle,
kinematic::perpendicularVector(old_velocity.cartesianEntries(), B);
const double v_perp_norm = kinematic::norm(v_perp);
const double gyro_radius = particle->mass_kg() * v_perp_norm /
(B_norm * std::abs(particle->charge_C()));
const blitz::TinyVector<double, 3> velocity_normal =
(-1) * blitz::cross(v_parallel, v_perp);
const blitz::TinyVector<double, 3> offset_to_gyro_center =
gyro_radius * velocity_normal / kinematic::norm(velocity_normal);
const blitz::TinyVector<double, 3> v_drift = driftVelocity(B, E);
const double v_drift_norm = kinematic::norm(v_drift);
@@ -225,30 +197,43 @@ void DriftMover::move(particle::Particle* particle,
const blitz::TinyVector<double, 3> movement_parallel =
v_parallel * timestep;
const blitz::TinyVector<double, 3> movement_drift = v_drift * timestep;
const double gyro_frequency =
particle->charge_C() * B_norm / particle->mass_kg();
const double total_rotation_angle = gyro_frequency * timestep;
const blitz::TinyVector<double, 3> movement_around_gyro_center =
kinematic::rotateVector(offset_to_gyro_center, v_parallel,
total_rotation_angle) -
offset_to_gyro_center;
particle->move(CartesianCoordinate(movement_parallel + movement_drift +
movement_around_gyro_center));
const blitz::TinyVector<double, 3> E_parallel =
kinematic::parallelVector(E, B);
const blitz::TinyVector<double, 3> dv_electric =
timestep * particle->charge_C() * E_parallel / particle->mass_kg();
const blitz::TinyVector<double, 3> v_perp_rotated =
kinematic::rotateVector(v_perp, v_parallel, total_rotation_angle);
if (v_perp_norm > 0.) {
const double gyro_radius = particle->mass_kg() * v_perp_norm /
(B_norm * std::abs(particle->charge_C()));
particle->velocity(
CartesianVector(v_parallel + v_perp_rotated + dv_electric));
const blitz::TinyVector<double, 3> velocity_normal =
(-1) * blitz::cross(B, v_perp);
const blitz::TinyVector<double, 3> offset_to_gyro_center =
gyro_radius * velocity_normal / kinematic::norm(velocity_normal);
const double gyro_frequency =
particle->charge_C() * B_norm / particle->mass_kg();
const double total_rotation_angle = gyro_frequency * timestep;
const blitz::TinyVector<double, 3> movement_around_gyro_center =
kinematic::rotateVector(offset_to_gyro_center, B,
total_rotation_angle) -
offset_to_gyro_center;
const blitz::TinyVector<double, 3> v_perp_rotated =
kinematic::rotateVector(v_perp, B, total_rotation_angle);
particle->move(CartesianCoordinate(movement_parallel + movement_drift +
movement_around_gyro_center));
particle->velocity(
CartesianVector(v_parallel + v_perp_rotated + dv_electric));
} else {
particle->move(CartesianCoordinate(movement_parallel + movement_drift));
particle->velocity(CartesianVector(v_parallel + dv_electric));
}
particle->increaseTimeAlive(timestep);
particle->increaseTimeInBin(timestep);