Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
YuleZhang936 authored Feb 15, 2025
1 parent 9346d00 commit 85d8ad0
Show file tree
Hide file tree
Showing 25 changed files with 60,887 additions and 1,911 deletions.
10 changes: 9 additions & 1 deletion source/module_hamilt_general/module_xc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ add_library(
NCLibxc/interface_to_libxc.cpp
NCLibxc/interface_to_libxc.h
NCLibxc/LebedevGrid.cpp
xc_functional_NCLibxc_gga.cpp
NCLibxc/FibonacciGrid.cpp
NCLibxc/FibonacciGrid.h
NCLibxc/benchmark_tests.cpp
NCLibxc/gga.cpp
NCLibxc/lda.cpp
NCLibxc/mgga.cpp
NCLibxc/math.cpp
NCLibxc/print.cpp
NCLibxc/torque.cpp
)

if(ENABLE_COVERAGE)
Expand Down
45 changes: 45 additions & 0 deletions source/module_hamilt_general/module_xc/NCLibxc/FibonacciGrid.cpp
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 source/module_hamilt_general/module_xc/NCLibxc/FibonacciGrid.h
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
Loading

0 comments on commit 85d8ad0

Please sign in to comment.