Developer Guide
If you are planning significant changes, please open an issue first. The ColPrac guidelines are recommended. For Julia package development basics, see:
Local Setup
This procedure is required only once. Install Git and Julia on your local machine before starting.
Fork the repository on GitHub.
Clone the forked repository. Replace
xxxxxxwith your GitHub username.git clone https://github.com/xxxxxx/TwoBody.jl.git cd TwoBody.jlInstall Revise.jl.
julia --startup-file=no -e 'import Pkg; Pkg.add("Revise")'
Development Flow
This is the typical workflow for making changes.
Create a branch for your changes. Replace
xxxwith the issue number, for exampleissue/20.git switch -c issue/xxxStart an interactive session with Revise.jl.
julia --startup-file=no -i -e 'using Revise; import Pkg; Pkg.activate("."); using TwoBody'Change the source code. When adding functions or updating docstrings, refer to Documenter: Adding docstrings.
If you need a new dependency, replace
SomePackagewith its package name and run:julia --project=. --startup-file=no -e 'import Pkg; Pkg.add("SomePackage"); Pkg.resolve(); Pkg.instantiate()'Run the tests. They may take a few minutes.
julia --project=. --startup-file=no -e 'using Pkg; Pkg.test()'Build the documentation locally. HTML files are generated in
docs/build/; opendocs/build/index.htmlin a web browser to review them.julia --project=docs --startup-file=no -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' julia --project=docs --startup-file=no -e 'include("docs/make.jl")'After the tests and documentation build succeed, commit and push the changed files.
git add "path/to/changed/file" git commit -m "commit message" git push origin issue/xxxSubmit a pull request on GitHub.
GitHub Actions
CI tests Julia 1.10 and 1.12, checks installation without optional solver dependencies, and builds the documentation. The Julia 1.10 test job collects coverage for src and ext, converts it to lcov.info, and uploads it to Codecov. Repository builds other than Dependabot runs authenticate using GitHub OIDC; no CODECOV_TOKEN secret is needed. Upload errors fail these jobs so that a broken integration is visible. Fork and Dependabot runs attempt tokenless uploads without OIDC; failures in the upload step do not fail their test jobs. Test and coverage-generation failures still fail CI. Codecov's action handles public fork PRs using prefixed branch names, so organization-wide token authentication can remain enabled; see Codecov's token documentation.
To check formatting, run Runic formatting from the repository's Actions tab and select the branch to check. The workflow reports formatting differences as a failed check and saves a runic-formatting-patch artifact only when the patch is nonempty. Download and extract the artifact, then apply runic.patch with git apply runic.patch in a checkout of the same commit. Review and commit the changes as usual. Formatting runs only on manual dispatch.
CompatHelper runs daily and can also be dispatched manually. In Settings > Actions > General, enable Allow GitHub Actions to create and approve pull requests so that it can open dependency updates. If GitHub disables its schedule after repository inactivity, re-enable the workflow in the Actions tab. The workflow uses DOCUMENTER_KEY as COMPATHELPER_PRIV so its pull requests can trigger CI.
TagBot uses GITHUB_TOKEN to create releases and DOCUMENTER_KEY to push tags that trigger documentation builds. The key must be configured as a deploy key with write access. Releases for commits that modify workflow files may require manual creation or a personal access token with workflow scope; see the TagBot troubleshooting guide.
Adding New Operators and Solvers
TwoBody.jl uses Julia's multiple dispatch to keep the physical problem separate from its numerical solution.
Operators
- Define the operator in
src/Hamiltonian.jlas a subtype ofKineticTermorPotentialTerm. - Implement the solver-specific operations required to support it, such as
element,matrix, or local-energy evaluation. - Add tests to the corresponding files under
test/. - Add or update the mathematical definition and API documentation under
docs/src/.
An unsupported operator–solver combination should fail explicitly rather than silently choosing an approximation.
Solvers
- Create
src/MethodName.jland define the method type and itssolve(hamiltonian::Hamiltonian, method::MethodName; ...)implementation. - Include the source file from
src/TwoBody.jlafter its dependencies. - Create
test/MethodName.jland include it fromtest/runtests.jl. - Create
docs/src/MethodName.mdand add it to thepageslist indocs/make.jl. - Run the complete test suite and documentation build as described in Development Flow.
Versioning and Registering (for Maintainers)
This project follows Semantic Versioning. When bumping the version, update version in Project.toml.
To register a release in the General registry, use Registrator through its GitHub App workflow.
Architecture
src/TwoBody.jl defines the TwoBody module and includes the source files in dependency order. Hamiltonian.jl defines the shared problem representation. Basis.jl supports the Rayleigh–Ritz implementation, and FDM.jl supplies the discretization used by the variational neural-network method. The solver files extend solve for their respective method types.
--- config: layout: elk theme: mc --- flowchart TD H["Hamiltonian.jl"] D["DB.jl"] B["Basis.jl"] R["Rayleigh-Ritz.jl"] F["FDM.jl"] Q["QTT.jl"] N["VNN.jl"] V["VMC.jl"] T["TwoBody.jl"] H --> D H --> R & F & Q & N & V B --> R F --> N H & D & B & R & F & Q & N & V --> T