Skip to content

Commit

Permalink
Merge pull request #172 from darioizzo/master
Browse files Browse the repository at this point in the history
Last Refresh? Before Pykep 3 ....
  • Loading branch information
darioizzo authored Dec 11, 2024
2 parents 403a7df + c20bfae commit 4faa855
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 108 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,28 @@ on:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
ubuntu-release-py311:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha-ubuntu-release-py311.sh
ubuntu-debug:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha-ubuntu-debug.sh
osx-debug:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build
run: bash tools/gha-osx-debug.sh
windows-2019:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- uses: conda-incubator/setup-miniconda@v2
Expand Down
13 changes: 5 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Main pykep project version.
set(PYKEP_PROJECT_VERSION 2.6.2)
set(PYKEP_PROJECT_VERSION 2.6.3)

# CMake version check.
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.18.0)

# Module path setup.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules" "${CMAKE_SOURCE_DIR}/cmake_modules/yacma")
Expand Down Expand Up @@ -155,14 +155,12 @@ list(REMOVE_ITEM KEP_TOOLBOX_CXX_FLAGS_DEBUG "-Wold-style-cast")
if(PYKEP_BUILD_PYKEP)
include(YACMAPythonSetup)
# NOTE: for the time being, require that dcgp/dcgpy versions are matching exactly.
find_package(keplerian_toolbox ${PYKEP_PROJECT_VERSION} EXACT REQUIRED)

# Internal variable that will be used to tell PykepFindBoost to locate Boost.Python.
set(_PYKEP_FIND_BOOST_PYTHON TRUE)
find_package(keplerian_toolbox ${PYKEP_PROJECT_VERSION} EXACT REQUIRED CONFIG)
endif()

# Boost setup. Will allow using Boost::library_name for the needed components
include(PykepFindBoost)
find_package(Boost 1.69 REQUIRED COMPONENTS serialization date_time python CONFIG)


if(PYKEP_BUILD_KEP_TOOLBOX)
# List of source files.
Expand Down Expand Up @@ -298,7 +296,6 @@ if(PYKEP_BUILD_KEP_TOOLBOX)
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/keplerian_toolbox-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/keplerian_toolbox-config.cmake" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/keplerian_toolbox-config.cmake" DESTINATION "lib/cmake/keplerian_toolbox")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/PykepFindBoost.cmake" DESTINATION "lib/cmake/keplerian_toolbox")
install(EXPORT keplerian_toolbox_export NAMESPACE Keplerian_toolbox:: DESTINATION lib/cmake/keplerian_toolbox)
# Take care of versioning.
include(CMakePackageConfigHelpers)
Expand Down
57 changes: 0 additions & 57 deletions cmake_modules/PykepFindBoost.cmake

This file was deleted.

25 changes: 21 additions & 4 deletions cmake_modules/yacma/YACMACompilerLinkerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ if(NOT _YACMACompilerLinkerSettingsRun)
# Configuration bits specific for GCC.
if(YACMA_COMPILER_IS_GNUCXX)
_YACMA_CHECK_ENABLE_CXX_FLAG(-fdiagnostics-color=auto)
_YACMA_CHECK_ENABLE_CXX_FLAG(-Woverloaded-virtual)
# New in GCC 9.
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Waddress-of-packed-member)
endif()
Expand Down Expand Up @@ -109,7 +110,6 @@ if(NOT _YACMACompilerLinkerSettingsRun)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wc99-designator)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wreorder-init-list)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wsizeof-pointer-div)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wsizeof-array-div)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wxor-used-as-pow)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wfinal-dtor-non-final-class)
# New warnings in clang 11.
Expand All @@ -122,18 +122,35 @@ if(NOT _YACMACompilerLinkerSettingsRun)
# NOTE: this is a new flag in Clang 13 which seems to give
# incorrect warnings for UDLs.
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wno-reserved-identifier)

_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Warray-bounds-pointer-arithmetic)
# New warnings in clang 14.
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Warray-parameter)
# NOTE: clang 17 enables by default a new compiler flag called "-fassume-unique-vtables":
#
# https://releases.llvm.org/17.0.1/tools/clang/docs/ReleaseNotes.html#c-language-changes
#
# This flag however seems to be buggy:
#
# https://github.com/llvm/llvm-project/issues/71196
#
# On our part, in several projects we are experiencing Boost.serialization failures when
# (de)serialising derived objects through pointers to bases. Thus, we forcibly disable
# this new flag.
_YACMA_CHECK_ENABLE_CXX_FLAG(-fno-assume-unique-vtables)
endif()

