This app allows you to control different operating parameters (e.g., feed temperature and volume flow rate) and study the dynamic behavior of a CSTR. Furthermore, you are able to define your own power-law reactions and scripts to change input parameters.
![cascade](https://private-user-images.githubusercontent.com/100750226/245081530-f9548e07-1e59-4ddb-8fa4-465019202390.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5NjI5MTEsIm5iZiI6MTcyNTk2MjYxMSwicGF0aCI6Ii8xMDA3NTAyMjYvMjQ1MDgxNTMwLWY5NTQ4ZTA3LTFlNTktNGRkYi04ZmE0LTQ2NTAxOTIwMjM5MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMFQxMDAzMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mMDAyMTZhZDEzM2Y4YmQ1YmMyOTEzYWRkNWY5MTIzZjBhZWU0YzMzMmI0N2FiZDgzMWRkZTkyMzMzMzg3OWZmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Xk8AzjUAcnjYIId354CO0OJV3d33G50PVV77nyNjXlQ)
The change of reactor temperature and concentrations of components with time is obtained by solving a system of ordinary differential equations:
where
These equations are solved using explicit Runge-Kutta method of order 5(4). The error is controlled assuming accuracy of the fourth-order method, but steps are taken using the fifth-order accurate formula.
The steady-state heat generation/removal rate (
The steady-state heat balance equation (
which simply means
We can rearrange this equation to find the required coolant temperature
The contour plot below demonstrates the relationship between
![TvT_contour](https://private-user-images.githubusercontent.com/100750226/244961546-de0d5d99-cab9-41b0-b51c-f2d21c3f41ee.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5NjI5MTEsIm5iZiI6MTcyNTk2MjYxMSwicGF0aCI6Ii8xMDA3NTAyMjYvMjQ0OTYxNTQ2LWRlMGQ1ZDk5LWNhYjktNDFiMC1iNTFjLWYyZDIxYzNmNDFlZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMFQxMDAzMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05NzA1YzI4ZDRhMGVjZjI1MjgzNDczMmUyZDU3NmMwMzRkNTI3MDBmZDlhMzc3MzM2ZTQ2N2FiNzU3YzQ4MTMxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.BK2HjhqLzDMPwM5YSJM6ZJhveFORQcgk_UEj0KHeGkQ)
If we draw a straight line at a certain space velocity, like the yellow one, we find 5 intersections at
Reactions can be defined by a .json
file under reactions
directory. An example file for the first-order reaction
[
{
"A": [-1, 1], // "reactant": [stoichiometry, exponent]
"P": [1, 0], // "product": [stoichiometry, exponent]
"k0": 1e13, // 1/s
"Ea": 100, // kJ/mol
"dH": -2e7 // J/kmol
},
{
"C0": {
"A": 5, // kmol/m3
"P": 0 // kmol/m3
},
"VR": 10, // m3
"v": 1e-2, // m3/s
"T0": 300, // K
"rho": 850, // kg/m3
"Cp": 2200, // J/(kg*K)
"Tc": 300, // K
"UA": 1000 // J/(s*K)
}
]
We can define multiple reactions in one file, so that we can simulate a complex system composed of many simple power-law reactions. Take the van de Vusse reaction for example:
The .json
file for the van de Vusse reaction looks like this:
[
{
"A": [-1, 1],
"B": [1, 0],
"k0": 3.575e8,
"Ea": 81.1305,
"dH": 4.2e6
},
{
"B": [-1, 1],
"C": [1, 0],
"k0": 3.575e8,
"Ea": 81.1305,
"dH": -11e6
},
{
"A": [-2, 2],
"D": [1, 0],
"k0": 2.512e6,
"Ea": 71.16784,
"dH": -41.85e6
},
{
"C0": {
"A": 5.1,
"B": 0,
"C": 0,
"D": 0
},
"VR": 0.01,
"v": 1.667e-3,
"T0": 387.05,
"rho": 934.2,
"Cp": 3010,
"Tc": 350,
"UA": 240.8,
"initial": {
"C": [2.2291, 1.0417, 0.9140, 0.9152],
"T": 352.741
}
}
]
We use 3 {}
to define those reactions and then use the last {}
to specify other necessary operating parameters. Be aware that enthalpy of reaction ( dH
) and reaction rate is calculated based on the first component written in each {}
. In this case, we also set initial values for concentrations and reactor temperature by specifying initial
(optional). If specified, values in initial["C"]
will be assigned to each component at t=0; if not specified, the initial values of C
will be set to 0 and T
to T0
.
The control over operating variables (scripts/scripts.json
. Each entry contains the script name and a piece of python code.
{
"T0 increases linearly": ["T0", "T0 + 0.5"],
"T0 decreases linearly": ["T0", "T0 - 0.5"],
"T0 fluctuates in a sine wave": ["T0", "350 + 20 * sin( 0.02 * pi * t)"],
"Tc increases linearly": ["Tc", "Tc + 0.5"],
"Tc decreases linearly": ["Tc", "Tc - 0.5"],
"Tc fluctuates in a sine wave": ["Tc", "320 + 20 * sin( 0.02 * pi * t)"],
"v increases linearly": ["v", "v + 0.0005"],
"v decreases linearly": ["v", "v - 0.0005"],
"UA increases linearly": ["UA", "UA + 20"],
"UA decreases linearly": ["UA", "UA - 20"]
}
Each brackets []
consists of two strings: the variable to control and the value to be assigned to it. All scripts are executed once in each frame. That is to say, if you set Seconds Per Frame to 10, and select the first script, the program will do T0 = T0 + 0.5
at each frame, so that T0
will increase 0.5 K every 10 seconds.
Once a script is created or modified, save the file and click the Reset button, and it will automatically appear on this window:
![control-variables](https://private-user-images.githubusercontent.com/100750226/245081676-a7b4fa02-f0cd-4748-b2ed-409079536a61.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5NjI5MTEsIm5iZiI6MTcyNTk2MjYxMSwicGF0aCI6Ii8xMDA3NTAyMjYvMjQ1MDgxNjc2LWE3YjRmYTAyLWYwY2QtNDc0OC1iMmVkLTQwOTA3OTUzNmE2MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkxMFQxMDAzMzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02NTlmNDVhMTQ0ZmI3NWZlZjZmODllYjJiNTUyZWNkY2I2M2I2ODIwMjk2NjhmOTM0M2ZkYmQ0MDMwOGYxMjcyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.a2VKEt8LILodZhWufVK2KfHUGqEt1TrvlsNqI8TU4zw)