-
Notifications
You must be signed in to change notification settings - Fork 23
Reduce usage of pow() and log() #92
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
Open
coco-yeung
wants to merge
14
commits into
MIT-LAE:main
Choose a base branch
from
coco-yeung:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9ad5c82
Experimental set up
coco-yeung 8f5cd64
Add input files for different weather conditions
coco-yeung 1d358b5
Reduced usage of pow() (and log())
coco-yeung 310a049
Fix parallelisation bug (#9)
coco-yeung 0238044
Added comments
coco-yeung 5f37b26
Editted CMakeLists.txt
coco-yeung 2616450
Removed some changes and improved readability
coco-yeung 3747189
Added more temp variables for readability
coco-yeung 1ba32c5
Returning the correct Moment for n > 3
coco-yeung a1f588f
Reverted KPP changes
coco-yeung 7f0b315
Typo
coco-yeung 47006bc
Merge branch 'MIT-LAE:main' into main
coco-yeung bdde8b7
Made changes according to comments
cocoyeung1 82f7e04
Delete yaml files
cocoyeung1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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]; | ||
| } | ||
| //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; | ||
|
|
@@ -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; }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; }; | ||
|
|
||
|
|
@@ -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) | ||
| }; | ||
|
|
@@ -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 */ | ||
|
|
@@ -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; }; | ||
|
|
@@ -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] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.