# Common configuration for GCC, clang and Intel.
if(YACMA_COMPILER_IS_CLANGXX OR YACMA_COMPILER_IS_INTELXX OR YACMA_COMPILER_IS_GNUCXX)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wall)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wextra)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wnon-virtual-dtor)
# NOTE: this flag has been superseded by "-Wdelete-non-virtual-dtor"
# (enabled by "-Wall"). See:
# https://gcc.gnu.org/pipermail/gcc-cvs/2022-November/374730.html
# _YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wnon-virtual-dtor)
# NOTE: this flag is a bit too chatty, let's disable it for the moment.
#_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wnoexcept)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wlogical-op)
#_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wconversion)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wconversion)
_YACMA_CHECK_ENABLE_DEBUG_CXX_FLAG(-Wdeprecated)
# This limit is supposed to be at least 1024 in C++11, but for some reason
# clang sets this to 256, and gcc to 900.
Expand Down
6 changes: 3 additions & 3 deletions cmake_modules/yacma/YACMAPythonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(_YACMA_PYTHON_MODULE_NEED_LINK)
else()
# NOTE: we need to determine the include dir on our own.
if(NOT YACMA_PYTHON_INCLUDE_DIR)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from __future__ import print_function\nfrom distutils import sysconfig\nprint(sysconfig.get_python_inc())"
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from __future__ import print_function\nimport sysconfig\nprint(sysconfig.get_path('include'))"
OUTPUT_VARIABLE _YACMA_PYTHON_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
if(_YACMA_PYTHON_INCLUDE_DIR)
set(YACMA_PYTHON_INCLUDE_DIR "${_YACMA_PYTHON_INCLUDE_DIR}" CACHE PATH "Path to the Python include dir.")
Expand Down Expand Up @@ -66,7 +66,7 @@ if(UNIX)
if(NOT YACMA_PYTHON_MODULES_INSTALL_PATH)
# NOTE: here we use this contraption (instead of the simple method below for Win32) because like this we can
# support installation into the CMake prefix (e.g., in the user's home dir).
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from __future__ import print_function\nimport distutils.sysconfig\nimport os\nprint(os.path.split(distutils.sysconfig.get_python_lib())[-1])"
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from __future__ import print_function\nimport sysconfig\nimport os\nprint(os.path.split(sysconfig.get_path('platlib'))[-1])"
OUTPUT_VARIABLE _YACMA_PY_PACKAGES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Python packages dir is: ${_YACMA_PY_PACKAGES_DIR}")
set(YACMA_PYTHON_MODULES_INSTALL_PATH "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${_YACMA_PY_PACKAGES_DIR}" CACHE PATH "Install path for Python modules.")
Expand All @@ -78,7 +78,7 @@ elseif(WIN32)
set(_YACMA_PY_MODULE_EXTENSION "pyd")
if(NOT YACMA_PYTHON_MODULES_INSTALL_PATH)
# On Windows, we will install directly into the install path of the Python interpreter.
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('platlib'))"
OUTPUT_VARIABLE _YACMA_PYTHON_MODULES_INSTALL_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
set(YACMA_PYTHON_MODULES_INSTALL_PATH "${_YACMA_PYTHON_MODULES_INSTALL_PATH}" CACHE PATH "Install path for Python modules.")
mark_as_advanced(YACMA_PYTHON_MODULES_INSTALL_PATH)
Expand Down
1 change: 0 additions & 1 deletion keplerian_toolbox-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ get_filename_component(_KEP_TOOLBOX_CONFIG_SELF_DIR "${CMAKE_CURRENT_LIST_FILE}"
#Find the deps.Alter the cmake module path.
set(_KEP_TOOLBOX_CONFIG_OLD_MODULE_PATH "${CMAKE_MODULE_PATH}")
list(APPEND CMAKE_MODULE_PATH "${_KEP_TOOLBOX_CONFIG_SELF_DIR}")
include(PykepFindBoost)

#Restore original module path.
set(CMAKE_MODULE_PATH "${_KEP_TOOLBOX_CONFIG_OLD_MODULE_PATH}")
Expand Down
11 changes: 2 additions & 9 deletions pykep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@ endif()
# NOTE: since Boost 1.67, the naming of the Boost.Python library has changed to include the
# major and minor python version as a suffix. See the release notes:
# https://www.boost.org/users/history/version_1_67_0.html
if(${Boost_MAJOR_VERSION} GREATER 1 OR (${Boost_MAJOR_VERSION} EQUAL 1 AND ${Boost_MINOR_VERSION} GREATER 66))
set(PYKEP_BP_TARGET "Boost::python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
else()
if(${PYTHON_VERSION_MAJOR} EQUAL 2)
set(PYKEP_BP_TARGET "Boost::python")
else()
set(PYKEP_BP_TARGET "Boost::python3")
endif()
endif()
set(PYKEP_BP_TARGET "Boost::python")


# Boost.Python version 1.64 (and possibly later?) has issues with default hidden visibility.
if(${Boost_MAJOR_VERSION} GREATER 1 OR (${Boost_MAJOR_VERSION} EQUAL 1 AND ${Boost_MINOR_VERSION} GREATER 63))
Expand Down
2 changes: 1 addition & 1 deletion pykep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
###########################################################
# We define pykep module
###########################################################
version = '2.6.1'
version = '2.6.3'
__doc__ = 'pykep is the answer ... but what was the question?'
__all__ = ['core', 'sims_flanagan', 'pontryagin', 'orbit_plots',
'examples', 'trajopt', 'phasing', 'util', 'planet', 'test']
Expand Down
27 changes: 14 additions & 13 deletions pykep/trajopt/_launchers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from scipy.interpolate import interp2d, interp1d
from scipy.interpolate import RectBivariateSpline, interp1d
from math import sqrt
import numpy as np

_vinfs_A5 = [0., 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6]
_decls_A5 = [-90, -40, -30, -29, -28.5, -20, -10, 0, 10, 20, 28.5, 29, 30, 40, 90]
_data_A5 = [
_data_A5 = np.array([
[1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1],
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0],
Expand All @@ -19,14 +20,14 @@
[10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0],
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1, 1e-1]
]
])

