Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sub-grid model for pitch-angle diffusion #846

Open
wants to merge 122 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
e31d3b6
Created new branch for artificial diffusion
MaximeII Mar 4, 2021
436687f
Check if neighbour cell exists, skip if not.
MaximeII Mar 5, 2021
e25e184
Loop over directions. Put back abs.
MaximeII Mar 10, 2021
c010a39
Implemented cartesian diffusion
MaximeII Apr 15, 2021
26bdad0
Added comments
MaximeII Apr 15, 2021
f82d343
New implementation
MaximeII Apr 20, 2021
905793d
Corrected calculation of theta
MaximeII Apr 21, 2021
aa5b8fd
Updated evec calculations, add writing in txt file
MaximeII May 4, 2021
35787bd
Corrected theta calculations
MaximeII May 4, 2021
dacea45
Clean, changed Vec3d with std::vector
MaximeII Jul 5, 2021
a4ab8d5
Removed writing dfdt to array
MaximeII Aug 18, 2021
1d6f063
Commented unecessarry storage of data into arrays
MaximeII Aug 24, 2021
5752982
Modified Fluctuations project for bi-maxwellian
MaximeII Aug 31, 2021
8403b3b
Added CFL conditions
MaximeII Aug 31, 2021
26ab496
Corrected CFL condition
MaximeII Aug 31, 2021
d1cc9db
Added time loop for sub-stepping
MaximeII Aug 31, 2021
eab8088
Set sparsity threshold for empty cells
MaximeII Aug 31, 2021
0f4bfb1
typos in sparsity
MaximeII Aug 31, 2021
74a82eb
Added Rule for diffusion in Makefile
MaximeII Sep 3, 2021
643d33e
Forgot one Vx
MaximeII Sep 3, 2021
170d43b
Update Vorna make file for debugging. Geometrical avg for diffusion, …
MaximeII Sep 29, 2021
cfaf326
Added diffusion from mu-space
MaximeII Oct 8, 2021
9e1a61e
dded non-zero neighbours for derivatives
MaximeII Oct 15, 2021
aefacdc
Checked fcount instead of fmu
MaximeII Oct 21, 2021
16d290a
Previous commit but correctly this time
MaximeII Oct 21, 2021
ae9bcad
Handle edges correctly
MaximeII Oct 26, 2021
c6e49ac
Changed Calculation to second line of eq 18. Added output to text files
MaximeII Oct 27, 2021
70811e5
Fixed edges for NaNs
MaximeII Nov 2, 2021
7fcb2ac
Only output first substep to txt. Totally not fixed a HUGE typo. Noth…
MaximeII Nov 2, 2021
07d7dbd
Fixed array initialisation to zero
MaximeII Nov 3, 2021
bd9dd3a
Fixed dfdt being zero for empty cells
MaximeII Nov 3, 2021
20bf005
Fixed first derivative
MaximeII Nov 3, 2021
fbb0cac
Fixed edges, changed counter name, removed cells with V less than Vmin
MaximeII Nov 4, 2021
798e8f2
Fixed dfdt zero, output Ddt
MaximeII Nov 5, 2021
8c8f538
Added check for CellValue and fmu = 0.0 during dfdt calculations
MaximeII Nov 8, 2021
44b2673
Handle edges better question mark
MaximeII Nov 9, 2021
bf016c8
fixed mistake
MaximeII Nov 10, 2021
8ed93bc
Reverted to: Set Cells lower than Sparsity to Sparsity, ratio to 1 if…
MaximeII Nov 12, 2021
4e19501
New handling of edges
MaximeII Nov 15, 2021
0f27d0e
Markus' Method
MaximeII Nov 17, 2021
8613e46
Markus' version fixed?
MaximeII Nov 18, 2021
28844d2
Working version
MaximeII Feb 23, 2022
8ba42d5
Added parralel, LossCOne project, ukko makefile
MaximeII May 10, 2022
e2fc5c4
Optimisations
MaximeII May 17, 2022
91f4acb
Updated LossCone for sin
MaximeII May 30, 2022
76e9267
Added option of extra monotonic distribution in addition to loss-cone…
markusbattarbee May 31, 2022
0dfdca1
Merge pull request #1 from markusbattarbee/diffusion_add_monotonic
MaximeII May 31, 2022
4b2c152
Added loop over pop
MaximeII Jun 1, 2022
3bba1d7
Merge branch 'diffusion' of github.com:MaximeII/vlasiator into diffusion
MaximeII Jun 1, 2022
9220246
hi
MaximeII Jun 23, 2022
aeb4601
Merge remote-tracking branch 'master/master' into diffusion
MaximeII Jun 23, 2022
8c281f7
vectorization mu space only
MaximeII Jun 27, 2022
5296dca
vectorization muspace + dfdt calculation
MaximeII Jun 27, 2022
c7ec301
vectors opti v3 scatter operation (not good)
MaximeII Jul 1, 2022
bfc3cf2
SERIAL: cleaner version, switched [] brackets to .at(), declared std:…
MaximeII Aug 31, 2022
503edf2
SERIAL: cleaner version, switched [] brackets to .at(), declared std:…
MaximeII Aug 31, 2022
829f889
Was not running the right LossCone KEK
MaximeII Sep 1, 2022
8fd8212
SPATIAL OMP
MaximeII Sep 1, 2022
64f80e9
vectors MUSPACE
MaximeII Sep 2, 2022
e9cfc5b
Nothing to see here, did not make a mistake
MaximeII Sep 2, 2022
59272f2
muspace + derivatives VECTORS
MaximeII Sep 2, 2022
0f5327a
Fixed mistake
MaximeII Sep 5, 2022
1040e3c
Added phiprof for zeroing of vectors in substeps
MaximeII Sep 5, 2022
9cebe2a
Added phiprof for arrays initialisation
MaximeII Sep 6, 2022
16560b7
Changed to arryas (SEGFAULT)
MaximeII Sep 8, 2022
7de45fa
Remove some init, changed back some to vectors
MaximeII Sep 12, 2022
f8c8cb0
More optimisation, changed losscone for vflow
MaximeII Sep 26, 2022
6ced71d
Changed vectors to pointers, vectorized checkCFL, private muspace var…
MaximeII Sep 30, 2022
7d9704e
freed memory, change Vcount to Vindex ARE YOU HAPPY NOW MARKUS?
MaximeII Sep 30, 2022
50dddba
Changed to store only 1 muvspace index.
MaximeII Oct 3, 2022
7793aa2
Not storing muspace indexes but recalculating (slightly faster)
MaximeII Oct 3, 2022
1fb8caa
add txt writting for subcounts (TO BE DELETED)
MaximeII Oct 10, 2022
9411412
Cosine LossCone for diffusion
MaximeII Oct 27, 2022
356b60a
Minor changes
MaximeII Oct 28, 2022
c2b5514
changed checkCFl to be calculated from mu v space instead of Cartesia…
MaximeII Oct 28, 2022
a412fbd
Removed subCount print out
MaximeII Oct 31, 2022
df9730c
Fused multiple loops together
MaximeII Oct 31, 2022
3e22f96
Changed dfdt from v-space size array to 4
MaximeII Oct 31, 2022
f4895fc
Final? version
MaximeII Nov 8, 2022
b598245
Change Dmumu to be a function of mu
MaximeII Nov 21, 2022
3aa13bb
Dont know
MaximeII Jan 27, 2023
c0f0922
Added off diagonal Ptensor save to Vlasiator. Added reading from nu0 …
MaximeII Feb 13, 2023
d122785
Added curlies, added path to file
MaximeII Feb 13, 2023
fc72b50
Building DRO for 1d mu distributions.
MaximeII Mar 6, 2023
a48358e
Fixed B
MaximeII Mar 7, 2023
5546653
Merge branch 'DROmuSpace' into DiffusionMAPDmumu
MaximeII Mar 7, 2023
45d6928
Fixed various overwritten
MaximeII Mar 13, 2023
9b14b1a
Added off diag tensor for R and V (because why not)
MaximeII Mar 13, 2023
002b996
Added Removed osme comments
MaximeII Mar 13, 2023
c952fe1
Added print check to sendBuffer
MaximeII Mar 17, 2023
8ce38b5
Removed parameters in fsGrid, added print out checks
MaximeII Mar 21, 2023
9a0882b
Added safety check for edge case where mu = exactly 1
MaximeII Mar 27, 2023
6606e0c
Fixed read txt file.
May 17, 2023
2c9c78f
density renormalization
Jun 15, 2023
48cf1c0
Corrected derivative of absolute value in dDmumu calculation
Jun 16, 2023
4f9b397
Merge remote-tracking branch 'fmihpc/dev' into DmumuGlobal
Jun 21, 2023
171a60b
Updated makefile, Edge cases for parametrization
Nov 13, 2023
835feea
Merge branch 'dev' into DmumuGlobal
Nov 13, 2023
28d02e2
Revert back to dev Makefile for ukko and carrington
Nov 13, 2023
80b6fa2
PR changes
Dec 12, 2023
26e59bd
Reverted to original values except temperature anisotropy
Dec 12, 2023
743c35d
Deleted unnused files and renamed txt
Dec 15, 2023
c0b7e73
Added metaData in DRO and fixed phiprof timer
Jan 22, 2024
aa78d2f
Fix
Jan 22, 2024
da24535
Fixed metadata again, revert moments back
Jan 22, 2024
df64782
Updated CI to vectorclass version 2 and fixed sub-grid
Jan 29, 2024
9e2d38d
Merge remote-tracking branch 'fmihpc/dev' into DmumuGlobal
Jan 29, 2024
d2d7129
Added submodules for vectorclass version2
Jan 29, 2024
1140298
Fixed LossCone project after devmerge
Jan 29, 2024
24f8769
Updated Makefile for submodules vectorclass version2
Jan 29, 2024
018817d
Added vector class to ionosphere mini-app
Jan 29, 2024
6479f14
Make diffusion solver vector size flexible
Feb 2, 2024
30fa1f8
Merge remote-tracking branch 'fmihpc/dev' into DmumuGlobal
Feb 2, 2024
97a41cd
Fixed crashes when VECL neq WID
Feb 5, 2024
0be00ce
Added ceiling simulation dt
Mar 11, 2024
c91a6c3
Replace muspace access with a horribly convoluted C language construct.
ursg Mar 11, 2024
1163f4b
Merge pull request #4 from ursg/DmumuGlobal
MaximeII Mar 11, 2024
db84a17
muvspace output for debugging
Mar 11, 2024
9a85032
Merge remote-tracking branch 'origin/DmumuGlobal' into DmumuGlobal
Mar 11, 2024
a6edf3e
Fixed dt_ceil
Mar 13, 2024
ab0bfad
Cleaned comments for ceiling dt. Fixed pointers not being private in …
Mar 13, 2024
cacb987
Fixed pointers, now WID flexible. Final?
Mar 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ OBJS = version.o memoryallocation.o backgroundfield.o quadr.o dipole.o linedipo
sysboundary.o sysboundarycondition.o particle_species.o\
project.o projectTriAxisSearch.o read_gaussian_population.o\
Alfven.o Diffusion.o Dispersion.o Distributions.o Firehose.o\
Flowthrough.o Fluctuations.o Harris.o KHB.o Larmor.o Magnetosphere.o MultiPeak.o\
VelocityBox.o Riemann1.o Shock.o Template.o test_fp.o testHall.o test_trans.o\
Flowthrough.o Fluctuations.o Harris.o KHB.o Larmor.o Magnetosphere.o MultiPeak.o LossCone.o\
VelocityBox.o velocity_space_diffusion.o Riemann1.o Shock.o Template.o test_fp.o testHall.o test_trans.o\
IPShock.o object_wrapper.o\
verificationLarmor.o Shocktest.o grid.o ioread.o iowrite.o vlasiator.o logger.o\
common.o parameters.o readparameters.o spatial_cell.o\
vlasovmover.o $(FIELDSOLVER).o fs_common.o fs_limiters.o gridGlue.o
vlasovmover.o $(FIELDSOLVER).o fs_common.o fs_limiters.o gridGlue.o

