Source Code - lcpp-org/RustBCA GitHub Wiki
Docs
Rustbca includes doc comments. Documentation for the source code can be built using cargo docs --no-deps and with the flag --all-features if one wants to build documentation for HDF5 input or the CPR rootfinder.
Once built with cargo docs, documentation can be found in target/docs/rustBCA/index.html.
Code Structure
RustBCA is structured, wherever possible, to enhance readability, especially compared to legacy codes that precede it. It is broken up into several modules: main.rs, particle.rs, material.rs, mesh.rs, bca.rs, interactions.rs, and tests.rs. Each of these modules is relatively self contained. Functions that can fail use the anyhow crate to return Results, so that error handling is precise and explanatory.
Modules
Main
main.rs includes the core code loop, including the core physics loop. main() contains the geometry match arms that take command line input.
Input
input.rs handles the processing of the toml-format input file and creates the Material and Particle array.
Output
output.rs includes the routines for creating output files, processing particles to produce, e.g., sputtered energy distributions, and printing the processed particle data to file.
Particle
particle.rs includes the Particle struct, used for tracking ions and atoms in the code. Functions for rotation, advancement in space, and refraction of particles at material surfaces are also included.
Material
material.rs contains the Material struct and associated functions. Material includes methods for determining the electronic stopping power, pulling information from the mesh, and determining whether points are inside or outside of the material.
Geometry
geometry.rs contains the Geometry and GeometryElement traits and the Mesh0D, Mesh1D, and Mesh2D structs and associated data structures and functions for handling inhomogeneous composition of materials.
Sphere
sphere.rs contains the implementation of the Geometry trait for the Sphere geometry type.
BCA
bca.rs contains the main BCA algorithms that involve both particles and materials, including distance of closest approach rootfinding calculation, and scattering angle determination.
Interactions
interactions.rs contains the interatomic potentials used in the code, the distance of closest approach functions, polynomial solver helper functions, scaling functions, and various screening lengths associated with the interatomic potentials in the code.
Tests
tests.rs contains all testing routines, including both unit tests and integration tests. Writing tests for rustbca is a work in progress. Currently, the code checks that momentum is conserved during an entire BCA step, that the numerical quadratures agree with one another, that the distance of closest approach algorithms agree with one another, and that the geometry correctly handles distances and inside/outside checks on the various geometry types.
Enums, Consts, Structs
These hold simulation-wide enums, constants, and structs (such as Vector).