-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |