[Python] Modélisation procédé - Thermodynamique

Cantera

a marqué ce sujet comme résolu.

Bonjour à tous,

Tout d’abord, j’avais déjà posté ce sujet dans le Forum catégorie Sciences. Je n’ai pas reçu de réponses mais j’ai quand même tenté de modéliser le procédé utilisant Cantera (Python). Je vous laisse lire à propos du procédé ici.

Ici, je poste le code que j’ai écrit et je voudrais savoir si ça fait sens selon vous. Je n’ai pas fini de modéliser le procédé. Pour le moment, j’en suis à l’étape 5–6 comme vous pouvez je voir.

Seule chose que je ne vois pas comment obtenir: Q1, Q2, Q5 et Q6. Auriez-vous une idée de comment faire ? Je suppose que je zappe quelque chose d’évident… (j’ai la différence de température?).

Merci d’avance!

Code (Étapes 1–2 à 5–6 inclus):

import matplotlib.pyplot as plt
import cantera as ct

#T-S diagram so lets make two lists to store T and S values.
T1 = []
S1 = []

# Define feedstocks
nCH4 = 1 #nCH4 
nH2O = 2.5 #nH2O
nCO2 = 0.3 #nCO2
T_reform = 1215  # Reforming temperature in K to have 97% conversion
P = 15*100000 # 15 bar 

# STEP 1-2
CH4 = ct.Solution('gri30.cti')
CH4.X = {"CH4": 1}
CH4.TP = 300, P

CO2 = ct.Solution('gri30.cti')
CO2.X = {"CO2": 0.3}
CO2.TP = 300, P

water = ct.Water()
water.TP = 300, P
#We'll need to define CO2 as well cause it's in the feedstock


# Heat natural gas and
# Heat water to producing steam
# add store T and S
for T in range(300, 600, 2):
    CH4.TP = T, P
    CO2.TP = T, P
    water.TP = T, P

    T1.append(T)
    S1.append(nH2O *water.entropy_mole/1000  + nCH4 * CH4.entropy_mole / 1000 + nCO2 * CO2.entropy_mole / 1000)


# Next we need to mix the gases
# To do this create a new gas solution object with CH4 and steam in the appropriate ratio
steamCH4 = ct.Solution('gri30.cti')
steamCH4.X = {"CH4": nCH4 , "H2O": nH2O, "CO2": nCO2}
steamCH4.TP = 600, P
# Let's also create a Mixture object.
# Mixtures are useful as they keep track of the total moles (extensive). Solutions objects do not (intensive only).
# Mixtures.phase_moles()[0] gets the number of moles in the gas phase, our only phase here.
feedstock = ct.Mixture([(steamCH4, nH2O+nCH4+nCO2)])
feedstock.P = P
feedstock.T = 600

# STEP 2-3 heat feedstock to reforming temperature
for T in range(600, T_reform+10, 10):
    feedstock.T = T
    T1.append(T)
    S1.append((feedstock.phase_moles()[0])* steamCH4.entropy_mole/ 1000)

# STEP 3-4 pass methane and steam through the reformer, store enthalpy before and after
H3 = (feedstock.phase_moles()[0])* steamCH4.enthalpy_mole / 1000
# Use Cantera equilibrate to get equilibrium composition in catalytic reactor.
feedstock.equilibrate('TP')
H4 = (feedstock.phase_moles()[0])* steamCH4.enthalpy_mole / 1000
print("Q_r = Delta H [J/mol] = ", H4-H3, "[J/mol CH4]")

T1.append(T_reform)
S1.append((feedstock.phase_moles()[0])* steamCH4.entropy_mole / 1000)

print("xi_CH4: ", 1-steamCH4.X[steamCH4.species_index("CH4")]*(feedstock.phase_moles()[0]))
print("p_H2O [bar]: ",  steamCH4.X[steamCH4.species_index("H2O")]*P/100000)

T_condense = 140 + 273 # approximate condensation temperature for water at 15 bar 

# STEP 4-5 
for T in range(T_reform, T_condense, -10):
    feedstock.T = T
    T1.append(T)
    S1.append((feedstock.phase_moles()[0])* steamCH4.entropy_mole/ 1000)


# STEP 5-6
# Condense out water by making new solution, Syngas without the H2O component
# This a simplification as the water would gradually be condensed over a temperature range and not simply isothermally.
n_water = feedstock.phase_moles()[0]*(steamCH4.X[steamCH4.species_index("H2O")])
water.TP = T_condense, P

Syngas = ct.Solution('gri30.cti')
n_Syngas = feedstock.phase_moles()[0]*(1-steamCH4.X[steamCH4.species_index("H2O")])
Syngas.X = {"H2": steamCH4.X[steamCH4.species_index("H2")],
            "CO":steamCH4.X[steamCH4.species_index("CO")],
            "CO2": steamCH4.X[steamCH4.species_index("CO2")]}
Syngas.TP = T_condense, P

#Syngas composition
print("H2 : CO : CO2", Syngas.X[Syngas.species_index("H2")], Syngas.X[Syngas.species_index("CO")], Syngas.X[Syngas.species_index("CO2")])
print("S-module: ", (Syngas.X[Syngas.species_index("H2")]- Syngas.X[Syngas.species_index("CO2")])/(Syngas.X[Syngas.species_index("CO")]+Syngas.X[Syngas.species_index("CO2")]))

T1.append(T)
S1.append(n_Syngas*Syngas.entropy_mole/1000 + n_water*water.entropy_mole/1000)

#STEP 5-6 Next cool the syngas to 300 K
for T in range(T_condense, 300, -10):
    Syngas.TP = T, P
    T1.append(T)
    S1.append(n_Syngas*Syngas.entropy_mole/1000 + n_water*water.entropy_mole/1000)

plt.style.use('ggplot')
plt.plot(S1, T1)
plt.xlabel('$S$ [J mol$^{-1}$ K$^{-1}$]')
plt.ylabel('$T$ [K]')
plt.title("TS-diagram, $S_\mathrm{feedstock}$ per mole CH$_4$")
plt.savefig("Steam-reforming_TS-diagram.png")
plt.show()
+0 -0
Connectez-vous pour pouvoir poster un message.
Connexion

Pas encore membre ?

Créez un compte en une minute pour profiter pleinement de toutes les fonctionnalités de Zeste de Savoir. Ici, tout est gratuit et sans publicité.
Créer un compte