# Include autogenerated dependency files, if they exist
-include $(OBJS:%.o=%.d)
Expand Down Expand Up @@ -226,7 +226,7 @@ version.cpp: FORCE
# for all files in the datareduction/ dir
%.o: datareduction/%.cpp ${DEPS_COMMON} datareduction/datareductionoperator.h fieldtracing/fieldtracing.h sysboundary/ionosphere.h datareduction/dro_populations.h
@echo [CC] $<
$(SILENT)${CMP} ${CXXFLAGS} ${FLAGS} ${MATHFLAGS} -c $< ${INC_DCCRG} ${INC_ZOLTAN} ${INC_MPI} ${INC_BOOST} ${INC_EIGEN} ${INC_VLSV} ${INC_FSGRID}
$(SILENT)${CMP} ${CXXFLAGS} ${FLAGS} ${MATHFLAGS} -c $< ${INC_DCCRG} ${INC_ZOLTAN} ${INC_MPI} ${INC_BOOST} ${INC_EIGEN} ${INC_VLSV} ${INC_FSGRID} ${INC_VECTORCLASS}

# for all files in the sysboundary/ dir
%.o: sysboundary/%.cpp ${DEPS_COMMON} sysboundary/%.h backgroundfield/backgroundfield.h projects/project.h fieldsolver/fs_limiters.h
Expand Down
85 changes: 85 additions & 0 deletions NU0BOX.DAT

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion common.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ namespace CellParams {
P_11_V, /*!< P_xx component after propagation in velocity space */
P_22_V, /*!< P_yy component after propagation in velocity space */
P_33_V, /*!< P_zz component after propagation in velocity space */
P_12, /*!< Pressure P_xy component, computed by Vlasov propagator. */
P_13, /*!< Pressure P_xz component, computed by Vlasov propagator. */
P_23, /*!< Pressure P_yz component, computed by Vlasov propagator. */
P_12_DT2, /*!< Intermediate step value for RK2 time stepping in field solver. Computed from P_12_R and P_12_V. */
P_13_DT2, /*!< Intermediate step value for RK2 time stepping in field solver. Computed from P_13_R and P_13_V. */
P_23_DT2, /*!< Intermediate step value for RK2 time stepping in field solver. Computed from P_23_R and P_23_V. */
P_12_R, /*!< P_xy component after propagation in ordinary space */
P_13_R, /*!< P_xz component after propagation in ordinary space */
P_23_R, /*!< P_yz component after propagation in ordinary space */
P_12_V, /*!< P_xy component after propagation in velocity space */
P_13_V, /*!< P_xz component after propagation in velocity space */
P_23_V, /*!< P_yz component after propagation in velocity space */
EXVOL, /*!< Volume electric field averaged over spatial cell, x-component.*/
EYVOL, /*!< Volume electric field averaged over spatial cell, y-component.*/
EZVOL, /*!< Volume electric field averaged over spatial cell, z-component.*/
Expand Down Expand Up @@ -214,6 +226,7 @@ namespace CellParams {
BULKV_FORCING_Y, /*! Externally forced drift velocity (ex. from the ionosphere) */
BULKV_FORCING_Z, /*! Externally forced drift velocity (ex. from the ionosphere) */
FORCING_CELL_NUM, /*! Number of boundary cells that have forced a bulkv here */
NU0, /*!< nu0 value for subgrid diffusion */
N_SPATIAL_CELL_PARAMS
};
}
Expand Down Expand Up @@ -475,7 +488,9 @@ RK_ORDER2_STEP1, /*!< Two-step second order method, first step */
RK_ORDER2_STEP2 /*!< Two-step second order method, second step */
};

