Skip to content

feat(hf): add a basic HF example#24

Merged
HaoZeke merged 6 commits into
atomic-solvers:mainfrom
HaoZeke:addHF
Oct 13, 2025
Merged

feat(hf): add a basic HF example#24
HaoZeke merged 6 commits into
atomic-solvers:mainfrom
HaoZeke:addHF

Conversation

@HaoZeke
Copy link
Copy Markdown
Contributor

@HaoZeke HaoZeke commented Oct 12, 2025

@certik this is a tiny example I setup (part of my thesis). Let me know if it looks OK.

@HaoZeke HaoZeke requested a review from Copilot October 12, 2025 17:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/hf.f90 Outdated

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)
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

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

The magic number 4*pi appears multiple times in the code. Consider defining it as a named constant for better maintainability.

Copilot uses AI. Check for mistakes.
Comment thread src/hf.f90 Outdated
Comment on lines +242 to +244
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)
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Comment thread test/test_hf_schroed.f90
real(dp), parameter :: Etot_ref = -14.32329062_dp

Z = 4
rmin = 0
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

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

Using rmin = 0 in radial calculations may cause numerical issues at the origin. Consider using a small positive value to avoid potential singularities.

Suggested change
rmin = 0
rmin = 1e-8_dp

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

Looks good. I would document what exact equations the example is solving. Can be done in subsequent PRs.

@HaoZeke HaoZeke force-pushed the addHF branch 2 times, most recently from ad6c76a to 04850cb Compare October 13, 2025 02:35
@HaoZeke HaoZeke merged commit f0bb173 into atomic-solvers:main Oct 13, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants