Update formatting

This commit is contained in:
2023-10-23 10:52:38 +02:00
parent d08a4a046c
commit 79da936956
8 changed files with 102 additions and 109 deletions

View File

@@ -14,12 +14,13 @@
#include <armadillo>
#include "typedefs.hpp"
#include "constants.hpp"
#include "typedefs.hpp"
/** @brief A class that holds attributes of a particle
* */
class Particle {
class Particle
{
private:
vec_3d r_vec; ///< position
vec_3d v_vec; ///< velocity
@@ -37,7 +38,8 @@ public:
* @param r_vec The initial position of the particle
* @param v_vec The initial velocity of the particle
* */
Particle(vec_3d r_vec, vec_3d v_vec, double q = CA_CHARGE, double m = CA_MASS);
Particle(vec_3d r_vec, vec_3d v_vec, double q = CA_CHARGE,
double m = CA_MASS);
/** @brief Make private attributes available for PenningTrap.
* */

View File

@@ -12,14 +12,24 @@
#ifndef __CONST__
#define __CONST__
#define K_E 1.38935333*1e5 ///< Coulomb constant. unit: \f$\frac{u(\mu m)^3}{(\mu s)^2 e^2}\f$
/** @brief Coulomb constant. unit: \f$\frac{u(\mu m)^3}{(\mu s)^2 e^2}\f$
* */
#define K_E 1.38935333 * 1e5
#define T 9.64852558*1e1 ///< 1 Tesla. unit: \f$ \frac{u}{(\mu s) e} \f$
/** @brief 1 Tesla. unit: \f$ \frac{u}{(\mu s) e} \f$
* */
#define T 9.64852558 * 1e1
#define V 9.64852558*1e7 ///< 1 Volt. unit: \f$ \frac{u (\mu m)^2}{(\mu s)^2 e} \f$
/** @brief 1 Volt. unit: \f$ \frac{u (\mu m)^2}{(\mu s)^2 e} \f$
* */
#define V 9.64852558 * 1e7
#define CA_MASS 40.078 ///< Mass of a single calcium ion. unit: amu
/** @brief Mass of a single calcium ion. unit: amu
* */
#define CA_MASS 40.078
#define CA_CHARGE 1. ///< Charge of a singly charged calcium ion. unit: e
/** @brief Charge of a singly charged calcium ion. unit: e
* */
#define CA_CHARGE 1.
#endif

View File

@@ -7,7 +7,7 @@
*
* @brief Useful typedefs for cleaner code.
*
* @details These typedefs make the code more readable and easy to follow
* @details These typedefs make the code more readable and easy to follow
* along.
*
* @bug No known bugs
@@ -18,7 +18,7 @@
#include <armadillo>
#include <vector>
/** @brief Typedef for the column of the result vector from simulating
/** @brief Typedef for the column of the result vector from simulating
* particles.
* */
typedef std::vector<arma::vec::fixed<3>> sim_cols;

View File

@@ -27,14 +27,14 @@
*
* This macro writes a debug message that includes the filename,
* line number, and a custom message. The function is wrapped in an ifdef
* that checks if DBG is defined, so one can choose to display the debug
* that checks if DBG is defined, so one can choose to display the debug
* messages by adding the -DDBG flag when compiling.
* */
#ifdef DBG
#define DEBUG(msg) std::cout << __FILE__ << " " << __LINE__ << ": " \
<< msg << std::endl
#define DEBUG(msg) \
std::cout << __FILE__ << " " << __LINE__ << ": " << msg << std::endl
#else
#define DEBUG(msg)
#define DEBUG(msg)
#endif
/** @def ASSERT(expr)
@@ -43,15 +43,14 @@
* This macro calls the m_assert function which is a more informative
* assertion function than the regular assert function from cassert.
* */
#define ASSERT(expr, msg) m_assert(expr, #expr, __METHOD_NAME__, __FILE__, \
__LINE__, msg)
#define ASSERT(expr, msg) \
m_assert(expr, #expr, __METHOD_NAME__, __FILE__, __LINE__, msg)
/** @def __METHOD_NAME__
* @brief Get the name of the current method/function without the return type.
* */
#define __METHOD_NAME__ methodName(__PRETTY_FUNCTION__)
/** @brief Turns a double into a string written in scientific format.
*
* @details The code is stolen from https://github.com/anderkve/FYS3150.
@@ -62,11 +61,11 @@
*
* @return std::string
* */
std::string scientific_format(double d, int width=20, int prec=10);
std::string scientific_format(double d, int width = 20, int prec = 10);
/** @brief Turns a vector of doubles into a string written in scientific format.
*
/** @brief Turns a vector of doubles into a string written in scientific
* format.
*
* @details The code is stolen from https://github.com/anderkve/FYS3150.
*
* @param v The vector to stringify
@@ -75,14 +74,12 @@ std::string scientific_format(double d, int width=20, int prec=10);
*
* @return std::string
* */
std::string scientific_format(const std::vector<double>& v,
int width=20,
int prec=10);
std::string scientific_format(const std::vector<double> &v, int width = 20,
int prec = 10);
/** @brief Test an expression, confirm that test is ok, or abort execution.
*
* @details This function takes in an expression and prints an OK message if
* @details This function takes in an expression and prints an OK message if
* it's true, or it prints a fail message and aborts execution if it fails.
*
* @param expr The expression to be evaluated
@@ -92,17 +89,12 @@ std::string scientific_format(const std::vector<double>& v,
* @param line The line number where this function is called from
* @param msg The message to be displayed
* */
void m_assert(bool expr,
std::string expr_str,
std::string func,
std::string file,
int line,
std::string msg);
void m_assert(bool expr, std::string expr_str, std::string func,
std::string file, int line, std::string msg);
/** @brief Test if two armadillo vectors are close to each other.
*
* @details This function takes in 2 vectors and checks if they are
* @details This function takes in 2 vectors and checks if they are
* approximately equal to each other given a tolerance.
*
* @param a Vector a
@@ -111,8 +103,7 @@ void m_assert(bool expr,
*
* @return bool
* */
bool close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
bool close_to(arma::vec &a, arma::vec &b, double tol = 1e-8);
/** @brief Takes in the __PRETTY_FUNCTION__ string and removes the return type.
*
@@ -124,16 +115,15 @@ bool close_to(arma::vec &a, arma::vec &b, double tol=1e-8);
*
* @return std::string
* */
static inline std::string methodName(const std::string& pretty_function)
static inline std::string methodName(const std::string &pretty_function)
{
size_t colons = pretty_function.find("::");
size_t begin = pretty_function.substr(0,colons).rfind(" ") + 1;
size_t begin = pretty_function.substr(0, colons).rfind(" ") + 1;
size_t end = pretty_function.rfind("(") - begin;
return pretty_function.substr(begin,end) + "()";
return pretty_function.substr(begin, end) + "()";
}
/** @brief Make path given.
*
* @details This tries to be the equivalent to "mkdir -p" and creates a new