<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#U12.1 
"""
13 kg smesi toluenu a 8 % (hm.) acetonu bylo pri 20 ˚C smıchano a) se 7 kg vody, b) s cinidlem, ktere obsahovalo 
25 kg vody a 0,5 kg acetonu. Po promıchanı a ustavenı rovnovahy byly vznikle faze rozdeleny. Urcete hmotnostnı 
zlomky acetonu v obou fazıch a mnozstvı acetonu v procentech presle do vodne faze (tj. vyteznost) pro oba prıpady. 
"""
import sympy as sym
import numpy as np
from matplotlib import pyplot as plt

#A...acetone
#B...water
#C...toluene

#a) 
mF=13 #kg, mass of feed
wAF=0.08 #kgA/kgTOT, mass fraction of acetone in feed
mS=7 #kg, mass of solvent
uAS1=0 #kgA/kgTOT, mass fraction of acetone in solvent

WAF=wAF/(1-wAF) #kgA/kgC, relative mass fraction
UAS1=0 #kgA/kgB, relative mass fraction
mB=mS*(1-uAS1) #kg, mass water
mC=mF*(1-wAF) #kg, mass toluene

#eqilibrium data from vscht.uchi.cz, regression curve from excel
#Ue=-2.18301*We^2 + 1.33420*We + 0.00249
#R2=0.99914
def Ue(We):
    return -2.18301*We**2 + 1.33420*We + 0.00249

#solve balance plus equlibrium
WA1 = sym.symbols('WA1')
r1=sym.Eq(mC*WAF+mB*UAS1, mC*WA1+mB*Ue(WA1))
res = sym.solve(r1)

#asign results
WA1=res[0] #kgA/kgC, relative mass fraction
UA1=Ue(WA1) #kgA/kgB, relative mass fraction
wA1=WA1/(1+WA1) #kgA/kgTOT, mass fraction of acetone in rafinate
uA1=UA1/(1+UA1) #kgA/kgTOT, mass fraction of acetone in extract

mE=mB/(1-uA1) #kg, mass of extract
mR=mC/(1-wA1) #kg, mass of rafinate

yield1=(1-WA1/WAF)*100 # %, amout of acetone transfered from toluene to water phase
#yield1=(1-(wA1*mR)/(wAF*mF))*100 # %, amout of acetone transfered from toluene to water phase, same result

print("a)____________________________") 
print("WA1:","%.4f" %WA1,"kgA/kgC")
print("UA1:","%.4f" %UA1,"kgA/kgB")

print("wa1:","%.4f" %wA1,"kgA/kgTOT")
print("ua1:","%.4f" %uA1,"kgA/kgTOT")
print("")
print("The mass fraction of acetone in exctract is", "%.3f" %uA1, "and in rafinate", "%.3f" %wA1,".")
print("Yield:","%.1f" %yield1, "%")

"""
plot results
"""
x = np.linspace(0, 0.12, 50)
plt.plot(x, Ue(x), color='red', label="equilibrium")
plt.plot([WAF,WA1], [UAS1,UA1], color='blue', label="balance a)")

plt.plot(WAF, UAS1, "o", label="input a)")
plt.plot(WA1, UA1, "o", label="output a)")

plt.plot([WA1,WA1], [UA1,0], "--", color='grey')
plt.plot([WA1,0], [UA1,UA1], "--", color='grey')

#plt.show()



#b)_______________________________________________________________________________
mF=13 #kg, mass of feed
wAF=0.08 #kgA/kgTOT, mass fraction of acetone in feed
mS=25.5 #kg, mass of solvent
uAS1=0.5/25 #kgA/kgTOT, mass fraction of acetone in solvent

WAF=wAF/(1-wAF) #kgA/kgC, relative mass fraction
UAS1=uAS1/(1-uAS1) #kgA/kgB, relative mass fraction
mB=mS*(1-uAS1) #kg, mass water
mC=mF*(1-wAF) #kg, mass toluene

#solve balance plus equlibrium
WA1 = sym.symbols('WA1')
r1=sym.Eq(mC*WAF+mB*UAS1, mC*WA1+mB*Ue(WA1))
res = sym.solve(r1)

#asign results
WA1=res[0] #kgA/kgC, relative mass fraction
UA1=Ue(WA1) #kgA/kgB, relative mass fraction
wA1=WA1/(1+WA1) #kgA/kgTOT, mass fraction of acetone in rafinate
uA1=UA1/(1+UA1) #kgA/kgTOT, mass fraction of acetone in extract

mE=mB/(1-uA1) #kg, mass of extract
mR=mC/(1-wA1) #kg, mass of rafinate

yield1=(1-WA1/WAF)*100 # %, amout of acetone transfered from toluene to water phase
#yield1=(1-(wA1*mR)/(wAF*mF))*100 # %, amout of acetone transfered from toluene to water phase, same result

print("b)____________________________") 
print("WA1:","%.4f" %WA1,"kgA/kgC")
print("UA1:","%.4f" %UA1,"kgA/kgB")

print("wa1:","%.4f" %wA1,"kgA/kgTOT")
print("ua1:","%.4f" %uA1,"kgA/kgTOT")
print("")
print("The mass fraction of acetone in exctract is", "%.3f" %uA1, "and in rafinate", "%.3f" %wA1,".")
print("Yield:","%.1f" %yield1, "%")


"""
#plot results
"""
#x = np.linspace(0, 0.12, 50)
#plt.plot(x, Ue(x), color='red', label="equilibrium")
plt.plot([WAF,WA1], [UAS1,UA1], color='black', label="balance b)")
plt.plot(WAF, UAS1, "o", label="input b)")
plt.plot(WA1, UA1, "o", label="output b)")

plt.plot([WA1,WA1], [UA1,0], "--", color='grey')
plt.plot([WA1,0], [UA1,UA1], "--", color='grey')
plt.xlabel('$W_{A}$ (kgA/kgC)')
plt.ylabel("$U_{A}$ (kgA/kgB)")
plt.ylim(0, 0.08)
plt.xlim(0,0.1)
plt.legend()
plt.show()



"""
Vysledek: 
a) Rafinat obsahuje 4,8 % (hm.) acetonu, v extraktu je obsazeno 5,9 % (hm.) acetonu a preslo do neho 42,2 % acetonu. 
b) Rafinat obsahuje 3,3 % (hm.) acetonu, v extraktu je obsazeno 4,4 % (hm.) acetonu a preslo do neho 60,4% acetonu.
"""</pre></body></html>