c = [0.004, 0.0087, 0.019, 0.024, 0.094, 0.195]
q = [0.026, 0.053 , 0.075, 0.082, 0.123, 0.129]
html('<h2>Solución</h2>')
datos_eq = zip(c,q)
%var c_A, q_A_max, K_Ac, n
L = 15
c0 = 1.30
M = 180.156
S1 = 20
q0 = 0
S2 = 20
c0 = c0*M/1000
html('<h3>Parte a) Ajustar a el modelo de Langmuir y Freundlich</h3>')
show("===== Isoterma de Langmuir =====")
qA_L(c_A) = q_A_max*K_Ac*c_A / (1+K_Ac*c_A)
ajuste = find_fit(datos_eq, qA_L, solution_dict = True)
qA_L = qA_L(q_A_max= numerical_approx(ajuste[q_A_max], digits = 4), K_Ac= numerical_approx(ajuste[K_Ac], digits=4))
show(r"$K_{A,c} = $ ", numerical_approx(ajuste[K_Ac], digits=4), r" L/kg; $q_{A,máx} = $", numerical_approx(ajuste[q_A_max], digits=4), " kg/kg")
show("$q_{A_L} = $", qA_L)
show("===== Isoterma de Freundlich =====")
qA_F(c_A) = K_Ac*c_A^(1/n)
ajuste = find_fit(datos_eq, qA_F, solution_dict = True)
qA_F = qA_F(n= numerical_approx(ajuste[n], digits=4), K_Ac=numerical_approx(ajuste[K_Ac], digits=4))
show(r"$K_{A,c} = $ ", numerical_approx(ajuste[K_Ac], digits=4), r" L/kg; $n = $", numerical_approx(ajuste[n], digits=4))
show("$q_{A_F} = $", qA_F)
gr_datos = scatter_plot(datos_eq, axes_labels = ['$c_A/(\\mathrm{kg/L})$', '$q_A/(\\mathrm{kg/kg})$'])
gr_Langm = plot(qA_L, xmin = 0, xmax = max(max(c),c0), legend_label = 'Langmuir', color = 'blue')
gr_Frlch = plot(qA_F, xmin = 0, xmax = max(c), legend_label = 'Freundlich', color = 'green')
show(gr_datos+gr_Langm+gr_Frlch)
html('<h3>Parte b) Una etapa</h3>')
def Calcula_etapa(W_L, W_S, c_entra, q_entra, q_isot):
R.<c_sale> = QQ[]
q_sale = q_isot(c_sale)
f = c_sale - (W_S/W_L * (q_entra - q_sale) + c_entra)
csale = find_root(f, 0, c_entra)
return [csale, q_sale(c_sale=csale)]
c1, q1 = Calcula_etapa(L, S1, c0, q0, qA_L)
show (r'$c_1 = %s$ kg/L; $q_1 = %s$ kg/kg' %(numerical_approx(c1, digits = 3), numerical_approx(q1, digits=3)))
html('<h3>Parte c) Dos etapas a flujo cruzado, idénticas cantidades de sólido</h3>')
c2, q2 = Calcula_etapa(L, S2, c1, q0, qA_L)
show (r'$c_2 = %s$ kg/L; $q_2 = %s$ kg/kg' %(numerical_approx(c2, digits = 3), numerical_approx(q2, digits=3)))
gr_etapa1 = line([(c0,q0),(c1,q1),(c1,0)], color = 'purple', legend_label = 'Etapa 1')
gr_etapa2 = line([(c1,q0),(c2,q2),(c2,0)], color = 'magenta', legend_label = 'Etapa 2')
show(gr_datos+gr_Langm+gr_etapa1+gr_etapa2)
html('<h3>Parte d) Dos etapas a flujo cruzado, calcular sólido mínimo</h3>')
S1m = L*(c0-c_A)/(qA_L(c_A) + q0)
S2m = L*(c_A-c2)/(qA_L(c_A=c2) + q0)
STm = S1m+S2m
S_Tm, c1 = find_local_minimum(STm, c2, c0)
show (r"$S_{T}$ /kg $=$", STm)
show (r"$S_{T, mín}= %s$ kg; $c_{1}= %s$ kg/L" %(numerical_approx(S_Tm, digits=3), numerical_approx(c1, digits=3)))
show (r"$Ahorro = %s $ kg" %(numerical_approx(((S1+S2)-S_Tm), digits=3)))
show (r"$S_{1}= %s$ kg; $S_{2}= %s$ kg" %(numerical_approx(S1m(c1), digits=3), numerical_approx(S2m(c1), digits=3)))
html('<h3>Parte e) Una etapa con total obtenido en d)</h3>')
c1, q1 = Calcula_etapa(W_L=L, W_S=S_Tm, c_entra=c0, q_entra=q0, q_isot=qA_L)
show (r'$c_1 = %s$ kg/L; $q_1 = %s$ kg/kg' %(numerical_approx(c1, digits = 3), numerical_approx(q1, digits=3)))