const int WID = 4; /*!< Number of cells per coordinate in a velocity block. Only a value of 4 supported by vectorized Leveque solver */
#ifndef WID
#define WID (4) /*!< Number of cells per coordinate in a velocity block. Defaults to the historical 4. */
#endif
const int WID2 = WID*WID; /*!< Number of cells per 2D slab in a velocity block. */
const int WID3 = WID2*WID; /*!< Number of cells in a velocity block. */

Expand Down
15 changes: 15 additions & 0 deletions datareduction/datareducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ void initializeDataReducers(DataReducer * outputReducer, DataReducer * diagnosti
continue;
}
}
if(P::systemWriteAllDROs || lowercase == "vg_nu0" || lowercase == "nu0") { // nu0 for sub-grid diffusion
outputReducer->addOperator(new DRO::DataReductionOperatorCellParams("vg_nu0",CellParams::NU0,1));
outputReducer->addMetadata(outputReducer->size()-1,"1/s","$\\mathrm{s}^{-1}$","$\\nu_0$","1.0");
continue;
}
if(P::systemWriteAllDROs || lowercase == "populations_v" || lowercase == "populations_vg_v") { // Per population bulk velocities
for(unsigned int i =0; i < getObjectWrapper().particleSpecies.size(); i++) {
species::Species& species=getObjectWrapper().particleSpecies[i];
Expand Down Expand Up @@ -513,6 +518,16 @@ void initializeDataReducers(DataReducer * outputReducer, DataReducer * diagnosti
continue;
}
}
if(P::systemWriteAllDROs || lowercase == "populations_1dmuspace" || lowercase == "populations_vg_1dmuspace") {
// Per-population 1d muspace
for(unsigned int i =0; i < getObjectWrapper().particleSpecies.size(); i++) {
species::Species& species=getObjectWrapper().particleSpecies[i];
const std::string& pop = species.name;
outputReducer->addOperator(new DRO::VariableMuSpace(i));
outputReducer->addMetadata(outputReducer->size()-1,"1/m^3","$\\mathrm{m}^{-3}$","$f(\\mu)$","1.0");
}
MaximeII marked this conversation as resolved.
Show resolved Hide resolved
continue;
}
if(P::systemWriteAllDROs || lowercase == "populations_precipitationlineflux" || lowercase == "populations_vg_precipitationlinedifferentialflux" || lowercase == "populations_precipitationlinedifferentialflux") {
// Per-population precipitation differential flux (along line)
for(unsigned int i =0; i < getObjectWrapper().particleSpecies.size(); i++) {
Expand Down
93 changes: 93 additions & 0 deletions datareduction/datareductionoperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "vectorclass.h"
#include <cstdlib>
#include <mpi.h>
#include <iostream>
Expand All @@ -28,6 +29,7 @@
#include "datareductionoperator.h"
#include "../object_wrapper.h"


using namespace std;

typedef Parameters P;
Expand Down Expand Up @@ -1651,6 +1653,97 @@ namespace DRO {
return true;
}

/*! \brief V-space flatten into 1D mu distribution
*/
VariableMuSpace::VariableMuSpace(cuint _popID): DataReductionOperatorHasParameters(),popID(_popID) {popName = getObjectWrapper().particleSpecies[popID].name;}
VariableMuSpace::~VariableMuSpace() { }

std::string VariableMuSpace::getName() const {return popName + "/vg_1dmuspace";}

bool VariableMuSpace::getDataVectorInfo(std::string& dataType,unsigned int& dataSize,unsigned int& vectorSize) const {
dataType = "float";
dataSize = sizeof(Real);
vectorSize = Parameters::PADmubins; //Number of bins to build muSpace
return true;
}

bool VariableMuSpace::reduceData(const SpatialCell* cell,char* buffer) {


const Real* parameters = cell->get_block_parameters(popID);
std::vector<Real> fmu (Parameters::PADmubins);
std::vector<int> fcount(Parameters::PADmubins);

std::array<Real,3> bulkV = {cell->parameters[CellParams::VX], cell->parameters[CellParams::VY], cell->parameters[CellParams::VZ]};

std::array<Real,3> B = {cell->parameters[CellParams::PERBXVOL] + cell->parameters[CellParams::BGBXVOL],
cell->parameters[CellParams::PERBYVOL] + cell->parameters[CellParams::BGBYVOL],
cell->parameters[CellParams::PERBZVOL] + cell->parameters[CellParams::BGBZVOL]};

Real Bnorm = sqrt(B[0]*B[0] + B[1]*B[1] + B[2]*B[2]);
std::array<Real,3> b = {B[0]/Bnorm, B[1]/Bnorm, B[2]/Bnorm};

// Build 2d array of f(v,mu)
for (vmesh::LocalID n=0; n<cell->get_number_of_velocity_blocks(popID); n++) { // Iterate through velocity blocks
for (uint k = 0; k < WID; ++k) for (uint j = 0; j < WID; ++j) for (uint i = 0; i < WID; ++i) { // Iterate through coordinates (z,y,x)

//Get velocity space coordinates
const Real VX(parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::VXCRD]
+ (i + 0.5)*parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::DVX]);

const Real VY(parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::VYCRD]
+ (j + 0.5)*parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::DVY]);

const Real VZ(parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::VZCRD]
+ (k + 0.5)*parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::DVZ]);

