Skip to content

Commit

Permalink
Merge pull request #29 from Battery-Intelligence-Lab/chebyshev
Browse files Browse the repository at this point in the history
Chebyshev
  • Loading branch information
ElektrikAkar authored Jul 26, 2024
2 parents 564e97a + 4091af3 commit 0a4beec
Show file tree
Hide file tree
Showing 708 changed files with 2,589 additions and 224,707 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ubuntu-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
- CC: gcc-12
CXX: g++-12
compiler: gcc-12 g++-12
- CC: gcc-13
CXX: g++-13
compiler: gcc-13 g++-13
- CC: clang-12
CXX: clang++-12
compiler: clang-12
Expand All @@ -36,7 +39,15 @@ jobs:
- CC: clang-14
CXX: clang++-14
compiler: clang-14

- CC: clang-15
CXX: clang++-15
compiler: clang-15
- CC: clang-16
CXX: clang++-16
compiler: clang-16
- CC: clang-17
CXX: clang++-17
compiler: clang-17
steps:
- uses: actions/checkout@v3

Expand Down
45 changes: 5 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
cmake_minimum_required(VERSION 3.17)
cmake_minimum_required(VERSION 3.21)

# include(cmake/ProjectSettings.cmake)
project(SLIDE VERSION "3.0.0"
DESCRIPTION "A simulator for lithium-ion battery degradation"
HOMEPAGE_URL https://github.com/Battery-Intelligence-Lab/SLIDE/
LANGUAGES CXX)



include(cmake/StandardProjectSettings.cmake)
include(cmake/PreventInSourceBuilds.cmake)
include(cmake/Dependencies.cmake) # Include external projects

# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
add_library(project_warnings INTERFACE)
Expand All @@ -20,20 +19,17 @@ target_compile_features(project_options INTERFACE cxx_std_20)

enable_testing()
add_subdirectory(src bin)
add_subdirectory(external/eigen)

target_link_libraries(src PUBLIC eigen)

include(cmake/Coverage.cmake)
add_subdirectory(tests)


target_link_libraries(src PUBLIC Eigen3::Eigen range-v3 fmt) # Link dependencies to the src library.
# glaze::glaze -> maybe in future.

add_executable(slide
src/main.cpp
)


target_link_libraries(slide
PRIVATE
src
Expand All @@ -46,8 +42,6 @@ target_include_directories(slide
data
)



# message(STATUS "Project: ${PROJECT_NAME} version ${PROJECT_HOMEPAGE_URL}")

# cmake --build ./build/ --parallel $(($(nproc)-1))
Expand Down Expand Up @@ -97,40 +91,11 @@ target_link_libraries(${LIB_NAME}
)

# # install header
# install(FILES "src/slide.hpp" DESTINATION include)
include(GNUInstallDirs)

install(TARGETS ${LIB_NAME} EXPORT ${LIB_NAME}Targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

# install(EXPORT MyProject-targets DESTINATION lib/cmake/MyProject)

# # # install the library
# # install(TARGETS MyProject
# # EXPORT MyProject-targets
# # LIBRARY DESTINATION lib
# # ARCHIVE DESTINATION lib
# # )

# # # install export target and config for find_package
# # install(EXPORT ${LIB_NAME}Targets DESTINATION lib/cmake/${LIB_NAME})
# # include(CMakePackageConfigHelpers)
# # configure_package_config_file(
# # "MyProjectConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/MyProjectConfig.cmake"
# # INSTALL_DESTINATION "lib/cmake/${LIB_NAME}"
# # )
# # install(FILES "${CMAKE_CURRENT_BINARY_DIR}/MyProjectConfig.cmake" DESTINATION "lib/cmake/${LIB_NAME}")

# # defines targets and sources CMAKE_BUILD_PARALLEL_LEVEL -> Try this to see if it gets better than -j
# add_subdirectory(src)

# install(TARGETS slide_v3
# CONFIGURATIONS Debug
# RUNTIME DESTINATION Debug/bin)
# install(TARGETS slide_v3
# CONFIGURATIONS Release
# RUNTIME DESTINATION Release/bin)
)
1 change: 1 addition & 0 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function(set_project_warnings project_name)
/wd4273 # QtAlignedMalloc, inconsistent DLL linkage
/wd4324 # structure was padded due to declspec(align())
/wd4503 # decorated name length exceeded, name was truncated
/Zc:preprocessor
)

