domingo, 21 de diciembre de 2025

Starting with IDAES: Steady state CSTR

Recently I started using IDAES for simulating chemical engineering processes. For my first example, I choose a CSTR at steady state.

For the following reaction:

$$A \rightarrow B$$

The mass balance equation for \(A\) is:

$$FC_{A,out} = FC_{A,in} - V \cdot k \cdot C_{A,out}$$

Where:

  • \(F\) is the total volumetric flow.
  • \(C_{A}\) is the concentration of component A.
  • \(V\) is the volume.
  • \(k\) is the kinetic constant for a first-order reaction.

The algebraic solution for the value of concentration at the outlet is:

$$C_{A,out} = \frac{C_{A,in}}{1 + (kV/F)}$$

Data

Besides the \(A\) and \(B\) components, an inert \(C\) component was added as a solvent. The data for the simulation is:

$$F_{A,inlet} = 50 \text{ mol/s}$$

$$F_{B,inlet} = 0 \text{ mol/s}$$

$$F_{C,inlet} = 450 \text{ mol/s}$$

Whereas the CSTR and the reaction are defined by the following values:

$$V = 5 \text{ m}^3$$

$$k = 1e-4 \text{1/s}$$

The result for the concentration at the outlet is:

$$C_{A,oulet}=34483 \text{ mol/s}$$


The notebook with the implementation, and the required properties and reaction properties files can be found here:

code




lunes, 15 de diciembre de 2025

The diluted solution approximation for the computation of concentrations

When working with a process simulator, specifying the composition of a stream in terms of mass fractions is the "easiest" approach.

That's because mass is a conserved quantity, so the fraction of a certain "component" of the mixture is the same if the components are accounted for separately, and after they are physically combined in a single stream.

But what if we want to go from mass fraction to, say, concentration by volume?

We have,

$$ \begin{aligned} \text{Conc}_i &= \text{mass}_i / \text{total_volume} \\ &= \text{total_mass} * \text{mass_fraction} / (\text{total_mass} / \text{density}) \\ &= \text{mass_fraction} * \text{density} \end{aligned} $$

So we need and expression for the density of the mixture in terms of the mass fractions (and other state variables), that is, an equation of state.

Here enters the "dilute mixture" approximation. 

Now we say that if the mixture is "dilute", meaning every component but one (called solvent) is present only in small fraction, the density of the mixture is effectively approximated by the solvent density, which is known from an equation of state for the pure solvent, which is expectedly easier to solve than an equation of state for the arbitrary composition of an n-component mixture.

With that we have:

$$ \text{Conc}_i = \text{mass}_i * \text{density_solvent} $$ 

for every component, and we can easily go from mass fraction to volume concentration.



domingo, 2 de marzo de 2025

Working with equations of state

 Working on implementation of equations of state, which involved solving the following problems:

 

a) Calculate the compressibility factor and the molar volume of methanol vapor at 200 °C and 10 bar. Virial equation versus ideal gas law.


b) Calculate the pressure of 1 mol of CO2 in a container of 2.5 dm3 at 40 °C. Virial equation versus Redlich-Kwong equation versus ideal gas.


c) Retrieve the vapor pressure and the liquid density data for methane from the DDBSP data base. Implement a liquid vapor pressure calculation for the Van der Waals equation of state and compare the results along the vapor-liquid coexistence curve to the experimental data.


d) Calculate the vapor pressures of benzene between 280 K and 540 K using the Soave-Redlich-Kwong equation of state.

The solutions can be found in the following Jupyter notebook.

The supplementary information is here and here.



sábado, 2 de noviembre de 2024

Excel: Sum is more robust than the "+" operator

 Did you know?, in Excel the SUM function is more robust than simply writing the "+" operator,

Check cell E7, where the SUM function is used, and cell E6, where the "+" operator is used, both for two inputs: C6, which contains a number, and D6, which contains the character "a".

Example: Fórmulas.


Example: results.


As you can see, the "+" operator fails with an error message, but the SUM function returns the result based on the numeric input only.

This is something to have in mind when designing a spreadsheet!


domingo, 11 de abril de 2021

Thermodynamics fundamentals - Part 2

Still working on thermodynamics problems....

 

We have the change in Gibbs free energy for the following reactions (every compound is a separate phase:

$Al_2O_3(s)+SiO_2(s)=Al_2SiO_5(s)$ $\Delta G^{\circ}=-8320-0.4T$ $J$

 

$3Al_2O_3(s) +2SiO_2(s)=Al_6Si_2O_{13}(s)$ $\Delta G^{\circ}=22770-31.8T$ $J$


a) Compute $\Delta G^{\circ}$ for the following reactions:

 

$3Al_2SiO_5=Al_6Si_2O_{13}+SiO_2$

 

$Al_6Si_2O_{13}=2Al_2SiO_5+Al_2O_3$

 

also compute the temperatures for which $\Delta G^{\circ}=0$

 

b) Plot the phase diagram for the system $SiO_2\cdot Al_2O_3$ between 45 and 65% mol percent $Al_2O_3$ at atmospheric pressure and the temperatures computed on a9)


c) For the reaction $3Al_2SiO_5=Al_6Si_2O_{13}+SiO_2$, $\Delta V>0$ ¿How would the coexistence temperature of these phases change if pressure increases?


The solution can be found on this Juypter notebook.

You can also check part one of this series here.


domingo, 4 de abril de 2021

Thermodynamics fundamentals

 Recently I have been reading Principles of extractive metallurgy , I'm currently at the starting chapters, mostly thermodynamics review. I will create an entry for every chapter with a couple of solved problems. 

So for this week these are the exercises:

1) For the reaction $H_2\text{(g, 1 atm)}+\frac{1}{2}O_2\text{(g, 1 atm)}=H_2O\text{(l)}$, $\Delta H^{\circ}_{298}=-285.9$ kJ and $\Delta G^{\circ}_{298}=-238$ kJ.

a) Compute $\Delta S^{\circ}_{298}$

b) The reaction can proceed at 298 K and 1 atm in a reversible way, for example, in a fuel cell, or in a completely irreversible form, that is, by combustion with no other work besides volume. Compute for both cases the heat $q$ absorbed from the environment and, for case a), the work $w'$ done on the environment. Show that your results are in agreement with the second law of thermodynamics.

Now I will try using a jupyter notebook for storing the solutions, I think the possibility of combining text and code could be useful for problems that requires several calculations.

The solution can be found here.

 

 

 

 

 

 

 

 

 

 





Starting with IDAES: Steady state CSTR