From f28c42d914e19637ccd78f36e9e21f7e5e2fd131 Mon Sep 17 00:00:00 2001 From: jmeneghini Date: Sat, 20 Jan 2024 13:02:56 -0500 Subject: [PATCH] added script to build all cpp sims. Dropped photon count across the board in the sims for shorter example run times --- CMakeLists.txt | 4 +-- Dockerfile | 3 +++ README.md | 7 ++++- .../CT_w_voxelized_solid.cpp | 2 +- .../half_value_layer/hvl_100kVp.cpp | 2 +- .../half_value_layer/hvl_100keV.cpp | 2 +- .../half_value_layer/hvl_30kVp.cpp | 2 +- .../half_value_layer/hvl_30keV.cpp | 2 +- cpp_simulations/radiography/radiography.cpp | 2 +- .../radiography/radiography_15_degrees.cpp | 2 +- utility_scripts/build_cpp_sims.sh | 26 +++++++++++++++++++ 11 files changed, 44 insertions(+), 10 deletions(-) create mode 100755 utility_scripts/build_cpp_sims.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a03ce3f..c8e976f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,8 +35,6 @@ target_include_directories(MIDSX PUBLIC add_git_submodule(${CMAKE_CURRENT_LIST_DIR}/extern/eigen) target_link_libraries(MIDSX PUBLIC Eigen3::Eigen) - - # Specify the Python interpreter find_package(Python3 COMPONENTS Interpreter Development) if(Python3_FOUND) @@ -74,6 +72,8 @@ configure_file( @ONLY ) + + # Installation and export install(TARGETS MIDSX EXPORT MIDSXTargets diff --git a/Dockerfile b/Dockerfile index 7056fe1d..3a8b1df8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,9 @@ COPY . . # Build and install MIDSX RUN mkdir build && cd build && cmake .. && make install +# Build the cpp_sims +RUN ./../scripts/build_cpp_sims.sh + diff --git a/README.md b/README.md index 26a9bdf0..669ea5b1 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,11 @@ To install with the command line: sudo make install ``` +4. To build all the cpp_simulations (not required) assuming you are still in the build directory: + ```sh + ./../utility_scripts/build_cpp_sims.sh + ``` + ### Installation (Docker) MIDSX can be built and run in a Docker container. This is currently the only way to build on MacOS. \ @@ -81,7 +86,7 @@ Then, to run the container with an interactive shell: ```sh docker run -it jmeneghini/midsx:latest ``` -The container will have already installed MIDSX and its dependencies, so you can start using it right away. +The container will have already installed/compiled MIDSX, its dependencies, and the cpp_simulations, so you can start using it right away. ## Documentation The [documentation](https://jmeneghini.github.io/MIDSX/) for MIDSX is generated via Doxygen and is hosted with Github Pages. \ diff --git a/cpp_simulations/CT_w_voxelized_solid/CT_w_voxelized_solid.cpp b/cpp_simulations/CT_w_voxelized_solid/CT_w_voxelized_solid.cpp index 83dc2664..547d1b3d 100644 --- a/cpp_simulations/CT_w_voxelized_solid/CT_w_voxelized_solid.cpp +++ b/cpp_simulations/CT_w_voxelized_solid/CT_w_voxelized_solid.cpp @@ -159,7 +159,7 @@ int main() { PhotonSource source = initializeSource(); - const int NUM_OF_PHOTONS = 100000000; + const int NUM_OF_PHOTONS = 1000000; std::cout << std::fixed << std::setprecision(15); diff --git a/cpp_simulations/half_value_layer/hvl_100kVp.cpp b/cpp_simulations/half_value_layer/hvl_100kVp.cpp index 0b5f5644..e8b9226c 100644 --- a/cpp_simulations/half_value_layer/hvl_100kVp.cpp +++ b/cpp_simulations/half_value_layer/hvl_100kVp.cpp @@ -66,7 +66,7 @@ int main() { PhotonSource source = initializeSource(); - int N_PHOTONS = 100000000; + int N_PHOTONS = 1000000; runSimulation(source, physics_engine, initializeSurfaceTallies, [](){return std::vector>();}, N_PHOTONS); auto surface_tally_results = physics_engine.getSurfaceQuantityContainers(); diff --git a/cpp_simulations/half_value_layer/hvl_100keV.cpp b/cpp_simulations/half_value_layer/hvl_100keV.cpp index 56bde5bf..ef30f32a 100644 --- a/cpp_simulations/half_value_layer/hvl_100keV.cpp +++ b/cpp_simulations/half_value_layer/hvl_100keV.cpp @@ -66,7 +66,7 @@ int main() { PhotonSource source = initializeSource(); - int N_PHOTONS = 100000000; + int N_PHOTONS = 1000000; runSimulation(source, physics_engine, initializeSurfaceTallies, [](){return std::vector>();}, N_PHOTONS); auto surface_tally_results = physics_engine.getSurfaceQuantityContainers(); diff --git a/cpp_simulations/half_value_layer/hvl_30kVp.cpp b/cpp_simulations/half_value_layer/hvl_30kVp.cpp index 895e22f9..66911508 100644 --- a/cpp_simulations/half_value_layer/hvl_30kVp.cpp +++ b/cpp_simulations/half_value_layer/hvl_30kVp.cpp @@ -66,7 +66,7 @@ int main() { PhotonSource source = initializeSource(); - int N_PHOTONS = 100000000; + int N_PHOTONS = 1000000; runSimulation(source, physics_engine, initializeSurfaceTallies, [](){return std::vector>();}, N_PHOTONS); auto surface_tally_results = physics_engine.getSurfaceQuantityContainers(); diff --git a/cpp_simulations/half_value_layer/hvl_30keV.cpp b/cpp_simulations/half_value_layer/hvl_30keV.cpp index 1f8cc623..6f3de1dd 100644 --- a/cpp_simulations/half_value_layer/hvl_30keV.cpp +++ b/cpp_simulations/half_value_layer/hvl_30keV.cpp @@ -66,7 +66,7 @@ int main() { PhotonSource source = initializeSource(); - int N_PHOTONS = 10000000; + int N_PHOTONS = 1000000; double run_time; runSimulation(source, physics_engine, initializeSurfaceTallies, [](){return std::vector>();}, N_PHOTONS, run_time); diff --git a/cpp_simulations/radiography/radiography.cpp b/cpp_simulations/radiography/radiography.cpp index b9e8d000..1920de72 100644 --- a/cpp_simulations/radiography/radiography.cpp +++ b/cpp_simulations/radiography/radiography.cpp @@ -316,7 +316,7 @@ int main() { PhotonSource source = initializeSource(); - const int NUM_OF_PHOTONS = 10000000; + const int NUM_OF_PHOTONS = 1000000; std::cout << std::fixed << std::setprecision(15); diff --git a/cpp_simulations/radiography/radiography_15_degrees.cpp b/cpp_simulations/radiography/radiography_15_degrees.cpp index 09cedd45..357cda30 100644 --- a/cpp_simulations/radiography/radiography_15_degrees.cpp +++ b/cpp_simulations/radiography/radiography_15_degrees.cpp @@ -319,7 +319,7 @@ int main() { PhotonSource source = initializeSource(); - const int NUM_OF_PHOTONS = 100000000; + const int NUM_OF_PHOTONS = 1000000; std::cout << std::fixed << std::setprecision(15); diff --git a/utility_scripts/build_cpp_sims.sh b/utility_scripts/build_cpp_sims.sh new file mode 100755 index 00000000..309d610f --- /dev/null +++ b/utility_scripts/build_cpp_sims.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# This script builds the C++ simulation executables for the project. + +# Set the path to the directory containing the source files. +CPP_SIMS_DIR=./cpp_simulations + +# Get dir of this script. +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +cd "${SCRIPT_DIR}" +cd .. # Go up to the project root directory. +pwd || echo + +for sim_dir in "${CPP_SIMS_DIR}/"*; do + # Get the name of the simulation. + sim_name=$(basename "$sim_dir") + + # Build the simulation. + echo "Building $sim_name..." + mkdir "${sim_dir}/build" + cd "${sim_dir}/build" + cmake .. + make + cd - +done