Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion Code.v05-00/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
#add_link_options(-fsanitize=bounds -fsanitize=address -fsanitize=undefined)
add_compile_options(-fno-omit-frame-pointer -fsanitize=bounds -fsanitize=undefined)
add_link_options(-fsanitize=bounds -fsanitize=undefined)
elseif (CMAKE_BUILD_TYPE STREQUAL "Profiling")
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -fno-omit-frame-pointer")
elseif (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
include(CheckCXXCompilerFlag)
Expand Down Expand Up @@ -132,4 +135,4 @@ add_subdirectory(tests)

if (DEBUG)
message(STATUS "DEBUG mode is enabled")
endif()
endif()
17 changes: 17 additions & 0 deletions Code.v05-00/include/AIM/Aerosol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ class AIM::Aerosol

/* Moments */
//NOTE: This gives the moment in [- / cm3]. You need to multiply by factors to get it in [ / m] or something.
//NOTE: now returning binMoment without the log bin ratio, as the only instance calling this function already calculates it
inline double binMoment(int iBin, int n = 0) const {
if (n == 0){
return (log(bin_Edges[iBin + 1]) - log(bin_Edges[iBin])) * pdf[iBin]; // if n = 0, it can skip the pow() calculation
}

return (log(bin_Edges[iBin + 1]) - log(bin_Edges[iBin])) * pow(bin_Centers[iBin], n) * pdf[iBin];
Comment thread
coco-yeung marked this conversation as resolved.
}
//NOTE: This gives the moment in [- / cm3]. You need to multiply by factors to get it in [ / m] or something.
template <UInt N> //Template allows us to evaulate the power at compile time to decrease runtime
double Moment() const;
double Moment( UInt n = 0 ) const;
double Radius( ) const;
double EffRadius( ) const;
Expand All @@ -79,6 +86,7 @@ class AIM::Aerosol
inline const Vector_1D& getBinVCenters() const { return bin_VCenters; };
inline const Vector_1D& getBinEdges() const { return bin_Edges; };
inline const Vector_1D& getBinSizes() const { return bin_Sizes; };
inline const Vector_1D& getLogBinEdges() const { return log_Bin_Edges; };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saving the log bins edges is great!

inline UInt getNBin() const { return nBin; };
inline const Vector_1D& getPDF() const { return pdf; };

Expand All @@ -88,6 +96,7 @@ class AIM::Aerosol
Vector_1D bin_VCenters;
Vector_1D bin_Edges;
Vector_1D bin_Sizes;
Vector_1D log_Bin_Edges;
UInt nBin;
Vector_1D pdf; // represents dN [-/cm3] / d(ln r)
};
Expand Down Expand Up @@ -124,8 +133,14 @@ class AIM::Grid_Aerosol
inline void updateNy(int ny_new) { Ny = ny_new; };

/* Moments */
template <UInt N> //Templates allow us to evaulate the power at compile time to decrease runtime
Vector_2D Moment() const;
Vector_2D Moment( UInt n ) const;
template <UInt N>
double Moment( const Vector_1D& PDF ) const;
double Moment( UInt n, const Vector_1D& PDF ) const;
template <UInt N>
double Moment( UInt iNx, UInt jNy ) const;
double Moment( UInt n, UInt iNx, UInt jNy ) const;

/* Extra utils */
Expand Down Expand Up @@ -177,6 +192,7 @@ class AIM::Grid_Aerosol
inline const Vector_3D& getBinVCenters() const { return bin_VCenters; };
inline const Vector_1D& getBinEdges() const { return bin_Edges; };
inline const Vector_1D& getBinSizes() const { return bin_Sizes; };
inline const Vector_1D& getLogBinEdges() const { return log_Bin_Edges; };
inline UInt getNBin() const { return nBin; };
inline const Vector_3D& getPDF() const { return pdf; };
inline Vector_3D& getPDF() { return pdf; };
Expand All @@ -189,6 +205,7 @@ class AIM::Grid_Aerosol
Vector_1D bin_Edges;
Vector_1D bin_VEdges;
Vector_1D bin_Sizes;
Vector_1D log_Bin_Edges;
UInt nBin;
unsigned int Nx, Ny;
Vector_3D pdf; //Everything with the pdf is implicitly in [ / cm3]
Expand Down
10 changes: 6 additions & 4 deletions Code.v05-00/include/Util/MetFunction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ namespace met
Atmospheric Chemistry and Physics
https://doi.org/10.5194/acp-22-10919-2022
*/

double rhi_abs = rhi * 0.01;

double rhi_abs = rhi / 100.0;
double rhi_abs_a = rhi_abs / a;

double rhi_corr = (rhi_abs / a) <= 1
? rhi_abs / a
: std::min(std::pow(rhi_abs / a, b), 1.65);
double rhi_corr = (rhi_abs_a) <= 1
? rhi_abs_a
: std::min(std::pow(rhi_abs_a, b), 1.65);
return rhi_corr * 100.0;
}
struct newXCoordsPair {
Expand Down
Loading