Skip to content

Source Code

Jon Drobny edited this page Mar 3, 2021 · 10 revisions

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, I/O, error handling on input (e.g., making sure that incompatible interaction potentials and root-finders are not used together), constants and imports, enums for controlling various code options, and the data structures Vector and Vector4.

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.

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

Click Pages above to see all pages in the Wiki.

Start Here

Home page

Installation

Selected Benchmarks

Frequently Asked Questions

FAQ

This page is a work in progress.

Using the Standalone Code

Input Files

Output Files

Error Messages

Interaction Potentials

Standalone Code Examples

Layered Targets

2D Geometry

Spherical Geometry

3D Geometry

Gaseous Targets

Multiple Interaction Potentials

Output Histograms

Bindings

Python

C/C++

Fortran

Clone this wiki locally