_vinfs_A551 = [sqrt(elem) for elem in [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 40, 45, 50, 55, 60]]
_data_A551 = [5995, 5780, 5570, 5360, 5160, 4965, 4775, 4585, 4405, 4230, 4055, 3890, 3730, 3570, 3420, 3270, 3130, 2995, 2860, 2670, 2380, 2120, 1900, 1695]

_vinfs_SF = [0, 1, 2, 3, 4, 5]
_decls_SF = [-90, -65, -50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50, 65, 90]
_data_SF = [
_data_SF = np.array([
[1e-3, 1e-3, 1e-3, 1e-3, 1e-3, 1e-3],
[100., 100.00000, 100.00000, 100.00000, 100.00000, 100.00000],
[1830.50000, 1830.50000, 1815.90000, 1737.70000, 1588.00000, 1344.30000],
Expand All @@ -42,14 +43,14 @@
[1805.90000, 1805.90000, 1796.00000, 1722.70000, 1571.60000, 1327.60000],
[100.00000, 100.00000, 100.00000, 100.00000, 100.00000, 100.00000],
[1e-3, 1e-3, 1e-3, 1e-3, 1e-3, 1e-3]
]
])

# Ariane 5: data provided to ESOC by Arianespace when they were still considering Ariane launch for ExoMars.
# Negative mass values have been substituted with exp(m/1000) to avoid problems.
# Declination has been extended up to 90 degrees.
_vinfs_Ariane5 = [0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. , 5.5, 6. ]
_decls_Ariane5 = [-90, -50, -45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 90]
_data_Ariane5 = [
_data_Ariane5 = np.array([
[4.97870684e-02, 3.01973834e-02, 1.83156389e-02, 1.11089965e-02, 6.73794700e-03, 2.47875218e-03, 9.11881966e-04, 3.35462628e-04, 1.23409804e-04, 4.53999298e-05, 1.67017008e-05, 6.14421235e-06],
[4.97870684e-02, 3.01973834e-02, 1.83156389e-02, 1.11089965e-02, 6.73794700e-03, 2.47875218e-03, 9.11881966e-04, 3.35462628e-04, 1.23409804e-04, 4.53999298e-05, 1.67017008e-05, 6.14421235e-06],
[8.20849986e-02, 4.97870684e-02, 3.01973834e-02, 1.83156389e-02, 1.11089965e-02, 6.73794700e-03, 2.47875218e-03, 9.11881966e-04, 3.35462628e-04, 1.23409804e-04, 4.53999298e-05, 1.67017008e-05],
Expand All @@ -73,7 +74,7 @@
[5.47700000e+03, 5.23900000e+03, 4.88200000e+03, 4.40100000e+03, 3.79500000e+03, 3.67879441e-01, 1.35335283e-01, 4.97870684e-02, 1.83156389e-02, 6.73794700e-03, 2.47875218e-03, 9.11881966e-04],
[5.30200000e+03, 5.02100000e+03, 4.60400000e+03, 4.04400000e+03, 3.67879441e-01, 1.35335283e-01, 4.97870684e-02, 1.83156389e-02, 6.73794700e-03, 2.47875218e-03, 9.11881966e-04, 3.35462628e-04],
[5.30200000e+03, 5.02100000e+03, 4.60400000e+03, 4.04400000e+03, 3.67879441e-01, 1.35335283e-01, 4.97870684e-02, 1.83156389e-02, 6.73794700e-03, 2.47875218e-03, 9.11881966e-04, 3.35462628e-04]
]
])

