Skip to content

PolskaKrowa/nuclear-physics-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

103 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โš›๏ธ Nuclear Physics Library

High-Performance Fortran Toolkit for Reactor Simulations & Multiphysics Studies

GitHub Actions Workflow Status License Release Fortran

Features โ€ข Installation โ€ข Documentation โ€ข Contributing โ€ข Roadmap


๐Ÿ“š Overview

Nuclear Physics Library is a comprehensive Fortran toolkit providing utilities, numerical solvers, and physics models to support the development of reactor simulations and multiphysics studies. Built for performance and accuracy, it offers a complete suite of mathematical kernels and physics models.

โœจ Features

๐Ÿ”ง Core Utilities
Component Description
Precision Control Standardised kind parameters (single, double, quad precision)
Physical Constants Mathematical and physical constants with high accuracy
Random Number Generation Deterministic RNG with multiple distributions
Numerical Utilities Array operations, interpolation, integration, and safety functions
๐Ÿงฎ Mathematical Kernels

Linear Algebra

  • โœ… Dense matrix operations using BLAS/LAPACK
  • โœ… Eigenvalue solvers (symmetric, general, generalised)
  • โœ… Linear system solvers (LU, Cholesky, iterative methods)
  • โœ… Sparse matrix operations (CSR format)
  • โœ… SVD, QR, and Schur decompositions

ODE Solvers

Method Type Use Case
RK4 Explicit Classic fourth-order Runge-Kutta
DOPRI5 Adaptive Dormand-Prince with adaptive step-size
Backward Euler Implicit Stiff equations

Optimisation Algorithms

  • Gradient Methods: Gradient descent (with momentum, Adam)
  • Conjugate Gradient: Fletcher-Reeves, Polak-Ribiรจre
  • Quasi-Newton: BFGS, L-BFGS
  • Constrained: Projected gradient, penalty methods

PDE Methods

  • Finite Difference: Various accuracy orders and boundary conditions
  • Finite Volume: Conservation law solvers with multiple flux schemes
  • Spectral Methods: FFT-based derivatives and Poisson solvers
โšก Physics Models
Model Capabilities
Fluid Dynamics Incompressible Navier-Stokes, projection method, natural convection, multi-region support
Heat Transfer Diffusion-convection with sources, multi-material regions, coupled flow
Nuclear Fission Point kinetics, multi-group diffusion, decay heat (ANS-5.1), 6-group precursors
Pressure Dynamics Multiple EOS, acoustic waves, phase transitions, compressibility

๐Ÿš€ Installation

Prerequisites

Important

Ensure you have the following installed:

  • Fortran Compiler: gfortran 9.0+ or Intel Fortran
  • CMake: Version 3.20 or higher
  • BLAS/LAPACK: For linear algebra operations
  • MSYS2: Required for Windows compilation

Quick Start

# Clone the repository
git clone https://github.com/PolskaKrowa/nuclear-physics-library.git
cd nuclear-physics-library/

# Create and enter build directory
mkdir build && cd build

# Configure with CMake
cmake ..

# Build the library (using all available cores)
make -j$(nproc)

# Install to system (requires sudo)
sudo make install

Custom Installation

cmake -DCMAKE_INSTALL_PREFIX=/path/to/install ..
make -j$(nproc)
make install

Build Configurations

Configuration Command Use Case
Release cmake -DCMAKE_BUILD_TYPE=Release .. Production with optimisations
Debug cmake -DCMAKE_BUILD_TYPE=Debug .. Development with symbols
Intel Compiler cmake -DCMAKE_Fortran_COMPILER=ifort .. Intel-optimised builds

Manual Library Specification

Note

CMake may require manual specification of BLAS/LAPACK locations:

cmake -DBLAS_LIBRARIES=/path/to/libblas.so \
      -DLAPACK_LIBRARIES=/path/to/liblapack.so ..

Tip

OpenBLAS Support: This programme supports OpenBLAS, which includes LAPACK in the same .so file. However, both libraries must still be passed to CMake for proper linking.

Platform-Specific Dependencies

๐Ÿง Ubuntu/Debian
sudo apt-get update
sudo apt-get install gfortran cmake libblas-dev liblapack-dev
๐ŸŽ macOS
brew install gcc cmake openblas lapack
๐ŸŽฉ Red Hat/CentOS
sudo yum install gcc-gfortran cmake blas-devel lapack-devel

๐Ÿ“ Module Organisation

