Skip to content

Commit

Permalink
Setup of the first BSTR example
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaedler committed Sep 15, 2024
1 parent 984ae75 commit 8ffa3f1
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ uuid = "3852ba64-8153-459f-9b4c-35a924b2b981"
authors = ["Jonathan Mädler <[email protected]>"]
version = "1.0.0-DEV"

[deps]
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"

[compat]
julia = "1.10"

Expand Down
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ makedocs(;
canonical="https://jmaedler.github.io/ProcessModels.jl",
edit_link="main",
assets=String[],
prettyurls = get(ENV, "CI", nothing) == "true", # Modifiziert: für ordentliche lokale Verlinkung
),
pages=[
"Home" => "index.md",
"BSTR" => "examples/simple_bstr.md"
],
)

deploydocs(;
repo="github.com/jmaedler/ProcessModels.jl",
devbranch="main",
)
)
22 changes: 22 additions & 0 deletions docs/src/examples/simple_bstr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Simple Batch Rector

This is a simple model of an batch stirred tank reactor (BSTR). Assuming a reaction system of

```math
\mathrm{A} \rightarrow \mathrm{B}
```

the following system of differential equations can be derived:


```math
\begin{align*}
\frac{\mathrm{d} \, c_\mathrm{A}}{\mathrm{d} \, t} &= - k \, c_\mathrm{A} \\
\frac{\mathrm{d} \, c_\mathrm{B}}{\mathrm{d} \, t} &= k \, c_\mathrm{B}
\end{align*}
```

| Name | Unit | Description |
| :--- | :--- | :--- |
|``c_\mathrm{A}``| ``\mathrm{mol \, L^{-1}}`` | Molar concentration of species A |
|``c_\mathrm{B}``| ``\mathrm{mol \, L^{-1}}`` | Molar concentration of species B |
16 changes: 16 additions & 0 deletions examples/run_simpleBSTR.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using ProcessModels
using ModelingToolkit
using DifferentialEquations
using Plots

@mtkbuild bstr = SimpleBSTR(;k = 1)

u_0 = [bstr.c_A => 10, bstr.c_B => 0]

tspan = (0,10)

prob = ODEProblem(bstr,u_0,tspan)

sol = solve(prob)

plot(sol)
15 changes: 15 additions & 0 deletions src/BSTR.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using ModelingToolkit: t_nounits as t, D_nounits as D

@mtkmodel SimpleBSTR begin
@parameters begin
k
end
@variables begin
c_A(t)
c_B(t)
end
@equations begin
D(c_A) ~ -k*c_A
D(c_B) ~ k*c_A
end
end
4 changes: 4 additions & 0 deletions src/ProcessModels.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module ProcessModels

using ModelingToolkit
# Write your package code here.

include("BSTR.jl")
export SimpleBSTR

end

0 comments on commit 8ffa3f1

Please sign in to comment.