class _launchers:
"""
Expand All @@ -92,10 +93,10 @@ class _launchers:
"""
def __init__(self):
self._atlas501 = interp2d(_vinfs_A5, _decls_A5, _data_A5, kind='linear', fill_value=0.1, copy=False)
self._atlas501 = RectBivariateSpline(_vinfs_A5, _decls_A5, _data_A5.T, kx=1, ky=1)
self._atlas551 = interp1d(_vinfs_A551, _data_A551, kind='linear', fill_value=0.1, copy=False, bounds_error=False)
self._soyuzf = interp2d(_vinfs_SF, _decls_SF, _data_SF, kind='linear', fill_value=1e-3, copy=False)
self._ariane5 = interp2d(_vinfs_Ariane5, _decls_Ariane5, _data_Ariane5, kind='linear', fill_value=1e-3, copy=False)
self._soyuzf = RectBivariateSpline(_vinfs_SF, _decls_SF, _data_SF.T, kx=1, ky=1)
self._ariane5 = RectBivariateSpline(_vinfs_Ariane5, _decls_Ariane5, _data_Ariane5.T, kx=1, ky=1)
def atlas501(self, vinfs, decls):
"""atlas501(vinfs, decls)
Expand All @@ -110,7 +111,7 @@ def atlas501(self, vinfs, decls):
Numpy array containg the mass delivered to escape with said declinations and magnitudes.
"""
return self._atlas501(vinfs, decls)
return self._atlas501(vinfs, decls).T

def atlas551(self, vinfs):
"""atlas551(vinfs)
Expand Down Expand Up @@ -140,7 +141,7 @@ def soyuzf(self, vinfs, decls):
Returns:
Numpy array containg the mass delivered to escape with said declinations and magnitudes.
"""
return self._soyuzf(vinfs, decls)
return self._soyuzf(vinfs, decls).T
def ariane5(self, vinfs, decls):
"""ariane5(vinfs, decls)
Expand All @@ -155,4 +156,4 @@ def ariane5(self, vinfs, decls):
Returns:
Numpy array containg the mass delivered to escape with said declinations and magnitudes.
"""
return self._ariane5(vinfs, decls)
return self._ariane5(vinfs, decls).T
11 changes: 7 additions & 4 deletions tools/gha-osx-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ set -x
# Exit on error.
set -e

# Core deps.
sudo apt-get install wget

# Install conda+deps.
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-MacOSX-x86_64.sh -O mambaforge.sh
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniforge.sh
export deps_dir=$HOME/local
export PATH="$HOME/mambaforge/bin:$PATH"
bash mambaforge.sh -b -p $HOME/mambaforge
mamba create -y -q -p $deps_dir c-compiler cxx-compiler cmake boost boost-cpp python=3.11 scipy matplotlib
export PATH="$HOME/miniforge/bin:$PATH"
bash miniforge.sh -b -p $HOME/miniforge
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake libboost-devel libboost-python-devel python scipy matplotlib ninja
source activate $deps_dir

# Create the build dir and cd into it.
Expand Down
8 changes: 4 additions & 4 deletions tools/gha-ubuntu-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ set -e
sudo apt-get install wget

# Install conda+deps.
wget https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-Linux-x86_64.sh -O mambaforge.sh
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniforge.sh
export deps_dir=$HOME/local
export PATH="$HOME/mambaforge/bin:$PATH"
bash mambaforge.sh -b -p $HOME/mambaforge
mamba create -y -q -p $deps_dir c-compiler cxx-compiler cmake boost boost-cpp python=3.11 scipy matplotlib
export PATH="$HOME/miniforge/bin:$PATH"
bash miniforge.sh -b -p $HOME/miniforge
conda create -y -q -p $deps_dir c-compiler cxx-compiler cmake libboost-devel libboost-python-devel python scipy matplotlib ninja
source activate $deps_dir

# Create the build dir and cd into it.
Expand Down
Loading

0 comments on commit 4faa855

Please sign in to comment.