Vlasiator ebf0dd394 on dev (v5.4.0 + 1054 commits)
Loading...
Searching...
No Matches
scenario.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This file is part of Vlasiator.
4 * Copyright 2010-2016 Finnish Meteorological Institute
5 *
6 * For details of usage, see the COPYING file and read the "Rules of the Road"
7 * at http://www.physics.helsinki.fi/vlasiator/
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23#include <vector>
24#include <map>
25#include "particles.h"
26#include "particleparameters.h"
27#include "field.h"
28#include "histogram.h"
29
30// A "Scenario" describes one possible class of simulation setup, and
31// Output quantities we are interested in.
32// There are multiple different ways in which particles can be used on
33// vlasiator data, this one abstracts these ways.
34
35struct Scenario {
36
37 // Fill in the initial particles, given electromagnetic- and velocity fields
38 // Further parameters, depending on the scenario, are given by the parameter object
40
41 // Do something when a new input timestep has been opened
42 virtual void newTimestep(int input_file_counter, int step, double time, ParticleContainer& particles, Field& E,
43 Field& B, Field& V) {};
44
45 // Modify or analyze particle behaviour before they are moved by the particle pusher.
46 virtual void beforePush(ParticleContainer& particles, Field& E, Field& B, Field& V) {};
47
48 // Modify or analzye particle behaviour after they are moved by the particle pusher
49 virtual void afterPush(int step, double time, ParticleContainer& particles, Field& E, Field& B, Field& V) {};
50
51 // Analyze the final state and / or write output
52 virtual void finalize(ParticleContainer& particles, Field& E, Field& B, Field& V) {};
53
54 // Flags specifying which fields are required for this scenario
55 bool needV; // Velocity field (it's always available for initialization)
56
57 Scenario() : needV(false) {};
58};
59
60
61
62
63
64// Specific scenarios below here
65
66// Trace a single particle, it's initial position and velocity given in the parameter file
69 virtual void afterPush(int step, double time, ParticleContainer& particles, Field& E, Field& B, Field& V);
70
72};
73
74// Sample a bunch of particles from a distribution, create them at a given point, then trace them
77 void newTimestep(int input_file_counter, int step, double time, ParticleContainer& particles, Field& E, Field& B,
78 Field& V);
79 void finalize(ParticleContainer& particles, Field& E, Field& B, Field& V);
80
82};
83
84// Inject particles in the tail continuously, see where they precipitate
86 void newTimestep(int input_file_counter, int step, double time, ParticleContainer& particles, Field& E, Field& B,
87 Field& V);
88 void afterPush(int step, double time, ParticleContainer& particles, Field& E, Field& B, Field& V);
89
91};
92
93// For interactive usage from analysator: read positions and velocities from stdin, push those particles.
96 void newTimestep(int input_file_counter, int step, double time, ParticleContainer& particles, Field& E, Field& B,
97 Field& V);
99};
100
101// Analyzation of shock reflectivity in radial IMF runs
103
106
107 void newTimestep(int input_file_counter, int step, double time, ParticleContainer& particles, Field& E, Field& B,
108 Field& V);
109 void afterPush(int step, double time, ParticleContainer& particles, Field& E, Field& B, Field& V);
110 void finalize(ParticleContainer& particles, Field& E, Field& B, Field& V);
111
113 transmitted(200,300, Vec2d(ParticleParameters::reflect_start_y,ParticleParameters::start_time),
114 Vec2d(ParticleParameters::reflect_stop_y,ParticleParameters::end_time)),
115 reflected(200,300, Vec2d(ParticleParameters::reflect_start_y,ParticleParameters::start_time),
116 Vec2d(ParticleParameters::reflect_stop_y,ParticleParameters::end_time)) {
117 needV= true;
118 }
119};
120
121// Initialize particles on a plane in front of the shock, track their precipitation upstream or downstream
123 FILE * traFile;
124 FILE * refFile;
125
127 void newTimestep(int input_file_counter, int step, double time, ParticleContainer& particles, Field& E, Field& B,
128 Field& V);
129 void afterPush(int step, double time, ParticleContainer& particles, Field& E, Field& B, Field& V);
130 void finalize(ParticleContainer& particles, Field& E, Field& B, Field& V);
131
133};
134
135template<typename T> Scenario* createScenario() {
136 return new T;
137}
138
139Scenario* createScenario(std::string name);
Numerical propagation V
Definition Dispersion.m:98
#define Vec2d
Definition histogram.h:29
std::vector< Particle, aligned_allocator< Particle, 32 > > ParticleContainer
Definition particles.h:45
Scenario * createScenario()
Definition scenario.h:135
Definition field.h:34
virtual void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.h:52
virtual void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.h:49
virtual void beforePush(ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.h:46
virtual void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.h:42
Scenario()
Definition scenario.h:57
bool needV
Definition scenario.h:55
virtual ParticleContainer initialParticles(Field &E, Field &B, Field &V)
Definition scenario.h:39
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:189
ParticleContainer initialParticles(Field &E, Field &B, Field &V)
Definition scenario.cpp:170
void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:93
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:84
ParticleContainer initialParticles(Field &E, Field &B, Field &V)
Definition scenario.cpp:57
void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:358
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:349
void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:409
ParticleContainer initialParticles(Field &E, Field &B, Field &V)
Definition scenario.cpp:307
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:134
void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:97
void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:251
void newTimestep(int input_file_counter, int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:200
LinearHistogram2D reflected
Definition scenario.h:105
void finalize(ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:297
LinearHistogram2D transmitted
Definition scenario.h:104
virtual void afterPush(int step, double time, ParticleContainer &particles, Field &E, Field &B, Field &V)
Definition scenario.cpp:45
ParticleContainer initialParticles(Field &E, Field &B, Field &V)
Definition scenario.cpp:32