0% found this document useful (0 votes)
9 views5 pages

Lamdas 1 y 2

The document contains a series of exercises involving calculations for equilibrium constants and convergence criteria using iterative methods in a programming context. It includes subroutines for calculating lambda values and functions based on user inputs for initial values, constants, and pressure. The exercises demonstrate the application of numerical methods to find equilibrium states in a chemical system.

Uploaded by

Angel Vazquez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Lamdas 1 y 2

The document contains a series of exercises involving calculations for equilibrium constants and convergence criteria using iterative methods in a programming context. It includes subroutines for calculating lambda values and functions based on user inputs for initial values, constants, and pressure. The exercises demonstrate the application of numerical methods to find equilibrium states in a chemical system.

Uploaded by

Angel Vazquez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Ejercicio 6

DECLARE SUB LAMBDA1 (K1, P, l1, l2, CONV, l1p)

DECLARE SUB LAMBDA2 (K2, P, l1p, l2, CONV, l2p)

INPUT "Valor inicial de lambda 1"; L1INI

INPUT "Valor inicial de lambda 2"; L2INI

INPUT "Constante de equilibrio 1"; K1

INPUT "Constante de equilibrio 2"; K2

INPUT "Presion (atm)"; P

INPUT "Criterio de convergencia (%)"; CONV

CLS

DO

l1 = L1INI

l2 = L2INI

LAMBDA1 K1, P, l1, l2, CONV, l1p

LAMBDA2 K2, P, l1p, l2, CONV, l2p

EPR1 = ABS((l1p - L1INI) / l1p) * 100

EPR2 = ABS((l2p - L2INI) / l2p) * 100

EPRC = EPR1 + EPR2

L1INI = l1p

L2INI = l2p

PRINT "lambda1="; l1p

PRINT "lambda2="; l2p

LOOP UNTIL EPRC < CONV

PRINT "LAMBDA1 DE EQUILIBRIO= "; l1p

PRINT "LAMBDA2 DE EQUILIBRIO= "; l2p

l1 = l1p

l2 = l2p

f1 = K1 * (P ^ -2) * ((0.2 - l1 + l2) * (0.3 - l1 - 2 * l2) * ((1 + 2 * l1 - 2 * l2) ^ 2)) - ((0.1 + 3 * l1) ^ 3) * (0.2 + l1 - 4 * l2)

f2 = K2 * (P ^ 2) * (((0.3 - l1 - 2 * l2) ^ 2) * ((0.2 + l1 - 4 * l2) ^ 4)) - (0.2 - l1 + l2) * ((0.2 + 3 * l2) ^ 3) * ((1 + 2 * l1 - 2 * l2) ^
2)

PRINT "La funcion f1 es igual a :"; f1

PRINT "La funcion f2 es igual a :"; f2

END
SUB LAMBDA1 (K1, P, l1, l2, CONV, l1p)

K1 = 1.1309

P = 1.2

DO

f1 = K1 * (P ^ -2) * ((0.2 - l1 + l2) * (0.3 - l1 - 2 * l2) * ((1 + 2 * l1 - 2 * l2) ^ 2)) - ((0.1 + 3 * l1) ^ 3) * (0.2 + l1 - 4 * l2)

D1 = K1 * (P ^ -2) * (1 + 2 * l1 - 2 * l2) * ((0.3 - l1 - 2 * l2) * (-6 * l1 + 6 * l2 - 0.2) - (0.2 - l1 + l2) * (1 + 2 * l1 - 2 * l2)) -


((0.1 + 3 * l1) ^ 2) * (12 * l1 - 36 * l2 + 1.9)

l1p = l1 - (f1 / D1)

EPR = ABS((l1p - l1) / l1p) * 100

l1 = l1p

LOOP UNTIL EPR < CONV

END SUB

SUB LAMBDA2 (K2, P, l1p, l2, CONV, l2p)

l1 = l1p

K2 = 10.9040

P = 1.2

DO

f2 = K2 * (P ^ 2) * (((0.3 - l1 - 2 * l2) ^ 2) * ((0.2 + l1 - 4 * l2) ^ 4)) - (0.2 - l1 + l2) * ((0.2 + 3 * l2) ^ 3) * ((1 + 2 * l1 - 2 *
l2) ^ 2)

D2 = -4 * K2 * (P ^ 2) * (0.3 - l1 - 2 * l2) * (0.2 + l1 - 4 * l2) * (((0.2 + l1 - 4 * l2) ^ 3) + 4 * ((0.3 - l1 - 2 * l2) ^ 2)) - ((0.2
+ 3 * l2) ^ 2) * (((1 + 2 * l1 - 2 * l2) ^ 2) * (-9 * l1 + 12 * l2 + 2) - 4 * (0.2 + 3 * l2) * (1 + 2 * l1 - 2 * l2))

l2p = l2 - (f2 / D2)

EPR = ABS((l2p - l2) / l2p) * 100

l2 = l2p

LOOP UNTIL EPR < CONV

END SUB

Ejercicio 1

INPUT "valor inicialde xi"; xIINI

INPUT "CRITERIO DE CONVERGENCIA (%)"; CONV

DO

XI = xIINI

xIINI = XIp

