Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
88cecaa
Improve the way to find Enzyme. (#48)
nkoukpaizan Feb 10, 2025
f33d600
Rename namespace ModelLib -> GridKit. (#56)
pelesh Feb 11, 2025
bc3f969
Aligning the code with contributing guidelines (#42)
shakedregev Feb 17, 2025
1c09d11
Phasor dynamics components modeling framework (#55)
pelesh Feb 17, 2025
77f61bd
Add missing forward declaration (#58)
alexander-novo Feb 19, 2025
7bd2825
Reorganize model evaluator implementations (#61)
pelesh Feb 21, 2025
ee4c1f4
Add dependency-tracking variable data type. (#63)
pelesh Feb 27, 2025
c3d86e6
Additional Enzyme examples and use cases (e.g DistributedGenerator) (…
nkoukpaizan Feb 27, 2025
e6551fc
First pass on clang format file
alexander-novo Dec 2, 2024
474bc88
Fixed a few issues
alexander-novo Dec 2, 2024
d515f6d
Put templates on their own lines
alexander-novo Dec 2, 2024
176ba39
Organize .clang-format file into sections
alexander-novo Dec 2, 2024
f4071a6
Indent namespace contents
alexander-novo Dec 2, 2024
64203c9
Properly regroup
alexander-novo Dec 2, 2024
0a0375f
Indent only inner namespace contents
alexander-novo Dec 2, 2024
73c375d
More small formatting to align with current code
alexander-novo Dec 2, 2024
72afae7
Alignment
alexander-novo Dec 2, 2024
5be90c1
Add clang-format as developer dependency
alexander-novo Dec 3, 2024
779ab9d
Fix readme heading
alexander-novo Dec 3, 2024
88f1442
Better comment handling
alexander-novo Feb 9, 2025
5120d6a
Move binary operators in broken lines to the next line
alexander-novo Feb 14, 2025
1fd7193
Remove extra comment columns
alexander-novo Feb 14, 2025
345497a
Remove empty lines
alexander-novo Feb 14, 2025
d720e62
Add auto-formatting section to CONTRIBUTING.md
alexander-novo Feb 17, 2025
cdf9638
Added usage details for auto-formatting
alexander-novo Feb 17, 2025
063d866
Pre-commit setup from ExaGO. To test.
nkoukpaizan Feb 28, 2025
5d1dacf
Apply pre-commmit fixes
nkoukpaizan Feb 28, 2025
7a67380
Merge branch 'add-clang-format' into nicholson/clang-format-pre-commi…
nkoukpaizan Feb 28, 2025
0f7bf7a
Apply pre-commmit fixes
nkoukpaizan Feb 28, 2025
edf740c
Upgrade versions of pre-commit hooks.
nkoukpaizan Feb 28, 2025
ac2a9ae
Apply pre-commmit fixes
nkoukpaizan Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/pre_commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: gridkit-bot pre-commit

# Won't run on develop/main directly
on: [pull_request]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-python@v5.4.0
- uses: pre-commit/action@v3.0.1
- uses: EndBug/add-and-commit@v9.1.4
# Only need to try and commit if the action failed
if: failure()
with:
fetch: false
committer_name: GitHub Actions
committer_email: actions@github.com
message: Apply pre-commmit fixes

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
.vscode/
*.DS_Store
build/
*.DS_Store
*.DS_Store
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
hooks:
- id: clang-format
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.4
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-toml
- id: forbid-new-submodules
- id: end-of-file-fixer
- id: check-yaml
149 changes: 74 additions & 75 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,65 +1,54 @@
#
# Copyright (c) 2017, Lawrence Livermore National Security, LLC.
# Produced at the Lawrence Livermore National Laboratory.
# Written by Slaven Peles <peles2@llnl.gov>.
# LLNL-CODE-718378.
# All rights reserved.
# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at the
# Lawrence Livermore National Laboratory. Written by Slaven Peles
# <peles2@llnl.gov>. LLNL-CODE-718378. All rights reserved.
#
# This file is part of GridKit™. For details, see github.com/LLNL/GridKit
# Please also read the LICENSE file.
# This file is part of GridKit™. For details, see github.com/LLNL/GridKit Please
# also read the LICENSE file.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the disclaimer below.
# - Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the disclaimer (as noted below) in the
# documentation and/or other materials provided with the distribution.
# - Neither the name of the LLNS/LLNL nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
# modification, are permitted provided that the following conditions are met: -
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the disclaimer below. - Redistributions in binary form
# must reproduce the above copyright notice, this list of conditions and the
# disclaimer (as noted below) in the documentation and/or other materials
# provided with the distribution. - Neither the name of the LLNS/LLNL nor the
# names of its contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL
# SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISINGIN ANY
# WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE
# U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISINGIN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Lawrence Livermore National Laboratory is operated by Lawrence Livermore
# National Security, LLC, for the U.S. Department of Energy, National
# Nuclear Security Administration under Contract DE-AC52-07NA27344.
# National Security, LLC, for the U.S. Department of Energy, National Nuclear
# Security Administration under Contract DE-AC52-07NA27344.
#
# This document was prepared as an account of work sponsored by an agency
# of the United States government. Neither the United States government nor
# Lawrence Livermore National Security, LLC, nor any of their employees
# makes any warranty, expressed or implied, or assumes any legal liability
# or responsibility for the accuracy, completeness, or usefulness of any
# information, apparatus, product, or process disclosed, or represents that
# its use would not infringe privately owned rights. Reference herein to
# any specific commercial product, process, or service by trade name,
# trademark, manufacturer, or otherwise does not necessarily constitute or
# imply its endorsement, recommendation, or favoring by the United States
# government or Lawrence Livermore National Security, LLC. The views and
# opinions of authors expressed herein do not necessarily state or reflect
# those of the United States government or Lawrence Livermore National
# Security, LLC, and shall not be used for advertising or product
# endorsement purposes.
# This document was prepared as an account of work sponsored by an agency of the
# United States government. Neither the United States government nor Lawrence
# Livermore National Security, LLC, nor any of their employees makes any
# warranty, expressed or implied, or assumes any legal liability or
# responsibility for the accuracy, completeness, or usefulness of any
# information, apparatus, product, or process disclosed, or represents that its
# use would not infringe privately owned rights. Reference herein to any
# specific commercial product, process, or service by trade name, trademark,
# manufacturer, or otherwise does not necessarily constitute or imply its
# endorsement, recommendation, or favoring by the United States government or
# Lawrence Livermore National Security, LLC. The views and opinions of authors
# expressed herein do not necessarily state or reflect those of the United
# States government or Lawrence Livermore National Security, LLC, and shall not
# be used for advertising or product endorsement purposes.
#
#
# [[
# Author(s):
# - Cameron Rutherford <cameron.rutherford@pnnl.gov>
# - Slaven Peles <peless@ornl.gov>
# ]]
# [[ Author(s): - Cameron Rutherford <cameron.rutherford@pnnl.gov> - Slaven
# Peles <peless@ornl.gov> ]]

cmake_minimum_required(VERSION 3.12)

Expand All @@ -73,7 +62,9 @@ set(PACKAGE_VERSION_MAJOR "0")
set(PACKAGE_VERSION_MINOR "0")
set(PACKAGE_VERSION_PATCH "7")

set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
set(PACKAGE_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}"
)

# Ipopt support is disabled by default
option(GRIDKIT_ENABLE_IPOPT "Enable Ipopt support" OFF)
Expand All @@ -82,7 +73,8 @@ option(GRIDKIT_ENABLE_IPOPT "Enable Ipopt support" OFF)
option(GRIDKIT_ENABLE_SUNDIALS "Enable SUNDIALS support" ON)

# Enable KLU
option(GRIDKIT_ENABLE_SUNDIALS_SPARSE "Enable SUNDIALS sparse linear solvers" ON)
option(GRIDKIT_ENABLE_SUNDIALS_SPARSE "Enable SUNDIALS sparse linear solvers"
ON)

# Enzyme support is disabled by default
option(GRIDKIT_ENABLE_ENZYME "Enable automatic differentiation with Enzyme" OFF)
Expand All @@ -95,23 +87,23 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
# when building, don't use the install RPATH already (but later on when
# installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
# add the automatically determined parts of the RPATH which point to directories
# outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")


# TODO: Probably beter to set a debug interface target
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG")

Expand All @@ -127,9 +119,14 @@ if(GRIDKIT_ENABLE_IPOPT)
enable_language(Fortran) # Needed for linking to HSL
endif()
if(GRIDKIT_ENABLE_SUNDIALS)
find_package(SUNDIALS 7.0.0 REQUIRED CONFIG
PATHS ${SUNDIALS_DIR}
${SUNDIALS_DIR}/lib/cmake/sundials)
find_package(
SUNDIALS
7.0.0
REQUIRED
CONFIG
PATHS
${SUNDIALS_DIR}
${SUNDIALS_DIR}/lib/cmake/sundials)
message(STATUS "SUNDIALS configuration found: ${SUNDIALS_CONFIG}")
endif()
if(GRIDKIT_ENABLE_SUNDIALS_SPARSE)
Expand All @@ -150,11 +147,14 @@ add_subdirectory(src)
# Create examples and tests
enable_testing()
add_subdirectory(examples)

export(EXPORT gridkit-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/GridKitTargets.cmake)
add_subdirectory(tests)

export(EXPORT gridkit-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/GridKitTargets.cmake)

# Configuring exporting cmake config
install(EXPORT gridkit-targets
install(
EXPORT gridkit-targets
FILE GridKitTargets.cmake
NAMESPACE GRIDKIT::
DESTINATION share/cmake/gridkit)
Expand All @@ -168,14 +168,13 @@ write_basic_package_version_file(
COMPATIBILITY SameMajorVersion)

# Generate config file that includes exports
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/GridKitConfig.cmake
INSTALL_DESTINATION share/cmake/gridkit
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)

# Install configuration file
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/GridKitConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/GridKitConfigVersion.cmake
DESTINATION share/cmake/gridkit)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/GridKitConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/GridKitConfigVersion.cmake
DESTINATION share/cmake/gridkit)
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,4 @@ To help enforce the above code style guidelines, we use autoformatting provided

VS Code users can use `clang-format` to automatically format their code by installing the [C/C++ Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) and using the `Format Document` command in the command palette with the file to be formatted open. As well, you can enabled the `editor.formatOnSave` option to auto-format any file when you save it.

Other users can use the [`git clang-format`](https://clang.llvm.org/docs/ClangFormat.html#git-integration) subcommand installed along with `clang-format` to auto-format all staged files.
Other users can use the [`git clang-format`](https://clang.llvm.org/docs/ClangFormat.html#git-integration) subcommand installed along with `clang-format` to auto-format all staged files.
Loading