std::array<Real,3> V = {VX,VY,VZ}; // Velocity in the cell, in the simulation frame

std::array<Real,3> Vplasma; // Velocity in the cell, in the plasma frame

for (int indx = 0; indx < 3; indx++) { Vplasma[indx] = (V[indx] - bulkV[indx]); }

Real normV = sqrt(Vplasma[0]*Vplasma[0] + Vplasma[1]*Vplasma[1] + Vplasma[2]*Vplasma[2]);

Real Vpara = Vplasma[0]*b[0] + Vplasma[1]*b[1] + Vplasma[2]*b[2];

Real mu = Vpara/(normV+std::numeric_limits<Realf>::min()); // + min value to avoid division by 0

int muindex;
Realf dmubins = 2.0 / Parameters::PADmubins;
muindex = floor((mu+1.0) / dmubins);

const Realf CellValue = cell->get_data(n,popID)[i+WID*j+WID*WID*k];

const Real DVX = parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::DVX];
const Real DVY = parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::DVY];
const Real DVZ = parameters[n * BlockParams::N_VELOCITY_BLOCK_PARAMS + BlockParams::DVZ];

fmu [muindex] += CellValue * DVX*DVY*DVZ / dmubins;


} // End coordinates
} // End blocks

// Divide f by count (independent of v but needs to be computed for all mu before derivatives)
//for(int indmu = 0; indmu < Parameters::PADmubins; indmu++) {
// if (fcount[indmu] == 0 || fmu[indmu] <= 0.0) { fmu[indmu] = std::numeric_limits<Realf>::min();}
// else {fmu[indmu] = fmu[indmu] / fcount[indmu];}
//}