fI = (0.1919 ^ 2 * 1.4) * ((200.9079 - XI) ^ 2 * (133.9386 - 1 / 2 * XI)) - ((167.4233 + XI) ^ 2 * (669.6931 - 1 / 2 * XI))
dI = (0.1919 ^ 2 * 1.4) * ((-2) * (200.9079 - XI) * (133.9386 - 1 / 2 * XI) + (1 / 2) * (200.9079 - XI) ^ 2) - ((2) * (167.4233 +
XI) * (669.6931 - 1 / 2 * XI) + (-1 / 2) * (167.4233 + XI) ^ 2)

XIp = XI - (fI / dI)

EPRC = ABS((XIp - XI) / XIp) * 100

XI = XIp

LOOP UNTIL EPRC < CONV

PRINT "XI="; XIp

XI = XIp

fI = (0.1919 ^ 2 / 1.4 ^ -1) * ((200.9079 - XI) ^ 2 * (133.9386 - 1 / 2 * XI)) - ((167.4233 + XI) ^ 2 * (669.6931 - 1 / 2 * XI))

PRINT "La funcion fI es igual a:"; fI

END

Ejercicio 4

DECLARE SUB LAMBDA1 (K1, l1, l2, CONV, l1p)

DECLARE SUB LAMBDA2 (K2, p, l1p, l2, CONV, l2p)

INPUT "valor inicial de lambda1"; L2INI

INPUT "valor inicial de lambda2"; L2INI

INPUT "k1"; K1

INPUT "k2"; K2

INPUT "PRESION (ATM)"; p

INPUT "CRITERIO DE CONVERGENCIA (%)"; CONV

l1 = L1INI

l2 = L2INI

CLS

DO

l1 = L1INI

l2 = L2INI

LAMBDA1 K1, l1, l2, CONV, l1p

LAMBDA2 K2, p, l1p, l2, CONV, l2p

EPR1 = ABS((l1p - L1INI) / l1p) * 100

EPR2 = ABS((l2p - L2INI) / l2p) * 100

EPRC = EPR1 + EPR2

L1INI = l1p

L2INI = l2p
PRINT "lambda1="; l1p

PRINT "lambda2="; l2p

LOOP UNTIL EPRC < CONV

PRINT "LAMBDA1 DE EQUILIBRIO="; l1p

PRINT "LAMBDA2 DE EQUILIBRIO="; l2p

l1 = l1p

l2 = l2p

f1 = K1 * ((12.5 + 2 * l1 - 2 * l2) ^ 2 * (2.5 - l1 + l2) * (10 - l1 - 2 * l2)) - (3 * l1) ^ 3 * (l1 - 4 * l2)

f2 = (K2 * (l1 - l2) * (10 - l1 - l2)) - (-l2) * (3 * l1 + l2)

PRINT "la funcion f1 es igual a:"; f1

PRINT "la funcion f2 es igual a:"; f2

END

SUB LAMBDA1 (K1, l1, l2, CONV, l1p)

K1 = 1.2653

DO

f1 = K1 * ((12.5 + 2 * l1 - 2 * l2) ^ 2 * (2.5 - l1 + l2) * (10 - l1 - 2 * l2)) - (3 * l1) ^ 3 * (l1 - 4 * l2)

D3 = 4 * (12.5 + 2 * l1 - 2 * l2) * (2.5 - l1 + l2) * (10 - l1 - 2 * l2)

D4 = -1 * (12.5 + 2 * l1 - 2 * l2) ^ 2 * (10 - l1 - 2 * l2)

D5 = -1 * (12.5 + 2 * l1 - 2 * l2) ^ 2 * (2.5 - l1 + l2)

D6 = (9 * 3 * l1 * l1 - 4 * l2) + (3 * l1) ^ 3

D1 = K1 * (D3 + D4 + D5) - D6

l1p = l1 - (f1 / D1)

EPR = ABS((l1p - l1) / l1p) * 100

l1 = l1p

LOOP UNTIL EPR < CONV

END SUB

SUB LAMBDA2 (K2, p, l1p, l2, CONV, l2p)

l1 = l1p

K2 = 2.3133

DO

f2 = K2 * (10 - l1 - 2 * l2) ^ 2 * (l1 - 4 * l2) ^ 4 - ((2.5 - l1 + l2) * (3 * l2) ^ 3 * (12.5 + 2 * l1 - 2 * l2) ^ 2)

D7 = (-4) * (10 - l1 - 2 * l2) * (l1 - 4 * l2) ^ 4 + (-16) * (l1 - 4 * l2) * (10 - l1 - 2 * l2) ^ 2

D8 = (3 * l2) ^ 3 * (12.5 + 2 * l1 - 2 * l2)


D9 = (9) * (2.5 - l1 + l2) * (3 * l2) ^ 2 * (12.5 + 2 * l1 - 2 * l2) ^ 2

D10 = (-4) * (3 * l2) ^ 3 * (2.5 - l1 + l2) * (12.5 + 2 * l1 - 2 * l2)

D2 = K2 * (D7) - (D8 + D9 + D10)

l2p = l2 - (f2 / D2)

EPR = ABS((l2p - l2) / l2p) * 100

l2 = l2p

LOOP UNTIL EPR < CONV

END SUB

You might also like