From fea00f9a0ae8ae4138d13e7b81f252ae03a63280 Mon Sep 17 00:00:00 2001 From: Christian Sendlinger Date: Thu, 16 May 2024 09:43:29 +0200 Subject: [PATCH] minor corrections, added example json file --- simulation_config/time_rest_testing.json | 536 +++++++++++++++++++++++ src/poisson_solver/poisson_solver.cpp | 2 +- src/simulation/simulation.cpp | 9 +- 3 files changed, 544 insertions(+), 3 deletions(-) create mode 100755 simulation_config/time_rest_testing.json diff --git a/simulation_config/time_rest_testing.json b/simulation_config/time_rest_testing.json new file mode 100755 index 0000000..9ee9ae3 --- /dev/null +++ b/simulation_config/time_rest_testing.json @@ -0,0 +1,536 @@ +{ + "GlobalPositionBinning": { + "CylinderBinning": { + "Radial": { + "NumberOfBins": 10, + "MaxRadius": { + "value": 5, + "unit": "cm" + } + }, + "Longitudinal": { + "NumberOfBins": 75, + "MaxLength": { + "value": 300, + "unit": "cm" + } + }, + "Azimuthal": { + "NumberOfBins": 1 + } + } + }, + "SourceGeometry": { + "Cylinder": { + "Radius": { + "value": 5, + "unit": "cm" + }, + "Height": { + "value": 300, + "unit": "cm" + } + } + }, + "Species": { + "Background": { + "TritiumGas": { + "ParticleType": "T", + "ConstantDensityField": { + "ScalarField": { + "ScalarFieldFunctionInZ": { + "zFunction": { + "Product": { + "fi": { + "Constant": { + "constant": 1 + } + }, + "fj": { + "Constant": { + "constant": 1 + } + }, + "fk": { + "Exponential": { + "scale": -7.1307e-4, + "prefactor": 1E17 + } + } + } + } + } + } + }, + "VelocityDistribution": { + "VelocityDistributionFromFunction": { + "VelocityDistributionFunction": { + "IsotropicDistribution": { + "EnergyDistributionFunction": { + "MaxwellBoltzmann": { + "Temperature": { + "value": 5, + "unit": "K" + } + } + }, + "Mass": { + "FromParticleType": "T" + } + } + } + } + }, + "DriftVelocity": { + "VectorField": { + "VectorFieldFunctionInZ": { + "zFunction": { + "Product": { + "fi": { + "Constant": { + "constant": 1 + } + }, + "fj": { + "Constant": { + "constant": 1 + } + }, + "fk": { + "PiecewiseLinear": { + "xValues": [ + 0, + 16 + ], + "yValues": [ + 0, + 0 + ], + "prefactor": 1 + } + } + } + } + } + } + } + } + }, + "Tracked": { + "e-": { + "ParticleType": "electron", + "Mover": { + "Drift": { + "MaximalMovedDistance": { + "value": 1e-3, + "unit": "m" + } + } + }, + "Terminator": { + "MaximumInteractions": 1E6, + "MaxTimeAlive": { + "value": 1, + "unit": "s" + }, + "BoundaryGeometry": { + "Cylinder": { + "Radius": { + "value": 5, + "unit": "cm" + }, + "Height": { + "value": 300, + "unit": "cm" + } + } + } + }, + "Reflector": { + "NoReflector": {} + }, + "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": { + "freeMovement": { + "Type": "FreeMovement" + }, + "elastic": { + "Type": "ElasticScattering", + "Target": "TritiumGas", + "CrossSection": { + "PredefinedFunction": "eT2_elastic_scattering_constant" + }, + "ScatteringAngleDistribution": { + "Isotropic": {} + } + } + } + }, + "T+": { + "ParticleType": "T+", + "Mover": { + "Drift":{ + "MaximalMovedDistance": { + "value": 1e-3, + "unit": "m" + } + } + }, + "Terminator": { + "MaximumInteractions": 1E6, + "MaxTimeAlive": { + "value": 1, + "unit": "s" + }, + "BoundaryGeometry": { + "Cylinder": { + "Radius": { + "value": 5, + "unit": "cm" + }, + "Height": { + "value": 300, + "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" + }, + "elastic": { + "Type": "ElasticScattering", + "Target": "TritiumGas", + "CrossSection": { + "PredefinedFunction": "eT2_elastic_scattering_constant" + }, + "ScatteringAngleDistribution": { + "Isotropic": {} + } + } + } + } + } + }, + "Injector": { + "CreatedSpecies": { + "specie1": { + "TrackedSpecieName": "e-", + "CreationVelocityDistribution": { + "VelocityDistributionFromFunction": { + "VelocityDistributionFunction": { + "DirectedDistribution": { + "EnergyDistributionFunction": { + "Constant": { + "constant": { + "value": 4.30867e-4, + "unit": "eV" + } + } + }, + "Mass": { + "FromParticleType": "electron" + }, + "Direction":{ + "vector": [1, 0, 1] + } + } + } + } + } + }, + "specie2": { + "TrackedSpecieName": "T+", + "CreationVelocityDistribution": { + "VelocityDistributionFromFunction": { + "VelocityDistributionFunction": { + "DirectedDistribution": { + "EnergyDistributionFunction": { + "Constant": { + "constant": { + "unit": "eV", + "value": 4.30867e-4 + } + } + }, + "Mass": { + "FromParticleType": "T" + }, + "Direction": { + "vector": [1, 0, 1] + } + } + } + } + } + } + }, + "EventPositionDistribution": { + "ScalarField": { + "ScalarFieldFunctionInZ": { + "zFunction": { + "Product": { + "fi": { + "Constant": { + "constant": 1 + } + }, + "fj": { + "Constant": { + "constant": 1 + } + }, + "fk": { + "PiecewiseLinear": { + "xValues": [0.0, 3.0], + "yValues": [1.0, 1.0], + "prefactor": 1E15 + } + } + } + } + } + }, + "DensityLimit": { + "min": 0, + "max": 1E15 + }, + "PositionLimits": { + "rPosition": { + "min": 0, + "max": 0.05 + }, + "phiPosition": { + "min": 0, + "max": 6.28318530718 + }, + "zPosition": { + "min": 0, + "max": 0.3 + } + } + }, + "MotherDriftVelocity": { + "VectorField": { + "VectorFieldConstant": { + "constant": { + "vector": [ + 0, + 0, + 0 + ] + }, + "unit": "m/s" + } + } + }, + "Activity": { + "value": 1e7, + "unit": "Bq" + } + }, + "ElectricField": { + "Background": { + "VectorField": { + "VectorFieldConstant": { + "constant": { + "vector": [ + 0, + 0, + 0 + ] + }, + "unit": "V/m" + } + } + }, + "Dynamic": { + "VectorField": { + "VectorFieldConstant": { + "constant": { + "vector": [ + 0, + 0, + 0 + ] + }, + "unit": "V/m" + } + } + } + }, + "MagneticField": { + "VectorField": { + "VectorFieldFunctionInZ": { + "zFunction": { + "Constant3D": { + "constant": 2.5 + } + } + } + }, + "GradientField": { + "VectorFieldFunctionInZ": { + "zFunction": { + "Constant3D": { + "constant": 0 + } + } + } + } + }, + "GravityField": { + "VectorField": { + "VectorFieldFunctionInZ": { + "zFunction": { + "Constant3D": { + "constant": -9.81 + } + } + } + } + }, + "PoissonSolver": { + "BoundaryGeometry": { + "CreateSameAs": ["SourceGeometry"] + }, + "PositionBinning": { + "CreateSameAs": [ + "GlobalPositionBinning" + ] + }, + "Boundary": { + "Top": { + "type": "neumann", + "value": 0 + }, + "Bottom": { + "type": "dirichlet", + "value": 0 + }, + "Hull": { + "type": "dirichlet", + "value": 0 + } + }, + "TargetAccuracy": 1e-6, + "NumCycles": 2e4, + "DoSolver": "true" + }, + "Simulation": { + "SimulatedEvents": 200000, + "EventStride": 5000, + "TimeResolutionEvents": 20000, + "commentTimeRes": "number of events over all cpus defining the timeresolution" + }, + "Output": { + "folder": "output", + "filename": "timerestest3", + "DensityFields": { + "Species": "all", + "Intervall": 1, + "OverwriteLast": "false" + }, + "CurrentBorders": { + "Species": [ + "e-", + "T+" + ], + "Intervall": "EachSync", + "OverwriteLast": "false" + }, + "DeletionLogger": { + "Species": "all", + "Intervall": "EachSync", + "OverwriteLast": "false" + }, + "PoissonSolver": { + "Intervall": "EachSync", + "OverwriteLast": "false" + } + }, + "RandomNumbers": { + "Seed": 1337 + } +} diff --git a/src/poisson_solver/poisson_solver.cpp b/src/poisson_solver/poisson_solver.cpp index 4c864dc..54ac242 100755 --- a/src/poisson_solver/poisson_solver.cpp +++ b/src/poisson_solver/poisson_solver.cpp @@ -82,7 +82,7 @@ PoissonSolver::PoissonSolver(GlobalBoundary bottom_boundary, void PoissonSolver::solvePotential( const blitz::Array charge_density, const bool solve) { - if (!(do_solver_) && !(solve)) { + if (!(do_solver_) || !(solve)) { return; } DEBUG_LEVEL_3("Interpolating chargedensity."); diff --git a/src/simulation/simulation.cpp b/src/simulation/simulation.cpp index c868f7a..8de1366 100755 --- a/src/simulation/simulation.cpp +++ b/src/simulation/simulation.cpp @@ -173,11 +173,16 @@ void Simulation::start() { pair.second->dynamicDensityField()->resetDynamicDensityField(); pair.second->lastSyncDensityField()->resetDynamicDensityField(); + // questionable if they need to be reset: + // + time res in current + // - ions very slow -> very unlikely that an ion crosses a boundary pair.second->currentCollector()->resetCurrentCollector(); pair.second->lastSyncCurrentCollector()->resetCurrentCollector(); - pair.second->deletionLogger()->resetDeletionLogger(); - pair.second->lastSyncDeletionLogger()->resetDeletionLogger(); + // do not need to be reset, since the time resolution considers the same + // set of particles + // pair.second->deletionLogger()->resetDeletionLogger(); + // pair.second->lastSyncDeletionLogger()->resetDeletionLogger(); } leftover_events_time_resolution = time_resolution_this_cpu; switch_active(active_queue_, non_active_queue_);