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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions include/amici/abstract_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,10 @@ class AbstractModel {
* @param k constant vector
* @param h Heaviside vector
* @param w repeating elements vector
* @param dwdx Recurring terms in xdot, state derivative
*/
virtual void fdydx(
realtype* dydx, realtype t, realtype const* x, realtype const* p,
realtype const* k, realtype const* h, realtype const* w,
realtype const* dwdx
realtype const* k, realtype const* h, realtype const* w
);

/**
Expand Down
3 changes: 1 addition & 2 deletions models/model_calvetti_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
#include "k.h"
#include "h.h"
#include "w.h"
#include "dwdx.h"

namespace amici {
namespace model_model_calvetti_py {

void dydx_model_calvetti_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_calvetti_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[0] = 1;
dydx[3] = std::pow(L1, 3)*(2*f1/R1 - 2*(R3*f3 + f1*(R1 + R2) + f2*(R2 + R3))/std::pow(R1, 2) + 4/std::pow(R1, 2))/std::pow(V1, 3);
dydx[7] = 1;
Expand Down
6 changes: 3 additions & 3 deletions models/model_calvetti_py/model_calvetti_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdw_rowvals_model_calvetti_py(SUNMatrixWrapper &rowvals);
extern void dxdotdx_explicit_model_calvetti_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *dx, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_calvetti_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_calvetti_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_calvetti_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_calvetti_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);



Expand Down Expand Up @@ -309,8 +309,8 @@ class Model_model_calvetti_py : public amici::Model_DAE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_calvetti_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_calvetti_py(dydx, t, x, p, k, h, w);
}


Expand Down
2 changes: 1 addition & 1 deletion models/model_dirac_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace amici {
namespace model_model_dirac_py {

void dydx_model_dirac_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_dirac_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[1] = 1;
}

Expand Down
6 changes: 3 additions & 3 deletions models/model_dirac_py/model_dirac_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdp_explicit_rowvals_model_dirac_py(SUNMatrixWrapper &rowvals);
extern void dxdotdx_explicit_model_dirac_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_dirac_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_dirac_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_dirac_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_dirac_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);



Expand Down Expand Up @@ -300,8 +300,8 @@ class Model_model_dirac_py : public amici::Model_ODE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_dirac_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_dirac_py(dydx, t, x, p, k, h, w);
}


Expand Down
2 changes: 1 addition & 1 deletion models/model_events_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace amici {
namespace model_model_events_py {

void dydx_model_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[0] = p4;
dydx[1] = p4;
dydx[2] = p4;
Expand Down
6 changes: 3 additions & 3 deletions models/model_events_py/model_events_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdp_explicit_rowvals_model_events_py(SUNMatrixWrapper &rowvals);
extern void dxdotdx_explicit_model_events_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_events_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_events_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dydp_model_events_py(realtype *dydp, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const int ip, const realtype *w, const realtype *tcl, const realtype *dtcldp, const realtype *spl, const realtype *sspl);
extern void dzdx_model_events_py(realtype *dzdx, const int ie, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h);

Expand Down Expand Up @@ -319,8 +319,8 @@ class Model_model_events_py : public amici::Model_ODE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_events_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_events_py(dydx, t, x, p, k, h, w);
}


Expand Down
2 changes: 1 addition & 1 deletion models/model_jakstat_adjoint_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace amici {
namespace model_model_jakstat_adjoint_py {

void dydx_model_jakstat_adjoint_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_jakstat_adjoint_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[1] = scale_tSTAT/init_STAT;
dydx[3] = scale_pSTAT/init_STAT;
dydx[4] = scale_tSTAT/init_STAT;
Expand Down
6 changes: 3 additions & 3 deletions models/model_jakstat_adjoint_py/model_jakstat_adjoint_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdp_explicit_rowvals_model_jakstat_adjoint_py(SUNMatrixWrapper &
extern void dxdotdx_explicit_model_jakstat_adjoint_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_jakstat_adjoint_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_jakstat_adjoint_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_jakstat_adjoint_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_jakstat_adjoint_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dydp_model_jakstat_adjoint_py(realtype *dydp, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const int ip, const realtype *w, const realtype *tcl, const realtype *dtcldp, const realtype *spl, const realtype *sspl);


Expand Down Expand Up @@ -308,8 +308,8 @@ class Model_model_jakstat_adjoint_py : public amici::Model_ODE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_jakstat_adjoint_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_jakstat_adjoint_py(dydx, t, x, p, k, h, w);
}


Expand Down
2 changes: 1 addition & 1 deletion models/model_nested_events_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace amici {
namespace model_model_nested_events_py {

void dydx_model_nested_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_nested_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[0] = 1;
}

Expand Down
6 changes: 3 additions & 3 deletions models/model_nested_events_py/model_nested_events_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdp_explicit_rowvals_model_nested_events_py(SUNMatrixWrapper &ro
extern void dxdotdx_explicit_model_nested_events_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_nested_events_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_nested_events_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_nested_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_nested_events_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);



Expand Down Expand Up @@ -304,8 +304,8 @@ class Model_model_nested_events_py : public amici::Model_ODE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_nested_events_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_nested_events_py(dydx, t, x, p, k, h, w);
}


Expand Down
2 changes: 1 addition & 1 deletion models/model_neuron_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace amici {
namespace model_model_neuron_py {

void dydx_model_neuron_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_neuron_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[0] = 1;
}

Expand Down
6 changes: 3 additions & 3 deletions models/model_neuron_py/model_neuron_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdp_explicit_rowvals_model_neuron_py(SUNMatrixWrapper &rowvals);
extern void dxdotdx_explicit_model_neuron_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_neuron_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_neuron_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_neuron_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_neuron_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);

extern void dzdx_model_neuron_py(realtype *dzdx, const int ie, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h);

Expand Down Expand Up @@ -316,8 +316,8 @@ class Model_model_neuron_py : public amici::Model_ODE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_neuron_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_neuron_py(dydx, t, x, p, k, h, w);
}


Expand Down
2 changes: 1 addition & 1 deletion models/model_robertson_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace amici {
namespace model_model_robertson_py {

void dydx_model_robertson_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_robertson_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[0] = 1;
dydx[4] = 10000.0;
dydx[8] = 1;
Expand Down
6 changes: 3 additions & 3 deletions models/model_robertson_py/model_robertson_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdp_explicit_rowvals_model_robertson_py(SUNMatrixWrapper &rowval
extern void dxdotdx_explicit_model_robertson_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *dx, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_robertson_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_robertson_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_robertson_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_robertson_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);



Expand Down Expand Up @@ -292,8 +292,8 @@ class Model_model_robertson_py : public amici::Model_DAE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_robertson_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_robertson_py(dydx, t, x, p, k, h, w);
}


Expand Down
2 changes: 1 addition & 1 deletion models/model_steadystate_py/dydx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace amici {
namespace model_model_steadystate_py {

void dydx_model_steadystate_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx){
void dydx_model_steadystate_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w){
dydx[0] = 1;
dydx[4] = 1;
dydx[8] = 1;
Expand Down
6 changes: 3 additions & 3 deletions models/model_steadystate_py/model_steadystate_py.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern void dxdotdp_explicit_rowvals_model_steadystate_py(SUNMatrixWrapper &rowv
extern void dxdotdx_explicit_model_steadystate_py(realtype *dxdotdx_explicit, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);
extern void dxdotdx_explicit_colptrs_model_steadystate_py(SUNMatrixWrapper &colptrs);
extern void dxdotdx_explicit_rowvals_model_steadystate_py(SUNMatrixWrapper &rowvals);
extern void dydx_model_steadystate_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx);
extern void dydx_model_steadystate_py(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w);



Expand Down Expand Up @@ -292,8 +292,8 @@ class Model_model_steadystate_py : public amici::Model_ODE {
}


void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
dydx_model_steadystate_py(dydx, t, x, p, k, h, w, dwdx);
void fdydx(realtype *dydx, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w) override {
dydx_model_steadystate_py(dydx, t, x, p, k, h, w);
}


Expand Down
7 changes: 4 additions & 3 deletions python/sdist/amici/_codegen/cxx_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def get_deps(self, ode: bool) -> list[str]:
)

def var_in_signature(self, varname: str, ode: bool = True) -> bool:
"""Check if a variable is in the function signature.
"""
Check if a variable is in the function signature as input (``const``).

:param varname: name of the variable to check
:param ode: whether to check the ODE (``True``) or DAE (``False``)
Expand Down Expand Up @@ -225,7 +226,7 @@ def var_in_signature(self, varname: str, ode: bool = True) -> bool:
"dydx": _FunctionInfo(
"realtype *dydx, const realtype t, const realtype *x, "
"const realtype *p, const realtype *k, const realtype *h, "
"const realtype *w, const realtype *dwdx",
"const realtype *w"
),
"dydp": _FunctionInfo(
"realtype *dydp, const realtype t, const realtype *x, "
Expand Down Expand Up @@ -483,6 +484,6 @@ def var_in_function_signature(name: str, varname: str, ode: bool) -> bool:

:return:
boolean indicating whether the variable occurs in the function
signature
signature as ``const`` input.
"""
return name in functions and functions[name].var_in_signature(varname, ode)
19 changes: 9 additions & 10 deletions python/sdist/amici/de_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,16 +2147,15 @@ def sym_or_eq(self, name: str, varname: str) -> sp.Matrix:
the variable symbols if the variable is part of the signature and
the variable equations otherwise.
"""
# dwdx and dwdp will be dynamically computed and their ordering
# within a column may differ from the initialization of symbols here,
# so those are not safe to use. Not removing them from signature as
# this would break backwards compatibility.
if var_in_function_signature(
name, varname, self.is_ode()
) and varname not in [
"dwdx",
"dwdp",
]:
if var_in_function_signature(name, varname, self.is_ode()):
if varname in [
"dwdx",
"dwdp",
]:
# dwdx and dwdp will be dynamically computed, and their
# ordering within a column may differ from the initialization
# of symbols here, so those are not safe to use.
raise AssertionError()
return self.sym(varname)
else:
return self.eq(varname)
Expand Down
2 changes: 1 addition & 1 deletion src/abstract_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void AbstractModel::fdydp(
void AbstractModel::fdydx(
realtype* /*dydx*/, realtype const /*t*/, realtype const* /*x*/,
realtype const* /*p*/, realtype const* /*k*/, realtype const* /*h*/,
realtype const* /*w*/, realtype const* /*dwdx*/
realtype const* /*w*/
) {
throw AmiException(
"Requested functionality is not supported as %s is "
Expand Down
3 changes: 1 addition & 2 deletions src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2084,11 +2084,10 @@ void Model::fdydx(realtype const t, AmiVector const& x) {
derived_state_.dydx_.assign(ny * nx_solver, 0.0);

fw(t, x_pos, false);
fdwdx(t, x_pos, false);
fdydx(
derived_state_.dydx_.data(), t, x_pos, state_.unscaledParameters.data(),
state_.fixedParameters.data(), state_.h.data(),
derived_state_.w_.data(), derived_state_.dwdx_.data()
derived_state_.w_.data()
);

if (always_check_finite_) {
Expand Down
Loading