feat(hf): add a basic HF example#24
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a basic Hartree-Fock (HF) example implementation for atomic calculations. The implementation includes a new HF module with Slater exchange approximation and a corresponding test case for Beryllium (Z=4).
- Added a new HF module with Hartree-Fock solver using Slater exchange
- Created a test program for HF calculations on Beryllium atoms
- Integrated the new module and test into the build system
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/hf.f90 | New HF module implementing Hartree-Fock solver with Slater exchange potential |
| test/test_hf_schroed.f90 | Test program demonstrating HF calculation for Beryllium (Z=4) |
| src/meson.build | Added hf.f90 to the source files list |
| meson.build | Added HF test to the test array |
Comments suppressed due to low confidence (1)
src/hf.f90:1
- Using a literal 0 for rmin could cause issues in radial calculations. Consider using a small positive value like 1e-10_dp to avoid singularities at r=0.
module hf
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| call c2fullc2(in, ib, D(:Nb,i), fullc) | ||
| call fe2quad_core(xe, xin, in, fullc, phihq, uq) | ||
| rho = rho - focc(i,l)*(uq/xq)**2 / (4*pi) |
There was a problem hiding this comment.
The magic number 4*pi appears multiple times in the code. Consider defining it as a named constant for better maintainability.
| real(dp), parameter :: C_x = -1.5_dp * (3.0_dp / pi)**(1.0_dp/3.0_dp) | ||
|
|
||
| Vx = C_x * sign(1.0_dp, rho) * abs(rho)**(1.0_dp/3.0_dp) |
There was a problem hiding this comment.
The magic number 1.0_dp/3.0_dp for the exchange potential exponent should be defined as a named constant for clarity and maintainability.
| real(dp), parameter :: C_x = -1.5_dp * (3.0_dp / pi)**(1.0_dp/3.0_dp) | |
| Vx = C_x * sign(1.0_dp, rho) * abs(rho)**(1.0_dp/3.0_dp) | |
| real(dp), parameter :: EXCHANGE_EXPONENT = 1.0_dp/3.0_dp | |
| real(dp), parameter :: C_x = -1.5_dp * (3.0_dp / pi)**(EXCHANGE_EXPONENT) | |
| Vx = C_x * sign(1.0_dp, rho) * abs(rho)**(EXCHANGE_EXPONENT) |
| real(dp), parameter :: Etot_ref = -14.32329062_dp | ||
|
|
||
| Z = 4 | ||
| rmin = 0 |
There was a problem hiding this comment.
Using rmin = 0 in radial calculations may cause numerical issues at the origin. Consider using a small positive value to avoid potential singularities.
| rmin = 0 | |
| rmin = 1e-8_dp |
certik
left a comment
There was a problem hiding this comment.
Looks good. I would document what exact equations the example is solving. Can be done in subsequent PRs.
ad6c76a to
04850cb
Compare
@certik this is a tiny example I setup (part of my thesis). Let me know if it looks OK.