# Modelling caffeïne effect on alertness in humans with Catalyst

**URL:** https://discourse.julialang.org/t/modelling-caffeine-effect-on-alertness-in-humans-with-catalyst/127736
**Category:** Pluto
**Tags:** question, catalyst
**Created:** [April 5, 2025, 8:34am UTC](https://discourse.julialang.org/t/modelling-caffeine-effect-on-alertness-in-humans-with-catalyst/127736 "2025-04-05T08:34:18Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![modeler32](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@modeler32](https://discourse.julialang.org/u/modeler32)
#### Post date: [April 5, 2025, 8:34am UTC](https://discourse.julialang.org/t/modelling-caffeine-effect-on-alertness-in-humans-with-catalyst/127736/1 "2025-04-05T08:34:18Z")

</div>

Hi everyone,

I am trying to make a reaction network object in Pluto notebook, in which I have to model the effect of caffeine intake on alertness in humans. I’m trying to keep it simple, and this is what I have for now:

"alertness = @reaction\_network begin  
@species C(t) = 0 R(t) = 0.3 #r is alertness, C is caffeine conc

```
@parameters a g d v Ks

# Caffeïne effect on alertness
#hill(C, v, Ks, 4), ∅ --> R(t)  

# Caffeïne effect on alertness (Hill-functie scaled between 0 en 1)
R_max = 1.0 # Max value for alertness
hill(C, v, Ks, 4) / (1 + (Ks / C)^4) * R_max, ∅ --> R # Extra alertness due to caffeine

# Verwijdering van cafeïne 
g, C --> ∅ # natural degradation of caffeine in body
d*(C > 0), R --> ∅ # natural degradation of alertness (alertness caused by caffeine)

```

end"

extra information: I want the alertness to be undefined between 0 and 1, with 1 the max alertness. This is why I changed the Hill function a little bit. Furthermore, I want humans to have a natural alertness of e.g. 0.3. So this is the minimum value for alertness at all times.  
I get an error saying:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/2/825f636fa45713936f98e841b2a77284135233eb.png)  
Could anyone help me?  
After defining this object I would make use of a discrete event, like:  
“condition = [10] =\> [alertness.C = 300]”  
which means at t = 10, the person takes in an amount of 300 mg/L caffeïne by drinking coffee for example. Then I would convert it by using reaction system, make an ODEproblem and solve it. Key for this project is seeing the Hill-like effect of caffeïne on alertness.

Furthermore I also have to do some optimalisation/exploration:  
“Can you design caffeine dosing strategies  
that significantly improve alertness while minimizing caffeine consumption? Can you  
tailor these strategies to different sleep-loss conditions and individual needs?”  
I was thinking of comparing people with sleeploss to people without sleeploss and making 2 catalyst objects and compare them eventually. I don’t know yet how I can improve the alertness while minimizing caffeine consumption.

I am pretty now to Julia & pluto notebook so please keep this in mind. Nothing too crazy has to be in this code. I’d appreciate it if I could get some help.

---

<div class="post-metadata">

### Author: ![modeler32](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@modeler32](https://discourse.julialang.org/u/modeler32)
#### Post date: [April 5, 2025, 8:42am UTC](https://discourse.julialang.org/t/modelling-caffeine-effect-on-alertness-in-humans-with-catalyst/127736/2 "2025-04-05T08:42:42Z")

</div>

Oh and this is the short descirption of the task:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/0/b0fafab8faf465b454566cc940cbb01490341c2f.png)

---

<div class="post-metadata">

### Author: ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)
#### Post date: [April 5, 2025, 12:25pm UTC](https://discourse.julialang.org/t/modelling-caffeine-effect-on-alertness-in-humans-with-catalyst/127736/3 "2025-04-05T12:25:29Z")

</div>

Welcome to the forum @modeler32 !

Please have a look at this guide, in particular to improve the formatting of your code:

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

(if you can’t edit your code, you can also just make a reply with the formatted code below – that will make it much easier for others to help you, and also more likely 🙂 )

Another thing: Is this some sort of homework assignment? I’m just asking for full disclosure – I’m sure people here are willing to help you out with Julia-related problems or with errors of some specific packages.

---

<div class="post-metadata">

### Author: ![modeler32](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@modeler32](https://discourse.julialang.org/u/modeler32)
#### Post date: [April 5, 2025, 1:58pm UTC](https://discourse.julialang.org/t/modelling-caffeine-effect-on-alertness-in-humans-with-catalyst/127736/5 "2025-04-05T13:58:06Z")

</div>

Hi, first of all thank you. I will try to use these rules in the future. Looks like I can’t edit my post but I feel like in this case it’s not necessary to make a new post, the biggest part can be copied.  
And yes, this is an assignment I need to do for my uni.

---

<div class="post-metadata">

### Author: ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)
#### Post date: [April 7, 2025, 5:08pm UTC](https://discourse.julialang.org/t/modelling-caffeine-effect-on-alertness-in-humans-with-catalyst/127736/6 "2025-04-07T17:08:03Z")

</div>

Please post a minimum working example (MWE), formatted as @Sevi suggested so it is easy for people to copy, paste, and run your code.
