forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9346d00
commit 85d8ad0
Showing
25 changed files
with
60,887 additions
and
1,911 deletions.
There are no files selected for viewing
This file contains 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
45 changes: 45 additions & 0 deletions
45
source/module_hamilt_general/module_xc/NCLibxc/FibonacciGrid.cpp
This file contains 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <cmath> | ||
|
||
struct Point { | ||
double x, y, z, w; | ||
}; | ||
|
||
std::vector<Point> fibonacci_sphere(int samples) { | ||
std::vector<Point> points; | ||
double phi = M_PI * (std::sqrt(5.0) - 1.0); // golden angle in radians | ||
|
||
for (int i = 0; i < samples; ++i) { | ||
double y = 1.0 - (i / double(samples - 1)) * 2.0; // y goes from 1 to -1 | ||
double radius = std::sqrt(1.0 - y * y); // radius at y | ||
|
||
double theta = phi * i; // golden angle increment | ||
|
||
double x = std::cos(theta) * radius; | ||
double z = std::sin(theta) * radius; | ||
|
||
double w = 1.0 / samples; | ||
|
||
points.push_back({x, y, z, w}); | ||
} | ||
|
||
return points; | ||
} | ||
/* | ||
int main() { | ||
int samples = 10; | ||
auto points = fibonacci_sphere(samples); | ||
double sum_weights = 0.0; | ||
for (const auto& p : points) { | ||
std::cout << "x: " << p.x << ", y: " << p.y | ||
<< ", z: " << p.z << ", w: " << p.w << std::endl; | ||
sum_weights += p.w; | ||
} | ||
std::cout << "Sum of weights: " << sum_weights << std::endl; | ||
return 0; | ||
} | ||
*/ |
13 changes: 13 additions & 0 deletions
13
source/module_hamilt_general/module_xc/NCLibxc/FibonacciGrid.h
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// FibonacciGrid.h | ||
#ifndef FIBONACCIGRID_H | ||
#define FIBONACCIGRID_H | ||
|
||
#include <vector> | ||
|
||
struct Point { | ||
double x, y, z, w; | ||
}; | ||
|
||
std::vector<Point> fibonacci_sphere(int samples); | ||
|
||
#endif // FIBONACCIGRID_H |
Oops, something went wrong.