Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests/cpp/expected_results_py.h5 filter=lfs diff=lfs merge=lfs -text
7 changes: 7 additions & 0 deletions .github/workflows/test_python_cplusplus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v4
with:
lfs: true
- run: git fetch --prune --unshallow

- run: echo "AMICI_DIR=$(pwd)" >> $GITHUB_ENV
Expand Down Expand Up @@ -253,6 +255,9 @@ jobs:
python-version: "3.11"

- uses: actions/checkout@v4
with:
lfs: true

- run: git fetch --prune --unshallow

- name: Install dependencies
Expand Down Expand Up @@ -315,6 +320,8 @@ jobs:
python-version: "3.11"

- uses: actions/checkout@v4
with:
lfs: true
- run: git fetch --prune --unshallow

- name: Install dependencies
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_python_ver_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 20
lfs: true

- name: Install apt dependencies
uses: ./.github/actions/install-apt-dependencies
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ jobs:
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v4
with:
lfs: true
- run: git fetch --prune --unshallow

- shell: bash
Expand Down
1 change: 1 addition & 0 deletions models/model_calvetti_py/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**
151 changes: 151 additions & 0 deletions models/model_calvetti_py/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# Build AMICI model
cmake_minimum_required(VERSION 3.22)
cmake_policy(VERSION 3.22...3.31)

project(model_calvetti_py)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

include(CheckCXXCompilerFlag)
set(MY_CXX_FLAGS -Wall -Wno-unused-function -Wno-unused-variable)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND MY_CXX_FLAGS -Wno-unused-but-set-variable)
endif()
foreach(flag ${MY_CXX_FLAGS})
unset(CUR_FLAG_SUPPORTED CACHE)
check_cxx_compiler_flag(${flag} CUR_FLAG_SUPPORTED)
if(${CUR_FLAG_SUPPORTED})
string(APPEND CMAKE_CXX_FLAGS " ${flag}")
endif()
endforeach()

if(DEFINED ENV{AMICI_CXXFLAGS})
message(STATUS "Appending flags from AMICI_CXXFLAGS: $ENV{AMICI_CXXFLAGS}")
add_compile_options("$ENV{AMICI_CXXFLAGS}")
endif()
if(DEFINED ENV{AMICI_LDFLAGS})
message(STATUS "Appending flags from AMICI_LDFLAGS: $ENV{AMICI_LDFLAGS}")
link_libraries("$ENV{AMICI_LDFLAGS}")
endif()

find_package(Amici 0.33.0 REQUIRED HINTS
${CMAKE_CURRENT_LIST_DIR}/../../build)
message(STATUS "Found AMICI ${Amici_DIR}")
set_target_properties(Upstream::amici PROPERTIES
MAP_IMPORTED_CONFIG_RELWITHDEBINFO RelWithDebInfo;Release;
MAP_IMPORTED_CONFIG_RELEASE Release
MAP_IMPORTED_CONFIG_DEBUG Debug;RelWithDebInfo;)

# Debug build?
if("$ENV{ENABLE_AMICI_DEBUGGING}" OR "$ENV{ENABLE_GCOV_COVERAGE}")
add_compile_options(-UNDEBUG)
if(MSVC)
add_compile_options(-DEBUG)
else()
add_compile_options(-O0 -g)
endif()
endif()

# coverage options
if($ENV{ENABLE_GCOV_COVERAGE})
string(APPEND CMAKE_CXX_FLAGS_DEBUG " --coverage")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG " --coverage")
endif()

set(MODEL_DIR ${CMAKE_CURRENT_LIST_DIR})

set(SRC_LIST_LIB Jy.cpp
Jy.h
create_splines.cpp
dJydsigma.cpp
dJydy.cpp
dJydy.h
dwdw.cpp
dwdw.h
dwdx.cpp
dwdx.h
dx.h
dxdotdw.cpp
dxdotdw.h
dxdotdx_explicit.cpp
dxdotdx_explicit.h
dydx.cpp
h.h
k.h
model_calvetti_py.cpp
model_calvetti_py.h
my.h
root.cpp
sigmay.cpp
sigmay.h
sx.h
w.cpp
w.h
wrapfunctions.cpp
wrapfunctions.h
x.h
x0.cpp
x0_fixedParameters.cpp
xB.h
x_old.h
x_rdata.cpp
x_rdata.h
x_solver.cpp
x_solver.h
xdot.cpp
xdot.h
xdot_old.h
y.cpp
y.h ${MODEL_DIR}/wrapfunctions.cpp)

add_library(${PROJECT_NAME} ${SRC_LIST_LIB})

# ${PROJECT_NAME} might already be "model"
if(NOT TARGET model)
add_library(model ALIAS ${PROJECT_NAME})
endif()

# Some special functions require boost
#
# TODO: set some flag during code generation whether the given model requires
# boost. for now, try to find it, add include directories and link against it.
# let the compiler/linker error if it is required but not found
find_package(Boost)

target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")

target_link_libraries(
${PROJECT_NAME}
PUBLIC Upstream::amici
PRIVATE $<$<BOOL:${Boost_FOUND}>:Boost::boost>)

if(NOT "${AMICI_PYTHON_BUILD_EXT_ONLY}")
set(SRC_LIST_EXE main.cpp)
add_executable(simulate_${PROJECT_NAME} ${SRC_LIST_EXE})
target_link_libraries(simulate_${PROJECT_NAME} ${PROJECT_NAME})
endif()

