Skip to content

One velocity monte carlo for the rod problem with advection-diffusion of DNPs

License

Notifications You must be signed in to change notification settings

milliCoulomb/monte_carlo_rod

Repository files navigation

1D Monte-Carlo advection-diffusion of DNPs

License: MIT C++ Build Status Build Status OpenMP

Table of Contents

Overview

Neutron Transport Solver for the Rod Problem is a small C++ project designed to simulate neutron transport in a periodic 1D system with Delayed Neutron Precursors (DNPs) advection and diffusion. It reads solver options, cross-sections, and geometrical parameters from a JSON configuration file. Advection-diffusion of DNPs is modeled by solving their Stochastic Differential Equations within a continuous diffusion/velocity field.

Features

  • Parallelization: Utilizes OpenMP and MPI for scalable performance.
  • Configurable: Reads parameters from a JSON configuration file for flexibility.
  • Modular Structure: Organized into src, include, and test directories for maintainability.
  • Unit Testing: Incorporates Google Test for robust testing.
  • CMake Build System: Simplifies building and managing dependencies.

Prerequisites

Ensure the following dependencies are installed on your system:

  • C++ Compiler with C++17 support
  • CMake (version 3.10 or later)
  • OpenMP
  • MPI (e.g., MPICH or OpenMPI)
  • nlohmann/json library for JSON parsing

Project Structure

monte_carlo_rod/
├── CMakeLists.txt
├── README.md
├── config.json
├── external/
│   └── googletest/ (Git submodule)
├── include/
│   ├── GaussianProfile.h
│   ├── Neutron.h
│   ├── NeutronMPI.h
│   ├── PhysicalProperties.h
│   ├── RodGeometry.h
│   ├── Settings.h
│   ├── Solver.h
│   └── Tallies.h
├── src/
│   ├── GaussianProfile.cpp
│   ├── main.cpp
│   ├── NeutronMPI.cpp
│   ├── PhysicalProperties.cpp
│   ├── RodGeometry.cpp
│   └── Solver.cpp
├── test/
│   ├── CMakeLists.txt
│   └── ... (unit tests)
└── json.hpp

Directory Overview

  • CMakeLists.txt: Root CMake build configuration file.
  • config.json: Configuration file containing solver options, cross-sections, and geometrical parameters.
  • external/: Contains external dependencies as Git submodules (e.g., Google Test).
  • include/: Header files (.h) for classes and modules.
  • src/: Source files (.cpp) implementing the functionality.
  • test/: Unit tests utilizing Google Test.
  • json.hpp: Single-header JSON library from nlohmann/json.

Configuration

The solver reads its parameters from a config.json file. Below is an example configuration:

{
    "ell": 3.0,
    "Hout": 3.0,
    "velocity_base": 1e-20,
    "n_cells": 600,
    "sigma_a": 1.0,
    "sigma_s": 98.0,
    "sigma_f": 0.7,
    "nu": 2.45,
    "alpha": 0.5,
    "n_histories": 20000,
    "max_generations": 4000,
    "n_inactive": 2500,
    "w_min": 0.8,
    "w_survive": 1.0,
    "w_max": 2.0,
    "beta": 0.1,
    "lambda": 0.1,
    "diffusion_coefficient_base": 1e-20,
    "keff_output_file": "keffs.txt",
    "volume_flux_output_file": "volume_flux.txt",
    "fission_sites_per_cell_output_file": "fission_sites.txt",
    "verbose": true,
    "with_dnps_deterministic_transport": false,
    "with_pixel_art": true,
    "DNPs_continuous_transport": true,
    "use_milstein": true,
    "N_time_steps": 8000,
    "T_max_dnps": 100.0,
    "velocity_gaussian_profiles": [
        {
            "position": 1.0,
            "width": 0.5,
            "amplitude": 1e-1
        }
    ],
    "diffusion_gaussian_profiles": [
        {
            "position": 3.2,
            "width": 0.2,
            "amplitude": 1e-20
        }
    ]
}

Installation

Cloning the Repository

First, clone the repository along with its submodules:

git clone --recurse-submodules https://github.com/milliCoulomb/monte_carlo_rod.git
cd monte_carlo_rod

If you have already cloned the repository without the submodules, initialize them with:

git submodule update --init --recursive

Building the Project

  1. Create a Build Directory:

    It is recommended to build the project in a separate directory to keep the source tree clean.

    mkdir build
    cd build
  2. Generate Build Files with CMake:

    cmake ..

    This command will configure the project and generate the necessary Makefiles or project files for your environment.

  3. Build the Project:

    make

    This will compile the source code and build the executable.

Running the Solver

Ensure that the config.json file is located in the same directory as the executable or provide the path to it. From the build directory, run:

./monte_carlo_rod ../config.json

Parameters:

  • config.json: Path to the configuration file containing solver parameters.

Output:

The solver will output results to the console, including:

  • Final keff values
  • Mean keff
  • Standard deviation of keff
  • Additional results as specified in the configuration (e.g., volume flux, fission sites)

Testing

Unit tests are located in the test/ directory and utilize Google Test. To run the tests:

  1. Navigate to the Build Directory:

    cd build
  2. Build the Tests:

    make test
  3. Run the Tests:

    ctest

    Alternatively, you can run specific test executables directly:

    ./test/your_test_executable

License

This project is licensed under the MIT License. You are free to use, modify, and distribute this software as per the terms of the license.

Releases

No releases published

Packages

No packages published

Languages