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.
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.