if(MSVC)
Expand Down
29 changes: 0 additions & 29 deletions cmake/Conan.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/Coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ option (SLIDE_ENABLE_COVERAGE "Enable coverage reporting for GCC or Clang" OFF)
# Setup macro for coverage testing for GCC or Clang
macro(add_executable_with_coverage_and_test TARGET_NAME CPP_FILE_NAME)
add_executable(${TARGET_NAME} ${CPP_FILE_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE src)
target_link_libraries(${TARGET_NAME} PRIVATE src Catch2::Catch2WithMain)
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME} WORKING_DIRECTORY bin)
if (SLIDE_ENABLE_COVERAGE)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
Expand Down
40 changes: 40 additions & 0 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This cmake file is to add external dependency projects.
# Adapted from https://github.com/cpp-best-practices/cmake_template/tree/main
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/recipes/")

include(cmake/recipes/CPM.cmake)

# Range-v3 library:
CPMAddPackage(
NAME range-v3
URL "https://github.com/ericniebler/range-v3/archive/refs/tags/0.12.0.tar.gz"
DOWNLOAD_ONLY YES
)

include(eigen)

add_library(range-v3 INTERFACE)
target_include_directories(range-v3 SYSTEM INTERFACE ${range-v3_SOURCE_DIR}/include)

# Catch2 library:
if(NOT TARGET Catch2::Catch2WithMain)
CPMAddPackage(
NAME Catch2
URL "https://github.com/catchorg/Catch2/archive/refs/tags/v3.3.2.tar.gz"
)
endif()


# CPMAddPackage("gh:fmtlib/fmt#10.1.1") #fmt library
# fmt library:
CPMAddPackage(
NAME fmt
URL "https://github.com/fmtlib/fmt/archive/refs/tags/10.1.1.tar.gz"
)


# # Glaze library:
# CPMAddPackage(
# NAME glaze
# URL "https://github.com/stephenberry/glaze/archive/refs/tags/v1.3.4.tar.gz"
# )
6 changes: 4 additions & 2 deletions cmake/readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
The files in this folder are taken and adapted from:
The files in this folder are mostly taken and adapted from:

https://github.com/lefticus/cpp_weekly/tree/master/cmake

Currently, they may or may not be in use.
Currently, they may or may not be in use.

CPM is obtained from https://github.com/cpm-cmake/CPM.cmake
22 changes: 22 additions & 0 deletions cmake/recipes/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
set(CPM_DOWNLOAD_VERSION 0.40.0)
set(CPM_HASH_SUM "7b354f3a5976c4626c876850c93944e52c83ec59a159ae5de5be7983f0e17a2a")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
68 changes: 68 additions & 0 deletions cmake/recipes/eigen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Obtained: https://github.com/polyfem/polysolve/tree/main/cmake/recipes
# Copyright 2019 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET Eigen3::Eigen)
return()
endif()

option(EIGEN_WITH_MKL "Use Eigen with MKL" OFF)
option(EIGEN_DONT_VECTORIZE "Disable Eigen vectorization" OFF)
option(EIGEN_MPL2_ONLY "Enable Eigen MPL2 license only" OFF)

message(STATUS "Third-party: creating target 'Eigen3::Eigen'")

include(CPM)
# Eigen library:
CPMAddPackage(
NAME eigen
URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz"
DOWNLOAD_ONLY YES
)

add_library(Eigen3_Eigen INTERFACE)
add_library(Eigen3::Eigen ALIAS Eigen3_Eigen)

