# Using External Function Feature

**URL:** <https://forum.cadet-web.de/t/using-external-function-feature/136>\
**Category:** CADET Troubleshooting\
**Tags:** modeling\
**Created:** [July 16, 2020, 5:47am UTC](https://forum.cadet-web.de/t/using-external-function-feature/136 "2020-07-16T05:47:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![clem](https://forum.cadet-web.de/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@clem](https://forum.cadet-web.de/u/clem)\
**Post date:** [July 16, 2020, 5:47am UTC](https://forum.cadet-web.de/t/using-external-function-feature/136/1 "2020-07-16T05:47:50Z")

</div>

I’ve tried to specify the external functions for a test model using multi-component Langmuir, just so I can understand how to set up the dependent model parameters in CADET python (ver 3.1.2). When I tried to run the simulation, I received a warning:

_“returncode=0, stdout=b’[Warning: setExternalFunctions::212] Index -1 exceeds number of passed external functions (0), external dependence is ignored\r\n[Warning: setExternalFunctions::212] Index -1 exceeds number of passed external functions (0), external dependence is ignored\r\n”_

The simulation seemed to have worked, however the output shows that the simulation did not take into account the dependence on the external function. I’m not exactly sure if I have it set up correctly; please see attached for the .h5 file. I appreciate any advice and help!

[ext\_test.h5](https://forum.cadet-web.de/uploads/short-url/tJIS8xHcnaljDkulVAliFBQNFsN.h5) (79.4 KB)

---

<div class="post-metadata">

**Author:** ![s.leweke](https://forum.cadet-web.de/user_avatar/forum.cadet-web.de/s.leweke/32/1323_2.png) [@s.leweke](https://forum.cadet-web.de/u/s.leweke)\
**Post date:** [July 17, 2020, 9:59am UTC](https://forum.cadet-web.de/t/using-external-function-feature/136/2 "2020-07-17T09:59:38Z")

</div>

You need to assign the external function to the binding model:  
Add the integer dataset `EXTFUN` with value `0` to the group `/input/model/unit_001/adsorption`. This tells the binding model that `source_000` is assigned to all its parameters.  
In Python, this corresponds to

```python
myCadetModel.root.input.model.unit_001.adsorption.extfun = 0

```

You will still receive some warnings like

```auto
Index 0 exceeds number of passed external functions (0), external dependence is ignored

```

but these can be safely ignored.

Note that you’ll see the same chromatogram, though. Since you’re using a `FILM_DIFFUSION` of `0.0`, the molecules cannot enter the particles. Hence, no binding occurs and you cannot see the effect of the external function.

---

<div class="post-metadata">

**Author:** ![clem](https://forum.cadet-web.de/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@clem](https://forum.cadet-web.de/u/clem)\
**Post date:** [July 20, 2020, 9:27pm UTC](https://forum.cadet-web.de/t/using-external-function-feature/136/3 "2020-07-20T21:27:43Z")

</div>

Thank you! The adsorption parameters seemed to be linked to `source_000` now.

This is tangentially related, but is there a way to plot `source_XXX` (or any model parameters that belong to the input group) vs. time in CADET? I’m a new user and am learning to navigate in Python.

---

<div class="post-metadata">

**Author:** ![s.leweke](https://forum.cadet-web.de/user_avatar/forum.cadet-web.de/s.leweke/32/1323_2.png) [@s.leweke](https://forum.cadet-web.de/u/s.leweke)\
**Post date:** [July 20, 2020, 9:55pm UTC](https://forum.cadet-web.de/t/using-external-function-feature/136/4 "2020-07-20T21:55:01Z")

</div>

There’s nothing built-in, as far as I know.

For the external functions, you can adapt this script:

```python
import numpy as np
import scipy.interpolate as scip
import matplotlib.pyplot as plt

section_times = [0.0, 2.0, 5.0, 10.0]
const_coeff = [0.0, 1.0, 2.0]
lin_coeff = [0.5, -0.1, 0.2]
quad_coeff = [0.0, 0.0, 0.0]
cube_coeff = [0.0, 0.0, 0.0]
velocity = 0.1 
col_length = 0.12

# Evaluation point in column (axial coordinate between 0 and col_length)
z = 0.1

# Convert to piecewise polynomial in scipy format
c = np.array([cube_coeff, quad_coeff, lin_coeff, const_coeff])
p = scip.PPoly(c, section_times)

# Evaluate at point z
t = np.linspace(min(section_times), max(section_times), 1001)
extFun = p((1.0 - z / col_length) / velocity + t)

plt.plot(t, extFun)
plt.xlabel('Time [s]')
plt.ylabel('External Function at z = {}'.format(z))
plt.grid(True)
plt.show()

```

---

<div class="post-metadata">

**Author:** ![h.lanzrath](https://forum.cadet-web.de/user_avatar/forum.cadet-web.de/h.lanzrath/32/1186_2.png) [@h.lanzrath](https://forum.cadet-web.de/u/h.lanzrath)\
**Post date:** [January 27, 2026, 7:24am UTC](https://forum.cadet-web.de/t/using-external-function-feature/136/5 "2026-01-27T07:24:37Z")

</div>


