diff --git a/Project.toml b/Project.toml index dbdf863..6ad6251 100644 --- a/Project.toml +++ b/Project.toml @@ -3,6 +3,11 @@ uuid = "3852ba64-8153-459f-9b4c-35a924b2b981" authors = ["Jonathan Mädler "] 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" diff --git a/docs/make.jl b/docs/make.jl index a47a6e5..a1a3c48 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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", -) +) \ No newline at end of file diff --git a/docs/src/examples/simple_bstr.md b/docs/src/examples/simple_bstr.md new file mode 100644 index 0000000..d6cd3a1 --- /dev/null +++ b/docs/src/examples/simple_bstr.md @@ -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 | \ No newline at end of file diff --git a/examples/run_simpleBSTR.jl b/examples/run_simpleBSTR.jl new file mode 100644 index 0000000..f88da7b --- /dev/null +++ b/examples/run_simpleBSTR.jl @@ -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) \ No newline at end of file diff --git a/src/BSTR.jl b/src/BSTR.jl new file mode 100644 index 0000000..de3f4ed --- /dev/null +++ b/src/BSTR.jl @@ -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 \ No newline at end of file diff --git a/src/ProcessModels.jl b/src/ProcessModels.jl index b932e05..9bf2f38 100644 --- a/src/ProcessModels.jl +++ b/src/ProcessModels.jl @@ -1,5 +1,9 @@ module ProcessModels +using ModelingToolkit # Write your package code here. +include("BSTR.jl") +export SimpleBSTR + end