# SWIG
option(ENABLE_SWIG "Build swig/python library?" ON)
if(ENABLE_SWIG)
add_subdirectory(swig)
endif()

# <Export cmake configuration>
include(GNUInstallDirs)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
export(
EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Config.cmake
NAMESPACE Upstream::)
# </Export cmake configuration>
40 changes: 40 additions & 0 deletions models/model_calvetti_py/Jy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "amici/symbolic_functions.h"
#include "amici/defines.h"
#include "sundials/sundials_types.h"

#include <gsl/gsl-lite.hpp>
#include <algorithm>

#include "k.h"
#include "y.h"
#include "sigmay.h"
#include "my.h"

namespace amici {
namespace model_model_calvetti_py {

void Jy_model_calvetti_py(realtype *Jy, const int iy, const realtype *p, const realtype *k, const realtype *y, const realtype *sigmay, const realtype *my){
switch(iy) {
case 0:
Jy[0] = 0.5*std::log(2*amici::pi*std::pow(sigma_obs_V1, 2)) + 0.5*std::pow(-mobs_V1 + obs_V1, 2)/std::pow(sigma_obs_V1, 2);
break;
case 1:
Jy[0] = 0.5*std::log(2*amici::pi*std::pow(sigma_obs_V2, 2)) + 0.5*std::pow(-mobs_V2 + obs_V2, 2)/std::pow(sigma_obs_V2, 2);
break;
case 2:
Jy[0] = 0.5*std::log(2*amici::pi*std::pow(sigma_obs_V3, 2)) + 0.5*std::pow(-mobs_V3 + obs_V3, 2)/std::pow(sigma_obs_V3, 2);
break;
case 3:
Jy[0] = 0.5*std::log(2*amici::pi*std::pow(sigma_obs_f0, 2)) + 0.5*std::pow(-mobs_f0 + obs_f0, 2)/std::pow(sigma_obs_f0, 2);
break;
case 4:
Jy[0] = 0.5*std::log(2*amici::pi*std::pow(sigma_obs_f1, 2)) + 0.5*std::pow(-mobs_f1 + obs_f1, 2)/std::pow(sigma_obs_f1, 2);
break;
case 5:
Jy[0] = 0.5*std::log(2*amici::pi*std::pow(sigma_obs_f2, 2)) + 0.5*std::pow(-mobs_f2 + obs_f2, 2)/std::pow(sigma_obs_f2, 2);
break;
}
}

} // namespace model_model_calvetti_py
} // namespace amici
6 changes: 6 additions & 0 deletions models/model_calvetti_py/Jy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define Jy0 Jy[0]
#define Jy1 Jy[1]
#define Jy2 Jy[2]
#define Jy3 Jy[3]
#define Jy4 Jy[4]
#define Jy5 Jy[5]
3 changes: 3 additions & 0 deletions models/model_calvetti_py/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include *.cpp *.h
include CMakeLists.txt
recursive-include swig/ *
20 changes: 20 additions & 0 deletions models/model_calvetti_py/create_splines.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "amici/symbolic_functions.h"
#include "amici/defines.h"
#include "sundials/sundials_types.h"

#include <gsl/gsl-lite.hpp>
#include <algorithm>

#include "amici/splinefunctions.h"
#include <vector>
#include "k.h"

namespace amici {
namespace model_model_calvetti_py {

std::vector<HermiteSpline> create_splines_model_calvetti_py(const realtype *p, const realtype *k){
return {};
}

} // namespace model_model_calvetti_py
} // namespace amici
40 changes: 40 additions & 0 deletions models/model_calvetti_py/dJydsigma.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "amici/symbolic_functions.h"
#include "amici/defines.h"
#include "sundials/sundials_types.h"

#include <gsl/gsl-lite.hpp>
#include <algorithm>

#include "k.h"
#include "y.h"
#include "sigmay.h"
#include "my.h"

namespace amici {
namespace model_model_calvetti_py {

void dJydsigma_model_calvetti_py(realtype *dJydsigma, const int iy, const realtype *p, const realtype *k, const realtype *y, const realtype *sigmay, const realtype *my){
switch(iy) {
case 0:
dJydsigma[0] = 1.0/sigma_obs_V1 - 1.0*std::pow(-mobs_V1 + obs_V1, 2)/std::pow(sigma_obs_V1, 3);
break;
case 1:
dJydsigma[1] = 1.0/sigma_obs_V2 - 1.0*std::pow(-mobs_V2 + obs_V2, 2)/std::pow(sigma_obs_V2, 3);
break;
case 2:
dJydsigma[2] = 1.0/sigma_obs_V3 - 1.0*std::pow(-mobs_V3 + obs_V3, 2)/std::pow(sigma_obs_V3, 3);
break;
case 3:
dJydsigma[3] = 1.0/sigma_obs_f0 - 1.0*std::pow(-mobs_f0 + obs_f0, 2)/std::pow(sigma_obs_f0, 3);
break;
case 4:
dJydsigma[4] = 1.0/sigma_obs_f1 - 1.0*std::pow(-mobs_f1 + obs_f1, 2)/std::pow(sigma_obs_f1, 3);
break;
case 5:
dJydsigma[5] = 1.0/sigma_obs_f2 - 1.0*std::pow(-mobs_f2 + obs_f2, 2)/std::pow(sigma_obs_f2, 3);
break;
}
}

} // namespace model_model_calvetti_py
} // namespace amici
Loading
Loading