const char* ptr = reinterpret_cast<const char*>(fmu.data());
for (uint i = 0; i < Parameters::PADmubins*sizeof(Real); ++i) buffer[i] = ptr[i];
return true;
}

bool VariableMuSpace::setSpatialCell(const SpatialCell* cell) {
return true;
}

bool VariableMuSpace::writeParameters(vlsv::Writer& vlsvWriter) {
return true;
}

/*! \brief Precipitation directional differential number flux (along line)
* Evaluation of the precipitating differential flux (per population) targeted at low energies.
* In a selected number (default: 16) of logarithmically spaced energy bins, the average of
Expand Down
19 changes: 18 additions & 1 deletion datareduction/datareductionoperator.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,24 @@ namespace DRO {
std::vector<Real> channels, dataDiffFlux;
};


// V-space flatten into 1D mu-distribution
class VariableMuSpace: public DataReductionOperatorHasParameters {
public:
VariableMuSpace(cuint popID);
virtual ~VariableMuSpace();

virtual bool getDataVectorInfo(std::string& dataType,unsigned int& dataSize,unsigned int& vectorSize) const;
virtual std::string getName() const;
virtual bool reduceData(const SpatialCell* cell,char* buffer);
virtual bool setSpatialCell(const SpatialCell* cell);
virtual bool writeParameters(vlsv::Writer& vlsvWriter);

protected:
uint popID;
std::string popName;
};

// Precipitation directional differential number flux (along line)
class VariablePrecipitationLineDiffFlux: public DataReductionOperatorHasParameters {
public:
Expand All @@ -625,7 +643,6 @@ namespace DRO {
virtual bool reduceData(const SpatialCell* cell,char* buffer);
virtual bool setSpatialCell(const SpatialCell* cell);
virtual bool writeParameters(vlsv::Writer& vlsvWriter);

protected:
uint popID;
std::string popName;
Expand Down
1 change: 0 additions & 1 deletion item_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include <map>
#include <string>

#include "definitions.h"

/** A generic storage class for storing items, such as variable values or
Expand Down
1 change: 1 addition & 0 deletions object_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "object_wrapper.h"
#include "readparameters.h"
#include <iostream>
#include <string>

bool ObjectWrapper::addParameters() {
typedef Readparameters RP;
Expand Down
1 change: 1 addition & 0 deletions object_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "particle_species.h"
#include "projects/project.h"
#include "velocity_mesh_parameters.h"
#include <string>
#include "sysboundary/sysboundary.h"

struct ObjectWrapper {
Expand Down
36 changes: 34 additions & 2 deletions parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ uint P::zcells_ini = numeric_limits<uint>::max();

Real P::t = 0;
Real P::t_min = 0;
Real P::t_max = LARGE_REAL;
Real P::t_max = LARGE_REAL;
Real P::dt_ceil = -1.0;
Real P::dt = NAN;
Real P::vlasovSolverMaxCFL = NAN;
Real P::vlasovSolverMinCFL = NAN;
Expand Down Expand Up @@ -186,7 +187,14 @@ std::vector<Realf> P::amrBoxCenterY;
std::vector<Realf> P::amrBoxCenterZ;
std::vector<int> P::amrBoxMaxLevel;
vector<string> P::blurPassString;
std::vector<int> P::numPasses; //numpasses
vector<int> P::numPasses;
bool P::artificialPADiff;
Realf P::PADcoefficient;
Realf P::PADCFL;
int P::PADvbins;
int P::PADmubins;
string P::PADnu0 = string("");
Realf P::PADfudge;

std::array<FsGridTools::Task_t,3> P::manualFsGridDecomposition = {0,0,0};
std::array<FsGridTools::Task_t,3> P::overrideReadFsGridDecomposition = {0,0,0};
Expand Down Expand Up @@ -313,6 +321,9 @@ bool P::addParameters() {
RP::add("gridbuilder.timestep_max",
"Max. value for timesteps. If t_max limit is hit first, this step will never be reached",
numeric_limits<uint>::max());
RP::add("gridbuilder.dt_ceil",
"Maximum simulation dt in seconds.",
-1.0);

// Field solver parameters
RP::add("fieldsolver.maxWaveVelocity",
Expand Down Expand Up @@ -497,6 +508,15 @@ bool P::addParameters() {
RP::add("AMR.transShortPencils", "if true, use one-cell pencils", false);
RP::addComposing("AMR.filterpasses", string("AMR filter passes for each individual refinement level"));

// Diffusion parameters
RP::add("PAD.enable","Enable Artificial pitch-angle diffusion",0);
RP::add("PAD.coefficient","Set artificial pitch-angle diffusion coefficient",0);
RP::add("PAD.CFL","Set CFL condition",0);
RP::add("PAD.vbins","number of bins for velocity",200);
RP::add("PAD.mubins","number of bins for mu",30);
RP::add("PAD.file","Path of txt file for nu0", string("NU0BOX.DAT"));
RP::add("PAD.fudge","fudge factor to lower diffusion",0.25);
// Fieldtracing
RP::add("fieldtracing.fieldLineTracer", "Field line tracing method to use for coupling ionosphere and magnetosphere (options are: Euler, BS)", std::string("Euler"));
RP::add("fieldtracing.tracer_max_allowed_error", "Maximum allowed error for the adaptive field line tracers ", 1000);
RP::add("fieldtracing.tracer_max_attempts", "Maximum allowed attempts for the adaptive field line tracers", 100);
Expand Down Expand Up @@ -878,6 +898,8 @@ void Parameters::getParameters() {
RP::get("gridbuilder.t_max", P::t_max);
RP::get("gridbuilder.timestep_max", P::tstep_max);

RP::get("gridbuilder.dt_ceil", P::dt_ceil);

if (P::dynamicTimestep)
P::dt = 0.0; // if dynamic timestep then first dt is always 0

Expand Down Expand Up @@ -970,6 +992,14 @@ void Parameters::getParameters() {
P::systemWrites.push_back(0);
}

RP::get("PAD.enable", P::artificialPADiff);
RP::get("PAD.coefficient", P::PADcoefficient);
RP::get("PAD.CFL",P::PADCFL);
RP::get("PAD.vbins",P::PADvbins);
RP::get("PAD.mubins",P::PADmubins);
RP::get("PAD.file",P::PADnu0);
RP::get("PAD.fudge",P::PADfudge);

RP::get("fieldtracing.fieldLineTracer", tracerString);
RP::get("fieldtracing.tracer_max_allowed_error", FieldTracing::fieldTracingParameters.max_allowed_error);
RP::get("fieldtracing.tracer_max_attempts", FieldTracing::fieldTracingParameters.max_field_tracer_attempts);
Expand All @@ -994,3 +1024,5 @@ void Parameters::getParameters() {
abort();
}
}


9 changes: 9 additions & 0 deletions parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ struct Parameters {
static Real t_max; /*!< Maximum simulation time. */
static Real dt; /*!< The value of the timestep to use in propagation. If CflLimit defined then it is dynamically
updated during simulation*/
static Real dt_ceil; /*!< The maximum value of the timestep to use in propagation. */

static Real vlasovSolverMaxCFL; /*!< The maximum CFL limit for propagation of distribution function. Used to set
timestep if useCFLlimit is true. */
static Real vlasovSolverMinCFL; /*!< The minimum CFL limit for propagation of distribution function. Used to set
Expand Down Expand Up @@ -218,6 +220,13 @@ struct Parameters {
static bool amrTransShortPencils; /*!< Use short or longpencils in AMR translation.*/
static std::vector<std::string> blurPassString;
static std::vector<int> numPasses;
static bool artificialPADiff; // Artificial velocity space Diffusion
static Realf PADcoefficient; // Artificial pitch-angle diffusion coefficient
static Realf PADCFL; // Artificial pitch-angle diffusion CFL
static int PADvbins; // Number of bins in velocity for pitch-angle diffusion
static int PADmubins; // Number of bins in mu for pitch-angle diffusion
static std::string PADnu0; // Path to txt file for nu0
static Realf PADfudge; // Fudge factore for diffusion

static std::array<FsGridTools::Task_t,3> manualFsGridDecomposition;
static std::array<FsGridTools::Task_t,3> overrideReadFsGridDecomposition;
Expand Down
Loading