Version 2, position dependent E/B, kinetic ions, boris mover, terminator
This commit is contained in:
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#include "simulation/unit_converter.h"
|
||||
#include "constants/physical_constants.h"
|
||||
#include "simulation/errors.h"
|
||||
|
||||
namespace unitConvertion {
|
||||
|
||||
double lengthPrefactor(const std::string& unit) {
|
||||
if (unit == "cm") {
|
||||
return 1E-2;
|
||||
} else if (unit == "m") {
|
||||
return 1;
|
||||
} else if (unit == "mm") {
|
||||
return 1E-3;
|
||||
} else {
|
||||
ERROR("I dont know this length unit.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
double length(double value,
|
||||
const std::string& unit_from,
|
||||
const std::string& unit_to) {
|
||||
double prefactor_from = lengthPrefactor(unit_from);
|
||||
double prefactor_to = lengthPrefactor(unit_to);
|
||||
|
||||
return value * prefactor_from / prefactor_to;
|
||||
}
|
||||
|
||||
double energyPrefactor(const std::string& unit) {
|
||||
if (unit == "eV") {
|
||||
return 1.;
|
||||
} else if (unit == "J") {
|
||||
return 1 / SI::e;
|
||||
} else {
|
||||
ERROR("I dont know this energy unit.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
double energy(double value,
|
||||
const std::string& unit_from,
|
||||
const std::string& unit_to) {
|
||||
double prefactor_from = energyPrefactor(unit_from);
|
||||
double prefactor_to = energyPrefactor(unit_to);
|
||||
return value * prefactor_from / prefactor_to;
|
||||
}
|
||||
|
||||
}; // namespace unitConvertion
|
||||
Reference in New Issue
Block a user