nuclear-physics-library/
โ”œโ”€โ”€ ๐Ÿ“ฆ core/                    # Foundational utilities
โ”‚   โ”œโ”€โ”€ kinds.f90              # Precision definitions
โ”‚   โ”œโ”€โ”€ constants.f90          # Physical/mathematical constants
โ”‚   โ”œโ”€โ”€ numeric_utils.f90      # Numerical utilities
โ”‚   โ””โ”€โ”€ rng.f90                # Random number generation
โ”‚
โ”œโ”€โ”€ ๐Ÿงฎ kernels/                 # Mathematical methods
โ”‚   โ”œโ”€โ”€ linear_algebra/        # Matrix operations
โ”‚   โ”œโ”€โ”€ ode/                   # ODE solvers
โ”‚   โ”œโ”€โ”€ optimisation/          # Optimisation algorithms
โ”‚   โ””โ”€โ”€ pde/                   # PDE methods
โ”‚
โ””โ”€โ”€ โšก models/                  # Physics models
    โ”œโ”€โ”€ burnup_depletion.f90
    โ”œโ”€โ”€ cross_sections.f90
    โ”œโ”€โ”€ multigroup_diffusion.f90
    โ”œโ”€โ”€ two_phase_flow.f90
    โ”œโ”€โ”€ fluid_dynamics.f90
    โ”œโ”€โ”€ heat_transfer.f90
    โ”œโ”€โ”€ nuclear_fission.f90
    โ””โ”€โ”€ pressure_dynamics.f90

๐Ÿ“– Dependencies

Required

  • โœ… Fortran compiler (gfortran 9.0+ or Intel Fortran)
  • โœ… CMake 3.20+
  • โœ… BLAS/LAPACK libraries

Optional

  • ๐Ÿ”„ FFTW3 (for optimised spectral methods)
  • ๐Ÿ”„ MPI (for parallel simulations)
  • ๐Ÿ”„ OpenMP (for shared-memory parallelisation)

โšก Performance Considerations

Compiler Optimisation Flags

The CMakeLists.txt file provides aggressive optimisation flags:

Compiler Flags
GNU -Ofast -march=native -mtune=native -flto
Intel -O3 -xHost

BLAS/LAPACK Performance

Tip

For optimal performance, use these BLAS implementations:

  • Intel MKL: Best for Intel CPUs
  • OpenBLAS: Good general-purpose choice
  • ATLAS: Auto-tuned alternative

Example with MKL:

cmake -DBLA_VENDOR=Intel10_64lp ..

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create a feature branch (git checkout -b feature/amazing-feature)
  3. ๐Ÿ’พ Commit your changes (git commit -m 'Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐Ÿ”€ Open a Pull Request

Code Style Guidelines

Guideline Requirement
Indentation 4 spaces
Line Length 100 characters maximum (excluding indentation)
Naming Descriptive variable names
Documentation Comments for complex algorithms
Structure Follow existing module organisation

๐Ÿ“„ Licence

This project is licensed under the Apache V2.0 Licence - see the LICENCE file for details.

๐Ÿ“ Citation

If you use this library in your research, please cite:

@software{nuclear_physics_library,
  title = {Nuclear Physics Library: A Fortran Library for Reactor Simulation},
  author = {Stevenson Parker},
  year = {2025},
  url = {https://github.com/PolskaKrowa/nuclear-physics-library}
}

๐Ÿ™ Acknowledgements

  • LAPACK and BLAS developers for linear algebra routines
  • The Fortran community for continued language development
  • Contributors and users of this library

๐Ÿ“ฌ Contact

๐Ÿ—บ๏ธ Roadmap

๐Ÿ”ฎ Planned Features

  • MPI parallelisation for distributed computing
  • Python bindings via f2py
  • I/O and Visualisation (HDF5, VTK, etc.)
  • Reactor control modules
  • Material Properties database
  • Detailed fuel modelling
  • Enhanced testing suite (unit tests, benchmarks, verification tests)

๐Ÿšง In Progress

  • Additional reactor geometries (hexagonal, cylindrical)
  • Advanced turbulence models
  • OpenMP threading for shared-memory systems
  • Improved performance for real-time/faster-than-real-time simulation

๐Ÿ“‹ Version History

v0.2.0 (current)
  • Enhanced neutronics models
  • Improved fluid dynamics simulation
  • Consistent testing suite
v0.1.0
  • Initial release
  • Core utilities and mathematical kernels
  • Basic physics models (fluid, heat, fission, pressure)
  • Single-threaded implementation

Note: This library is intended for educational and research purposes.

Made with โค๏ธ and ๐Ÿง  by Steve

About

A library for the assistance of the development of nuclear reactor simulations

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors