IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 13460451 authored by ralfulrich's avatar ralfulrich
Browse files

run ./do-clang-format.sh

parent ce459bfe
No related branches found
No related tags found
No related merge requests found
Showing
with 184 additions and 197 deletions
#include <corsika/logging/Logger.h> #include <corsika/logging/Logger.h>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <string>
#include <iostream>
#include <fstream> #include <fstream>
#include <iostream>
#include <string>
using namespace std; using namespace std;
using namespace corsika::logging; using namespace corsika::logging;
int int main() {
main()
{
{ {
cout << "writing to \"another.log\"" << endl; cout << "writing to \"another.log\"" << endl;
ofstream logfile("another.log"); ofstream logfile("another.log");
...@@ -18,28 +15,32 @@ main() ...@@ -18,28 +15,32 @@ main()
sink::BufferedSinkStream sink(logfile, sink::StdBuffer(10000)); sink::BufferedSinkStream sink(logfile, sink::StdBuffer(10000));
Logger<MessageOn, sink::BufferedSinkStream> info("\033[32m", "info", sink); Logger<MessageOn, sink::BufferedSinkStream> info("\033[32m", "info", sink);
Logger<MessageOn, sink::BufferedSinkStream> err("\033[31m", "error", sink); Logger<MessageOn, sink::BufferedSinkStream> err("\033[31m", "error", sink);
//logger<ostream,messageconst,StdBuffer> info(std::cout, StdBuffer(10000)); // logger<ostream,messageconst,StdBuffer> info(std::cout, StdBuffer(10000));
/* /*
Logging& logs = Logging::GetInstance(); Logging& logs = Logging::GetInstance();
logs.AddLogger<>("info", info); logs.AddLogger<>("info", info);
auto& log_1 = logs.GetLogger("info"); // no so useful, since type of log_1 is std::any auto& log_1 = logs.GetLogger("info"); // no so useful, since type of log_1 is
std::any
*/ */
for (int i=0; i<100000; ++i) { for (int i = 0; i < 100000; ++i) {
LOG(info, "irgendwas"," ", string("and more")," ", boost::format("error: %i message: %s. done."), i, "stupido"); LOG(info, "irgendwas", " ", string("and more"), " ",
boost::format("error: %i message: %s. done."), i, "stupido");
LOG(err, "Fehler"); LOG(err, "Fehler");
} }
} }
{ {
sink::NoSink off; sink::NoSink off;
Logger<MessageOff> info("", "", off); Logger<MessageOff> info("", "", off);
for (int i=0; i<100000; ++i) { for (int i = 0; i < 100000; ++i) {
LOG(info, "irgendwas", string("and more"), boost::format("error: %i message: %s. done."), i, "stupido", "a-number:", 8.99, "ENDE" ); LOG(info, "irgendwas", string("and more"),
boost::format("error: %i message: %s. done."), i, "stupido", "a-number:", 8.99,
"ENDE");
} }
} }
return 0; return 0;
} }
#include <corsika/stack/super_stupid/SuperStupidStack.h>
#include <corsika/particles/ParticleProperties.h> #include <corsika/particles/ParticleProperties.h>
#include <corsika/stack/super_stupid/SuperStupidStack.h>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
...@@ -10,7 +10,6 @@ using namespace std; ...@@ -10,7 +10,6 @@ using namespace std;
using namespace corsika::units; using namespace corsika::units;
using namespace corsika::stack; using namespace corsika::stack;
void fill(corsika::stack::super_stupid::SuperStupidStack& s) { void fill(corsika::stack::super_stupid::SuperStupidStack& s) {
for (int i = 0; i < 11; ++i) { for (int i = 0; i < 11; ++i) {
auto p = s.NewParticle(); auto p = s.NewParticle();
......
...@@ -2,27 +2,20 @@ ...@@ -2,27 +2,20 @@
namespace cascade; namespace cascade;
template<typename Sequence, typename Trajectory> template <typename Sequence, typename Trajectory>
void void Cascade::Cascade() {
Cascade::Cascade() {
kkk; kkk;
kk; kk;
} }
template <typename Sequence, typename Trajectory>
template<typename Sequence, typename Trajectory> void Cascade::Init() {
void
Cascade::Init()
{
fStack.Init(); fStack.Init();
fProcesseList.Init(); fProcesseList.Init();
} }
template <typename Sequence, typename Trajectory>
template<typename Sequence, typename Trajectory> void Cascade::Run() {
void
Cascade::Run()
{
if (!fStack.IsEmpty()) { if (!fStack.IsEmpty()) {
if (!fStack.IsEmpty()) { if (!fStack.IsEmpty()) {
Particle& p = fStack.GetNextParticle(); Particle& p = fStack.GetNextParticle();
...@@ -34,14 +27,10 @@ Cascade::Run() ...@@ -34,14 +27,10 @@ Cascade::Run()
} }
} }
template <typename Sequence, typename Trajectory>
template<typename Sequence, typename Trajectory> void Cascade::Step(Particle& particle) {
void
Cascade::Step(Particle& particle)
{
double nextStep = fProcesseList.MinStepLength(particle); double nextStep = fProcesseList.MinStepLength(particle);
Trajectory trajectory = fProcesseList.Transport(particle, nextStep); Trajectory trajectory = fProcesseList.Transport(particle, nextStep);
sequence.DoContinuous(particle, trajectory); sequence.DoContinuous(particle, trajectory);
sequence.DoDiscrete(particle); sequence.DoDiscrete(particle);
} }
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
namespace cascade { namespace cascade {
template<typename Processes, typename Trajectory, typename Stack> template <typename Processes, typename Trajectory, typename Stack>
class Cascade { class Cascade {
public: public:
Cascade(); Cascade();
...@@ -16,9 +16,8 @@ namespace cascade { ...@@ -16,9 +16,8 @@ namespace cascade {
private: private:
Stack fStack; Stack fStack;
Processes fProcesseList; Processes fProcesseList;
}; };
} } // namespace cascade
#endif #endif
...@@ -2,13 +2,9 @@ ...@@ -2,13 +2,9 @@
namespace cascade; namespace cascade;
void Cascade::Step(auto& sequence, Particle& particle) {
void
Cascade::Step(auto& sequence, Particle& particle)
{
double nextStep = sequence.MinStepLength(particle); double nextStep = sequence.MinStepLength(particle);
Trajectory trajectory = sequence.Transport(particle, nextStep); Trajectory trajectory = sequence.Transport(particle, nextStep);
sequence.DoContinuous(particle, trajectory); sequence.DoContinuous(particle, trajectory);
sequence.DoDiscrete(particle); sequence.DoDiscrete(particle);
} }
...@@ -11,7 +11,7 @@ typedef Eigen::Translation<double, 3> EigenTranslation; ...@@ -11,7 +11,7 @@ typedef Eigen::Translation<double, 3> EigenTranslation;
namespace corsika::geometry { namespace corsika::geometry {
using corsika::units::length_d; using corsika::units::length_d;
class CoordinateSystem { class CoordinateSystem {
CoordinateSystem const* reference = nullptr; CoordinateSystem const* reference = nullptr;
EigenTransform transf; EigenTransform transf;
...@@ -59,6 +59,6 @@ namespace corsika::geometry { ...@@ -59,6 +59,6 @@ namespace corsika::geometry {
auto const& GetTransform() const { return transf; } auto const& GetTransform() const { return transf; }
}; };
} // namespace corsika } // namespace corsika::geometry
#endif #endif
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
namespace corsika::geometry { namespace corsika::geometry {
using corsika::units::SpeedType; using corsika::units::frequency_d;
using corsika::units::TimeType;
using corsika::units::FrequencyType; using corsika::units::FrequencyType;
using corsika::units::quantity; using corsika::units::quantity;
using corsika::units::frequency_d; using corsika::units::SpeedType;
using corsika::units::TimeType;
class Helix // TODO: inherit from to-be-implemented "Trajectory" class Helix // TODO: inherit from to-be-implemented "Trajectory"
{ {
using SpeedVec = Vector<SpeedType::dimension_type>; using SpeedVec = Vector<SpeedType::dimension_type>;
...@@ -26,8 +26,8 @@ namespace corsika::geometry { ...@@ -26,8 +26,8 @@ namespace corsika::geometry {
LengthType const radius; LengthType const radius;
public: public:
Helix(Point const& pR0, quantity<frequency_d> pOmegaC, Helix(Point const& pR0, quantity<frequency_d> pOmegaC, SpeedVec const& pvPar,
SpeedVec const& pvPar, SpeedVec const& pvPerp) SpeedVec const& pvPerp)
: r0(pR0) : r0(pR0)
, omegaC(pOmegaC) , omegaC(pOmegaC)
, vPar(pvPar) , vPar(pvPar)
...@@ -43,6 +43,6 @@ namespace corsika::geometry { ...@@ -43,6 +43,6 @@ namespace corsika::geometry {
auto GetRadius() const { return radius; } auto GetRadius() const { return radius; }
}; };
} // namespace corsika } // namespace corsika::geometry
#endif #endif
#ifndef _include_LINETRAJECTORY_H #ifndef _include_LINETRAJECTORY_H
#define _include_LINETRAJECTORY_H #define _include_LINETRAJECTORY_H
#include <Units/PhysicalUnits.h>
#include <corsika/Point.h> #include <corsika/Point.h>
#include <corsika/Vector.h> #include <corsika/Vector.h>
#include <Units/PhysicalUnits.h>
namesapce corsika { namesapce corsika {
class LineTrajectory // TODO: inherit from Trajectory class LineTrajectory // TODO: inherit from Trajectory
{ {
using SpeedVec = Vector<Speed::dimension_type>; using SpeedVec = Vector<Speed::dimension_type>;
Point const r0; Point const r0;
SpeedVec const v0; SpeedVec const v0;
LineTrajectory(Point const& pR0, SpeedVec const& pV0) : LineTrajectory(Point const& pR0, SpeedVec const& pV0)
r0(r0), v0(pV0) : r0(r0)
{ , v0(pV0) {}
}
auto GetPosition(Time t) const { return r0 + v0 * t; }
auto GetPosition(Time t) const };
{
return r0 + v0 * t;
}
};
} // end namesapce } // end namesapce
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
namespace corsika::geometry { namespace corsika::geometry {
using corsika::units::LengthType;
using corsika::units::length_d; using corsika::units::length_d;
using corsika::units::LengthType;
/*! /*!
* A Point represents a point in position space. It is defined by its * A Point represents a point in position space. It is defined by its
* coordinates with respect to some CoordinateSystem. * coordinates with respect to some CoordinateSystem.
...@@ -60,6 +60,6 @@ namespace corsika::geometry { ...@@ -60,6 +60,6 @@ namespace corsika::geometry {
} }
}; };
} // namespace corsika } // namespace corsika::geometry
#endif #endif
...@@ -172,6 +172,6 @@ namespace corsika::geometry { ...@@ -172,6 +172,6 @@ namespace corsika::geometry {
} }
}; };
} // namespace corsika } // namespace corsika::geometry
#endif #endif
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
namespace corsika::logging { namespace corsika::logging {
namespace sink { namespace sink {
/** /**
Output buffer template. NoBuffer does nothingk. Output buffer template. NoBuffer does nothingk.
...@@ -19,47 +18,53 @@ namespace corsika::logging { ...@@ -19,47 +18,53 @@ namespace corsika::logging {
*/ */
/** /**
Output buffer template. StdBuffer records fSize characters in Output buffer template. StdBuffer records fSize characters in
local memeory before passing it on to further output stages. local memeory before passing it on to further output stages.
*/ */
struct StdBuffer { struct StdBuffer {
StdBuffer(const int size) : fSize(size) {} StdBuffer(const int size)
inline bool Test(const std::string& s) { return int(fBuffer.tellp())+s.length() < fSize; } : fSize(size) {}
inline bool Test(const std::string& s) {
return int(fBuffer.tellp()) + s.length() < fSize;
}
inline std::string GetString() const { return fBuffer.str(); } inline std::string GetString() const { return fBuffer.str(); }
inline void Clear() { fBuffer.str(""); } inline void Clear() { fBuffer.str(""); }
inline void Add(const std::string& s) { fBuffer << s; } inline void Add(const std::string& s) { fBuffer << s; }
private: private:
int fSize; int fSize;
std::ostringstream fBuffer; std::ostringstream fBuffer;
}; };
/** /**
Definition of Sink for log output. Definition of Sink for log output.
*/ */
template<typename TStream, typename TBuffer=StdBuffer> template <typename TStream, typename TBuffer = StdBuffer>
class BufferedSink { class BufferedSink {
public: public:
BufferedSink(TStream& out, TBuffer buffer = {} ) : fOutput(out), fBuffer(std::move(buffer)) {} BufferedSink(TStream& out, TBuffer buffer = {})
void operator<<(const std::string& msg) { : fOutput(out)
if (!fBuffer.Test(msg)) { , fBuffer(std::move(buffer)) {}
fOutput << fBuffer.GetString(); void operator<<(const std::string& msg) {
fBuffer.Clear(); if (!fBuffer.Test(msg)) {
fOutput << fBuffer.GetString();
fBuffer.Clear();
}
if (!fBuffer.Test(msg))
fOutput << msg;
else
fBuffer.Add(msg);
} }
if (!fBuffer.Test(msg)) void Close() { fOutput << fBuffer.GetString(); }
fOutput << msg;
else
fBuffer.Add(msg);
}
void Close() { fOutput << fBuffer.GetString(); }
private: private:
TStream& fOutput; TStream& fOutput;
TBuffer fBuffer; TBuffer fBuffer;
}; };
typedef BufferedSink<std::ostream, StdBuffer> BufferedSinkStream; typedef BufferedSink<std::ostream, StdBuffer> BufferedSinkStream;
}// end namespace } // namespace sink
} // end namespace } // namespace corsika::logging
#endif #endif
...@@ -8,25 +8,22 @@ ...@@ -8,25 +8,22 @@
#define _include_logger_h_ #define _include_logger_h_
#include <iosfwd> #include <iosfwd>
#include <string>
#include <sstream> #include <sstream>
#include <string>
#include <typeinfo> #include <typeinfo>
#include <boost/format.hpp> #include <boost/format.hpp>
#include <corsika/logging/MessageOn.h> #include <corsika/logging/BufferedSink.h>
#include <corsika/logging/MessageOff.h> #include <corsika/logging/MessageOff.h>
#include <corsika/logging/Sink.h> #include <corsika/logging/MessageOn.h>
#include <corsika/logging/NoSink.h> #include <corsika/logging/NoSink.h>
#include <corsika/logging/BufferedSink.h> #include <corsika/logging/Sink.h>
using namespace std; using namespace std;
using namespace boost; using namespace boost;
namespace corsika::logging { namespace corsika::logging {
/** /**
@class Logger @class Logger
...@@ -36,50 +33,51 @@ namespace corsika::logging { ...@@ -36,50 +33,51 @@ namespace corsika::logging {
compile-time into message strings. The helper class MessageOff, compile-time into message strings. The helper class MessageOff,
will just do nothing and will be optimized away at compile time. will just do nothing and will be optimized away at compile time.
*/ */
template<typename MSG=MessageOn, typename TSink=sink::NoSink> template <typename MSG = MessageOn, typename TSink = sink::NoSink>
class Logger : private MSG { class Logger : private MSG {
using MSG::Message; using MSG::Message;
public: public:
// Logger() : fName("") {} // Logger() : fName("") {}
Logger(const std::string color, const std::string name, TSink& sink) : fSink(sink), fName(color+"["+name+"]\033[39m ") {} Logger(const std::string color, const std::string name, TSink& sink)
~Logger() { fSink.Close(); } : fSink(sink)
, fName(color + "[" + name + "]\033[39m ") {}
~Logger() { fSink.Close(); }
// Logger(const Logger&) = delete; // Logger(const Logger&) = delete;
/** /**
Function to add string-concatenation of all inputs to output Function to add string-concatenation of all inputs to output
sink. sink.
*/ */
template<typename ... Strings> template <typename... Strings>
void Log(const Strings&... inputs) { void Log(const Strings&... inputs) {
fSink << MSG::Message(inputs...); fSink << MSG::Message(inputs...);
} }
const std::string& GetName() const { return fName; } const std::string& GetName() const { return fName; }
private: private:
TSink& fSink; TSink& fSink;
std::string fName; std::string fName;
}; };
} // end namesapce } // namespace corsika::logging
/** /**
* @def LOG(...) * @def LOG(...)
* *
* This is the main interface to the logging facilities. If Logger * This is the main interface to the logging facilities. If Logger
* object are defined (e.g. log1) use as * object are defined (e.g. log1) use as
* @example LOG(log1, "var1=", variable1int, "var2=", variabl2double) * @example LOG(log1, "var1=", variable1int, "var2=", variabl2double)
* for arbitrary long sequence * for arbitrary long sequence
* of arguments. This may also include boost::format objects the * of arguments. This may also include boost::format objects the
* output is concatenated, if log1 is switched off at compile time, * output is concatenated, if log1 is switched off at compile time,
* the whole LOG command is optimized away by the compiler. * the whole LOG command is optimized away by the compiler.
*/ */
#define LOG(__LOGGER,...) \ #define LOG(__LOGGER, ...) \
__LOGGER.Log(__LOGGER.GetName(), __FILE__,":", __LINE__, " (", __func__, ") -> ", ##__VA_ARGS__); __LOGGER.Log(__LOGGER.GetName(), __FILE__, ":", __LINE__, " (", __func__, ") -> ", \
##__VA_ARGS__);
#endif #endif
...@@ -9,11 +9,12 @@ namespace corsika::logging { ...@@ -9,11 +9,12 @@ namespace corsika::logging {
*/ */
class MessageOff { class MessageOff {
protected: protected:
template<typename First, typename ... Strings> std::string Message(const First& arg, const Strings&... rest) { template <typename First, typename... Strings>
std::string Message(const First& arg, const Strings&... rest) {
return ""; return "";
} }
}; };
} // end namespace } // namespace corsika::logging
#endif #endif
#ifndef _include_MessageOn_h_ #ifndef _include_MessageOn_h_
#define _include_MessageOn_h_ #define _include_MessageOn_h_
namespace corsika::logging { namespace corsika::logging {
/** /**
...@@ -11,44 +10,51 @@ namespace corsika::logging { ...@@ -11,44 +10,51 @@ namespace corsika::logging {
class MessageOn { class MessageOn {
protected: protected:
std::string Message() { return "\n"; } std::string Message() { return "\n"; }
template<typename First, typename ... Strings> std::string Message(const First& arg, const Strings&... rest) { template <typename First, typename... Strings>
std::string Message(const First& arg, const Strings&... rest) {
std::ostringstream ss; std::ostringstream ss;
ss << arg << Message(rest...); ss << arg << Message(rest...);
return ss.str(); return ss.str();
} }
template<typename ... Strings> std::string Message(const int& arg, const Strings&... rest) { template <typename... Strings>
std::string Message(const int& arg, const Strings&... rest) {
return std::to_string(arg) + Message(rest...); return std::to_string(arg) + Message(rest...);
} }
template<typename ... Strings> std::string Message(const double& arg, const Strings&... rest) { template <typename... Strings>
std::string Message(const double& arg, const Strings&... rest) {
return std::to_string(arg) + Message(rest...); return std::to_string(arg) + Message(rest...);
} }
template<typename ... Strings> std::string Message(char const * arg, const Strings&... rest) { template <typename... Strings>
std::string Message(char const* arg, const Strings&... rest) {
return std::string(arg) + Message(rest...); return std::string(arg) + Message(rest...);
} }
template<typename ... Strings> std::string Message(const std::string& arg, const Strings&... rest) { template <typename... Strings>
std::string Message(const std::string& arg, const Strings&... rest) {
return arg + Message(rest...); return arg + Message(rest...);
} }
// ---------------------- // ----------------------
// boost format // boost format
template<typename ... Strings> std::string Message(const boost::format& fmt, const Strings&... rest) { template <typename... Strings>
std::string Message(const boost::format& fmt, const Strings&... rest) {
boost::format FMT(fmt); boost::format FMT(fmt);
return bformat(FMT, rest...); return bformat(FMT, rest...);
} }
template<typename Arg, typename ... Strings> std::string bformat(boost::format& fmt, const Arg& arg, const Strings&... rest) { template <typename Arg, typename... Strings>
std::string bformat(boost::format& fmt, const Arg& arg, const Strings&... rest) {
fmt % arg; fmt % arg;
return bformat(fmt, rest...); return bformat(fmt, rest...);
} }
std::string bformat(boost::format& fmt) { return fmt.str() + "\n"; } std::string bformat(boost::format& fmt) { return fmt.str() + "\n"; }
}; };
}// end namesapce } // namespace corsika::logging
#endif #endif
...@@ -10,7 +10,7 @@ namespace corsika::logging { ...@@ -10,7 +10,7 @@ namespace corsika::logging {
inline void Close() {} inline void Close() {}
}; };
}// end namespace } // namespace sink
} // end namespace } // namespace corsika::logging
#endif #endif
...@@ -5,33 +5,33 @@ namespace corsika::logging { ...@@ -5,33 +5,33 @@ namespace corsika::logging {
/** /**
a sink for the logger must implement the two functions a sink for the logger must implement the two functions
operator<<(const std::string&) operator<<(const std::string&)
and and
Close() Close()
See example: NoSink See example: NoSink
*/ */
namespace sink { namespace sink {
/** /**
Definition of Sink for log output. Definition of Sink for log output.
*/ */
template<typename TStream> template <typename TStream>
class Sink { class Sink {
public: public:
Sink(TStream& out) : fOutput(out) {} Sink(TStream& out)
void operator<<(const std::string& msg) { : fOutput(out) {}
fOutput << msg; void operator<<(const std::string& msg) { fOutput << msg; }
} void Close() {}
void Close() {}
private: private:
TStream& fOutput; TStream& fOutput;
}; };
typedef Sink<std::ostream> SinkStream; typedef Sink<std::ostream> SinkStream;
}// end namespace } // namespace sink
} // end namespace } // namespace corsika::logging
#endif #endif
#include <corsika/units/PhysicalUnits.h>
#include <corsika/particles/ParticleProperties.h> #include <corsika/particles/ParticleProperties.h>
#include <corsika/units/PhysicalUnits.h>
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one
// cpp file // cpp file
...@@ -18,8 +18,7 @@ TEST_CASE("Particles", "[Particles]") { ...@@ -18,8 +18,7 @@ TEST_CASE("Particles", "[Particles]") {
REQUIRE(Electron::GetMass() / GetMass(Code::Electron) == Approx(1)); REQUIRE(Electron::GetMass() / GetMass(Code::Electron) == Approx(1));
REQUIRE(Electron::GetCharge() / constants::e == Approx(-1)); REQUIRE(Electron::GetCharge() / constants::e == Approx(-1));
REQUIRE(Positron::GetCharge() / constants::e == Approx(+1)); REQUIRE(Positron::GetCharge() / constants::e == Approx(+1));
REQUIRE(GetElectricCharge(Positron::GetAntiParticle()) / constants::e == REQUIRE(GetElectricCharge(Positron::GetAntiParticle()) / constants::e == Approx(-1));
Approx(-1));
REQUIRE(Electron::GetName() == "e-"); REQUIRE(Electron::GetName() == "e-");
} }
} }
...@@ -111,6 +111,6 @@ namespace corsika::stack { ...@@ -111,6 +111,6 @@ namespace corsika::stack {
} }
}; };
} // end namespace stack } // namespace corsika::stack
#endif #endif
...@@ -27,37 +27,34 @@ ...@@ -27,37 +27,34 @@
#include <phys/units/quantity.hpp> #include <phys/units/quantity.hpp>
namespace corsika::units::constants { namespace corsika::units::constants {
using namespace phys::units; using namespace phys::units;
// acceleration of free-fall, standard
constexpr phys::units::quantity<phys::units::acceleration_d> g_sub_n{phys::units::Rep(9.80665L) * phys::units::meter / phys::units::square(phys::units::second)};
// Avogadro constant // acceleration of free-fall, standard
constexpr quantity<dimensions<0, 0, 0, 0, 0, -1> > N_sub_A{Rep(6.02214199e+23L) / constexpr phys::units::quantity<phys::units::acceleration_d> g_sub_n{
mole}; phys::units::Rep(9.80665L) * phys::units::meter /
// electronvolt phys::units::square(phys::units::second)};
constexpr quantity<energy_d> eV{Rep(1.60217733e-19L) * joule};
// elementary charge // Avogadro constant
constexpr quantity<electric_charge_d> e{Rep(1.602176462e-19L) * coulomb}; constexpr quantity<dimensions<0, 0, 0, 0, 0, -1> > N_sub_A{Rep(6.02214199e+23L) / mole};
// electronvolt
constexpr quantity<energy_d> eV{Rep(1.60217733e-19L) * joule};
// Planck constant // elementary charge
constexpr quantity<dimensions<2, 1, -1> > h{Rep(6.62606876e-34L) * joule * second}; constexpr quantity<electric_charge_d> e{Rep(1.602176462e-19L) * coulomb};
// speed of light in a vacuum // Planck constant
constexpr quantity<speed_d> c{Rep(299792458L) * meter / second}; constexpr quantity<dimensions<2, 1, -1> > h{Rep(6.62606876e-34L) * joule * second};
// unified atomic mass unit // speed of light in a vacuum
constexpr quantity<mass_d> u{Rep(1.6605402e-27L) * kilogram}; constexpr quantity<speed_d> c{Rep(299792458L) * meter / second};
// etc. // unified atomic mass unit
constexpr quantity<mass_d> u{Rep(1.6605402e-27L) * kilogram};
// etc.
} // namespace corsika
#endif // PHYS_UNITS_PHYSICAL_CONSTANTS_HPP_INCLUDED } // namespace corsika::units::constants
#endif // PHYS_UNITS_PHYSICAL_CONSTANTS_HPP_INCLUDED
...@@ -15,23 +15,24 @@ ...@@ -15,23 +15,24 @@
namespace phys { namespace phys {
namespace units { namespace units {
namespace literals { namespace literals {
QUANTITY_DEFINE_SCALING_LITERALS(eV, energy_d, magnitude(corsika::units::constants::eV)) QUANTITY_DEFINE_SCALING_LITERALS(eV, energy_d,
magnitude(corsika::units::constants::eV))
} }
} // namespace units } // namespace units
} // namespace phys } // namespace phys
namespace corsika::units { namespace corsika::units {
using namespace phys::units; using namespace phys::units;
using namespace phys::units::literals; using namespace phys::units::literals;
//namespace literals = phys::units::literals; // namespace literals = phys::units::literals;
using LengthType = phys::units::quantity<phys::units::length_d, double>; using LengthType = phys::units::quantity<phys::units::length_d, double>;
using TimeType = phys::units::quantity<phys::units::time_interval_d, double>; using TimeType = phys::units::quantity<phys::units::time_interval_d, double>;
using SpeedType = phys::units::quantity<phys::units::speed_d, double>; using SpeedType = phys::units::quantity<phys::units::speed_d, double>;
using FrequencyType = phys::units::quantity<phys::units::frequency_d, double>; using FrequencyType = phys::units::quantity<phys::units::frequency_d, double>;
using ElectricChargeType = phys::units::quantity<phys::units::electric_charge_d, double>; using ElectricChargeType =
phys::units::quantity<phys::units::electric_charge_d, double>;
using EnergyType = phys::units::quantity<phys::units::energy_d, double>; using EnergyType = phys::units::quantity<phys::units::energy_d, double>;
} // end namespace corsika::units } // end namespace corsika::units
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment