1 Commits
Author SHA1 Message Date
Jonas Kellerer 71dc3f4ada Merge branch 'develop' 2022-11-11 13:42:46 +01:00
15 changed files with 427 additions and 420 deletions
+2 -7
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)))[-1, :]
return (np.sum(particles, axis=(1)) / np.sum(areas_in_r, axis=(1)))[-2, :]
def densityVsZ(filename, path_to_species, output_period="LastSyncPeriod"):
@@ -212,19 +212,14 @@ 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, plot_instructions={}):
def plotAllSpectrumAtZ(filename, z_position, output_period, specie_keys, output_folder):
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))
@@ -1,34 +0,0 @@
{
"DriftVelocityExample1": {
"DriftVelocity": {
"VectorField": {
"VectorFieldFunctionInZ": {
"zFunction": {
"Product": {
"fi": {
"Constant": {
"constant": 1
}
},
"fj": {
"Constant": {
"constant": 1
}
},
"fk": {
"Constant": {
"constant": 1
}
}
}
}
}
}
}
},
"DriftVelocityExample2": {
"null": {}
}
}
@@ -1,20 +0,0 @@
{
"EnergyDistributionFunctionExample1": {
"MaxwellBoltzmann": {
"Temperature": {
"value": 80,
"unit": "K"
}
}
},
"EnergyDistributionFunctionExample2": {
"TritiumBetaDecay": {}
},
"EnergyDistributionFunctionExample3": {
"Constant": {
"constant": {
"value": 1
}
}
}
}
+95 -65
View File
@@ -1,74 +1,104 @@
{
"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
}
}
]
},
"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
}
"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
}
},
"3dto1D examples": {
"f1": {
"Constant3D": {
"constant": 2
"f2": {
"Constant": {
"constant": 1
}
},
"f3": {
"Product": [
{
"Constant": {
"constant": 2
}
},
{
"Constant": {
"constant": 3
}
}
},
"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 }
]
},
"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
}
}
}
}
}
}
}
}
@@ -141,16 +141,6 @@
"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"
}
@@ -182,11 +172,6 @@
"PredefinedFunction": "TpT2_clustering_tertiary_ascendion_pasil"
}
},
"recombination_example1": {
"Type": "Recombination",
"Target": "e-",
"CrossSection": "eT2p_recombination_janev"
},
"free_movement_example": {
"Type": "FreeMovement"
}
@@ -222,11 +207,6 @@
"Isotropic": {}
}
},
"recombination_example1": {
"Type": "Recombination",
"Target": "e-",
"CrossSection": "eT3p_recombination_janev"
},
"free_movement_example": {
"Type": "FreeMovement"
}
-18
View File
@@ -1,18 +0,0 @@
{
"MoverExample1":{
"Boris": {
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
}
}
},
"MoverExample2":{
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
}
}
}
}
@@ -2,21 +2,21 @@
"GlobalPositionBinning": {
"CylinderBinning": {
"Radial": {
"NumberOfBins": 5,
"NumberOfBins": 15,
"MaxRadius": {
"value": 4.5,
"unit": "cm"
}
},
"Longitudinal": {
"NumberOfBins": 166,
"NumberOfBins": 1657,
"MaxLength": {
"value": 1657,
"unit": "cm"
}
},
"Azimuthal": {
"NumberOfBins": 1
"NumberOfBins": 4
}
}
},
@@ -56,11 +56,11 @@
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/densityDistributions/T2",
"Filename": "T2_n_vs_z_kuckert_approximated_relative.h5"
"Filename": "T2_n_vs_z_kuckert_approximated.h5"
},
"xValuesKey": "/z_position(m)",
"yValuesKey": "/n(m3)",
"prefactor": 6.337599E19
"prefactor": 1E20
}
}
}
@@ -125,10 +125,11 @@
"e-": {
"ParticleType": "electron",
"Mover": {
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-12,
"unit": "s"
}
}
},
@@ -209,7 +210,7 @@
"CompositeAngleDistribution": {
"LowerDistribution": {
"Isotropic": {}
},
},
"HigherDistribution": {
"AngleDistributionFromFile": {
"PathToH5": {
@@ -347,17 +348,18 @@
"T2+": {
"ParticleType": "T2+",
"Mover": {
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 10,
"value": 1,
"unit": "s"
},
"BoundaryGeometry": {
@@ -439,17 +441,18 @@
"T+": {
"ParticleType": "T+",
"Mover": {
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 10,
"value": 1,
"unit": "s"
},
"BoundaryGeometry": {
@@ -542,17 +545,18 @@
"T3+": {
"ParticleType": "T3+",
"Mover": {
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 10,
"value": 1,
"unit": "s"
},
"BoundaryGeometry": {
@@ -690,7 +694,7 @@
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/densityDistributions/T2",
"Filename": "T2_n_vs_z_kuckert_approximated_relative.h5"
"Filename": "T2_n_vs_z_kuckert_approximated.h5"
},
"xValuesKey": "/z_position(m)",
"yValuesKey": "/n(m3)",
@@ -753,7 +757,7 @@
}
},
"Activity": {
"value": 1E14,
"value": 1E15,
"unit": "Bq"
}
},
@@ -791,8 +795,15 @@
"VectorField": {
"VectorFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2.5
"PiecewiseLinearFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/magneticField/Kassiopeia",
"Filename": "B_vs_z_kassiopeia_approximated.h5"
},
"xValuesKey": "/z_position(m)",
"yValuesKey": "/B(T)",
"prefactor": 1
}
}
}
@@ -802,12 +813,12 @@
"UseInSimulation": "false"
},
"Simulation": {
"SimulatedEvents": 10000000,
"EventStride": 1000
"SimulatedEvents": 1000000,
"EventStride": 10
},
"Output": {
"folder": "output",
"filename": "katrin",
"filename": "karl_output",
"DensityFields": {
"Species": "all",
"Intervall": 1,
-17
View File
@@ -1,17 +0,0 @@
{
"ReflectorExample1": {
"Reflector": {
"ReflectorDPS": {
"position_z": {
"value": 1657,
"unit": "cm"
}
}
}
},
"ReflectorExample2": {
"Reflector": {
"NoReflector": {}
}
}
}
+15
View File
@@ -0,0 +1,15 @@
{
"Example1": {
"Reflector": {
"NoReflector": {}
}
},
"Example2": {
"ReflectorDPS": {
"position_z": {
"value": 1600,
"unit": "cm"
}
}
}
}
@@ -1,9 +1,11 @@
{
"ScalarFieldsExample1": {
"ScalarFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
"ScalarFields": {
"field1": {
"ScalarFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
}
}
}
}
@@ -1,23 +0,0 @@
{
"TerminatorExample1": {
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 1,
"unit": "s"
},
"BoundaryGeometry": {
"Cylinder": {
"Radius": {
"value": 4.5,
"unit": "cm"
},
"Height": {
"value": 1657,
"unit": "cm"
}
}
}
}
}
}
+185 -85
View File
@@ -2,7 +2,7 @@
"GlobalPositionBinning": {
"CylinderBinning": {
"Radial": {
"NumberOfBins": 1,
"NumberOfBins": 15,
"MaxRadius": {
"value": 4.5,
"unit": "cm"
@@ -16,7 +16,7 @@
}
},
"Azimuthal": {
"NumberOfBins": 1
"NumberOfBins": 4
}
}
},
@@ -55,21 +55,23 @@
"PiecewiseLinear": {
"xValues": [
0,
7.4999,
7.5,
8.5,
8.5001,
1.43,
3,
8,
13,
14.57,
16
],
"yValues": [
0,
0,
5E-4,
0.002,
0.02,
1,
1,
0,
0
0.02,
0.002,
5E-4
],
"prefactor": 1E22
"prefactor": 1E20
}
}
}
@@ -112,8 +114,20 @@
}
},
"fk": {
"Constant": {
"constant": 0
"PiecewiseLinear": {
"xValues": [
0,
7.99,
8.01,
16
],
"yValues": [
-100,
-100,
100,
100
],
"prefactor": 1
}
}
}
@@ -127,10 +141,11 @@
"e-": {
"ParticleType": "electron",
"Mover": {
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-12,
"unit": "s"
}
}
},
@@ -154,7 +169,12 @@
}
},
"Reflector": {
"NoReflector": {}
"ReflectorDPS": {
"position_z": {
"value": 1600,
"unit": "cm"
}
}
},
"DensityField": {
"DynamicDensityField": {
@@ -171,7 +191,7 @@
"unit": "eV"
},
"MaxEnergy": {
"value": 1E2,
"value": 20E3,
"unit": "eV"
}
}
@@ -196,32 +216,47 @@
}
},
"Interactions": {
"free": {
"Type": "FreeMovement"
},
"elastic": {
"Type": "ElasticScattering",
"CrossSection": {
"1dFunction": {
"Constant": {
"constant": 1.412E-19
}
}
"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+"
}
}
},
"T+": {
"ParticleType": "T+",
"T2+": {
"ParticleType": "T2+",
"Mover": {
"Drift": {
"MaximalMovedDistance": {
"value": 0.001,
"unit": "m"
"Boris": {
"BorisStepsPerMovementCylce": 10,
"MaximalTimestepLength": {
"value": 1E-8,
"unit": "s"
}
}
},
@@ -287,23 +322,87 @@
}
},
"Interactions": {
"free": {
"name1": {
"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"
}
}
},
"Terminator": {
"MaximumInteractions": 1E6,
"MaxTimeAlive": {
"value": 1,
"unit": "s"
},
"BoundaryGeometry": {
"Cylinder": {
"Radius": {
"value": 4.5,
"unit": "cm"
},
"Height": {
"value": 1600,
"unit": "cm"
}
}
}
},
"Reflector": {
"NoReflector": {}
},
"DensityField": {
"DynamicDensityField": {
"PositionBinning": {
"CreateSameAs": [
"GlobalPositionBinning"
]
},
"EnergyBinning": {
"Type": "Logarithmic",
"NumberOfBins": 100,
"MinEnergy": {
"value": 1E-6,
"unit": "eV"
},
"MaxEnergy": {
"value": 1E3,
"unit": "eV"
}
}
}
},
"VelocityDistribution": {
"null": {}
},
"DriftVelocity": {
"null": {}
},
"Loggers": {
"Deletion": {
"Type": "all"
}
},
"CurrentCollector": {
"PositionBinning": {
"CreateSameAs": [
"GlobalPositionBinning"
]
}
},
"Interactions": {
"name1": {
"Type": "FreeMovement"
}
}
}
}
@@ -315,24 +414,12 @@
"CreationVelocityDistribution": {
"VelocityDistributionFromFunction": {
"VelocityDistributionFunction": {
"DirectedDistribution": {
"IsotropicDistribution": {
"EnergyDistributionFunction": {
"Constant": {
"constant": {
"value": 8E-3,
"unit": "eV"
}
}
"TritiumBetaDecay": {}
},
"Mass": {
"FromParticleType": "electron"
},
"Direction": {
"vector": [
0,
0,
-1
]
}
}
}
@@ -340,28 +427,21 @@
}
},
"specie2": {
"TrackedSpecieName": "T+",
"TrackedSpecieName": "T2+",
"CreationVelocityDistribution": {
"VelocityDistributionFromFunction": {
"VelocityDistributionFunction": {
"DirectedDistribution": {
"IsotropicDistribution": {
"EnergyDistributionFunction": {
"Constant": {
"constant": {
"value": 20E-2,
"unit": "eV"
"MaxwellBoltzmann": {
"Temperature": {
"value": 80,
"unit": "K"
}
}
},
"Mass": {
"FromParticleType": "T+"
},
"Direction": {
"vector": [
0,
0,
-1
]
"FromParticleType": "T2"
}
}
}
@@ -385,8 +465,26 @@
}
},
"fk": {
"Constant": {
"constant": 0.5
"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
}
}
}
@@ -395,7 +493,7 @@
},
"DensityLimit": {
"min": 0,
"max": 1
"max": 1E15
},
"PositionLimits": {
"rPosition": {
@@ -407,8 +505,8 @@
"max": 6.28318530718
},
"zPosition": {
"min": 7.94,
"max": 7.96
"min": 0,
"max": 16.0
}
}
},
@@ -476,8 +574,8 @@
"UseInSimulation": "false"
},
"Simulation": {
"SimulatedEvents": 100,
"EventStride": 100
"SimulatedEvents": 1,
"EventStride": 1
},
"Output": {
"folder": "output",
@@ -490,13 +588,15 @@
"CurrentBorders": {
"Species": [
"e-",
"T+"
"T2+"
],
"Intervall": "EachSync",
"OverwriteLast": "true"
},
"DeletionLogger": {
"Species": "all",
"Species": [
"all"
],
"Intervall": "EachSync",
"OverwriteLast": "true"
}
+36 -30
View File
@@ -1,39 +1,45 @@
{
"VectorfieldExample1": {
"VectorFieldConstant": {
"Constant": {
"vector": [ 1, 2, 3]
}
}
},
"VectorfieldExample2": {
"VectorFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
"VectorFields": {
"field1": {
"VectorFieldConstant": {
"Constant": {
"vector": [
1,
2,
3
]
}
}
}
},
"VectorfieldExample3": {
"VectorFieldFromArray": {
"ReadArrayFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/velocity/distributions",
"Filename": "drift_velocity.h5"
},
"field2": {
"VectorFieldFunctionInZ": {
"zFunction": {
"Constant3D": {
"constant": 2
}
}
}
},
"field3": {
"VectorFieldFromArray": {
"ReadArrayFromFile": {
"PathToH5": {
"Type": "RelativeToHomebase",
"RelativePath": "data/velocity/distributions",
"Filename": "drift_velocity.h5"
},
"Keys": [
"/vr",
"/vphi",
"/vz"
]
},
"Keys": [
"/vr",
"/vphi",
"/vz"
]
},
"Radius": 0.045,
"Length": 16
"Radius": 0.045,
"Length": 16
}
}
},
"VectorfieldExample4": {
"field4": {
"VectorFieldFromArray": {
"ReadArrayFromFile": {
"PathToH5": {
@@ -1,35 +0,0 @@
{
"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"
}
}
}
}
+44 -29
View File
@@ -135,6 +135,23 @@ 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_);
@@ -179,6 +196,8 @@ 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);
@@ -188,6 +207,15 @@ 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);
@@ -197,43 +225,30 @@ 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();
if (v_perp_norm > 0.) {
const double gyro_radius = particle->mass_kg() * v_perp_norm /
(B_norm * std::abs(particle->charge_C()));
const blitz::TinyVector<double, 3> v_perp_rotated =
kinematic::rotateVector(v_perp, v_parallel, total_rotation_angle);
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->velocity(
CartesianVector(v_parallel + v_perp_rotated + dv_electric));
particle->increaseTimeAlive(timestep);
particle->increaseTimeInBin(timestep);