include(GNUInstallDirs)
target_include_directories(Eigen3_Eigen SYSTEM INTERFACE
$<BUILD_INTERFACE:${eigen_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if(EIGEN_MPL2_ONLY)
target_compile_definitions(Eigen3_Eigen INTERFACE EIGEN_MPL2_ONLY)
endif()

if(EIGEN_DONT_VECTORIZE)
target_compile_definitions(Eigen3_Eigen INTERFACE EIGEN_DONT_VECTORIZE)
endif()

if(EIGEN_WITH_MKL)
#TODO : Checks that, on 64bits systems, `mkl::mkl` is using the LP64 interface
# (by looking at the compile definition of the target)
include(mkl)
target_link_libraries(Eigen3_Eigen INTERFACE mkl::mkl)
target_compile_definitions(Eigen3_Eigen INTERFACE
EIGEN_USE_MKL_ALL
EIGEN_USE_LAPACKE_STRICT
)
endif()

# On Windows, enable natvis files to improve debugging experience
if(WIN32 AND eigen_SOURCE_DIR)
target_sources(Eigen3_Eigen INTERFACE $<BUILD_INTERFACE:${eigen_SOURCE_DIR}/debug/msvc/eigen.natvis>)
endif()

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME eigen)
set_target_properties(Eigen3_Eigen PROPERTIES EXPORT_NAME Eigen)
install(DIRECTORY ${eigen_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS Eigen3_Eigen EXPORT Eigen_Targets)
install(EXPORT Eigen_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/eigen NAMESPACE Eigen3::)
2 changes: 1 addition & 1 deletion deprecated/src/BasicCycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* Copyright (c) 2019, The Chancellor, Masters and Scholars of the University
* of Oxford, VITO nv, and the 'Slide' Developers.
* See the licence file LICENCE.txt for more information.
* See the licence file LICENSE for more information.
*/

#include <filesystem>
Expand Down
2 changes: 1 addition & 1 deletion deprecated/src/BasicCycler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Copyright (c) 2019, The Chancellor, Masters and Scholars of the University
* of Oxford, VITO nv, and the 'Slide' Developers.
* See the licence file LICENCE.txt for more information.
* See the licence file LICENSE for more information.
*/

#pragma once
Expand Down
2 changes: 1 addition & 1 deletion deprecated/src/CyclerOld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* Copyright (c) 2019, The Chancellor, Masters and Scholars of the University
* of Oxford, VITO nv, and the 'Slide' Developers.
* See the licence file LICENCE.txt for more information.
* See the licence file LICENSE for more information.
*/

#include "CyclerOld.hpp"
Expand Down
2 changes: 1 addition & 1 deletion deprecated/src/CyclerOld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Copyright (c) 2019, The Chancellor, Masters and Scholars of the University
* of Oxford, VITO nv, and the 'Slide' Developers.
* See the licence file LICENCE.txt for more information.
* See the licence file LICENSE for more information.
*/

#pragma once
Expand Down
20 changes: 17 additions & 3 deletions develop/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
- [ ] There are classes with completely capital? Which one?
- [ ] SUNDIALS is pretty quick.
- [ ] Automated tests against PyBAMM
- [ ] Catch2 library for testing.
- [x] Catch2 library for testing.
- [ ] Snapshot testing.
- [ ] Template projects in OxRSE template-project-cpp
- [ ] gui_starter_library Jason Turner.
- [ ] clang-tidy
- [ ] codecov.
- [ ] Doxygen.
- [x] Doxygen.
- [ ] CPack


Expand All @@ -35,10 +35,23 @@
- [x] sp - sn question
- [x] cps - cns question: dOCV_neg and dOCV_tot are taking zp_surf as input due to our data. Very important.
- [ ] Should capacity check also contain a CV phase?
- [ ] Chebyshev discretisation only works for nch = 5. Need to see why.


### Current priority:

- [ ] Module_data is deleted but look for it and bring it back.
- [ ] State always holds cumulative variables.
- [ ] Fix INTERFACE library problem in C++. Cannot include <DataFrame.hpp> and others!
- [ ] DataFrame class is added for named columns.
- [ ] Create Module_p_ApproxPI
- [ ] PTHREADS definition
- [ ] inline namespaces for literals.
- [ ] Make Eigen-based calculations for Matrix-vector multiplications.
- [ ] Electrode-based calculations?
- [x] cmake_minimum_required(VERSION 3.17) -> 3.21
- [x] CPM package manager is adopted.
- [ ] Renew matlab scripts to read results.
- [ ] Matio and parquet data types.
- [ ] In `test_specificDeg` in `Procedure_test.cpp` there is a weak cell.
- [ ] What to do if one of the series cells reach maximum voltage?
- [ ] CCCV for ageing CV should be done with the remaining voltage.
Expand Down Expand Up @@ -120,6 +133,7 @@
- [ ] setSUs and assigning unique pointers then testing individually is very difficult. Clearly a design problem.
- [ ] getNSUs may slow down time to time.
- [ ] std::vector<double> Iolds in Module_p.cpp
- [ ] Use just one memory allocation, dynamically allocated memory space for Model_SPM.


### From SLIDE v2:
Expand Down
Loading

0 comments on commit 0a4beec

Please sign in to comment.