Вы находитесь на странице: 1из 4

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProyectoDeZ_FlujoMultifasico
{
class Program
{
static void Main(string[] args)
{

Console.WriteLine("\t Inserte los siguientes valores con el fin de obtener el


factor Z: \n");

Console.WriteLine("\n Grados API: ");


string a = Console.ReadLine();
float api = float.Parse(a);

Console.WriteLine("\n P [lb/ft^2]: ");


string p = Console.ReadLine();
float presion = float.Parse(p);

Console.WriteLine("\n Temperatura [F]: ");


string t = Console.ReadLine();
float temperatura = float.Parse(t);

Console.WriteLine("\n q0 [BPD]: ");


string qCero = Console.ReadLine();
float q0 = float.Parse(qCero);

Console.WriteLine("\n qg [BPD]: ");


string qGe = Console.ReadLine();
float qg = float.Parse(qGe);

Console.WriteLine("\n Rs [ft^3/bl]: ");


string relsolub = Console.ReadLine();
float rs = float.Parse(relsolub);

Console.WriteLine("\n Yg (Gamma del gas): ");


string Gammag = Console.ReadLine();
float Yg = float.Parse(Gammag);

Console.WriteLine("Marque 1 si se trata de un gas superficial \n Marque 2


si se trata de un gas hmedo");
string numero = Console.ReadLine();
//Dentro del switch va la variable que decide el usuario
switch (numero)
{
case "1":
double Ygd, R, Ygf, Tpc, Ppc, Tpr, Ppr, DensReducida, z;
Ygd = 0.25 + (0.02 * api)+(rs*Math.Pow(10,-6))*(0.6874-(3.5864*api));
Console.WriteLine(" El valor de Ygd es: " + Ygd);
R =qg/q0;
Console.WriteLine("El valor de R es: " + R);
Ygf =((R*Yg)-(rs*Ygd))/(R-rs);
Console.WriteLine("El valor de Ygf es: " + Ygf);
//Por tratarse de gases superficiales Tpc y Ppc
Tpc = 167 + (316.67 * Ygf);
Console.WriteLine("El valor de Tpc es: " + Tpc);
Ppc = 702.5 - (50 * Ygf);
Console.WriteLine("El valor de Ppc es: " + Ppc);
Tpr = (temperatura + 460) / Tpc;
Console.WriteLine("El valor de Tpr es: " + Tpr);
Ppr = presion / Ppc;
Console.WriteLine("El valor de Ppr es: " + Ppr);
double A1 = 0.31506, A2 = -1.0467, A3 = -0.5783, A4 = 0.5353,
A5 =-0.6123, A6=-0.10489, A7=0.68157, A8=0.68446;
double Zsupuesto = 0.5;

for(int y=1; y<100; y++)


{
DensReducida = (0.27 * Ppr) / (Zsupuesto * Tpr);
z = 1 + ((A1 + (A2 / Tpr) + (A3 / Math.Pow(Tpr, 3)))*DensReducida)
+((A4+(A5/Tpr))*Math.Pow(DensReducida,2))+
(((A5*A6)/Tpr)*((Math.Pow(DensReducida,5))))+
(((A7*Math.Pow(DensReducida,2))/Math.Pow(Tpr,3))*(1+
(A8*Math.Pow(DensReducida,2)))*Math.Exp(-A8*Math.Pow(DensReducida,2)));

if (Math.Abs(Zsupuesto - z)<=0.00001)
{
Console.WriteLine("El valor de z es: " + z);
break;
}
else
{
Zsupuesto = z;
}
y ++;
}

break;
case "2":
double iYgd, iR, iYgf, iTpc, iPpc, iTpr, iPpr, iDensReducida, iz;
iYgd = 0.25 + (0.02 * api) + (rs * Math.Pow(10, -6)) * (0.6874 - (3.5864
* api));
Console.WriteLine("El valor de Ygd es: " + iYgd);
iR = qg / q0;
Console.WriteLine("El valor de R es: " + iR);
iYgf = (((iR * Yg) - (rs * iYgd)) / (iR - rs));
Console.WriteLine("El valor de Ygf es: " + iYgf);
//Por tratarse de gases hmedos Tpc y Ppc
iTpc = 238 + (210 * iYgf);
Console.WriteLine("El valor de Tpc es: " + iTpc);
iPpc = 740 - (100 * iYgf);
Console.WriteLine("El valor de Ppc es: " + iPpc);
iTpr = (temperatura + 460) / iTpc;
Console.WriteLine("El valor de Tpr es: " + iTpr);
iPpr = presion / iPpc;
Console.WriteLine("El valor de Ppr es: " + iPpr);

double iA1 = 0.31506, iA2 = -1.0467, iA3 = -0.5783, iA4 = 0.5353,


iA5 = -0.6123, iA6 = -0.10489, iA7 = 0.68157, iA8 = 0.68446;
double iZsupuesto = 0.5;

for (int j = 1; j < 100; j++)


{
iDensReducida = (0.27 * iPpr) / (iZsupuesto * iTpr);
iz = 1 + ((iA1 + (iA2 / iTpr) + (iA3 / Math.Pow(iTpr, 3))) *
iDensReducida) + ((iA4 + (iA5 / iTpr)) * Math.Pow(iDensReducida, 2)) + (((iA5 *
iA6) / iTpr) * ((Math.Pow(iDensReducida, 5)))) + (((iA7 * Math.Pow(iDensReducida,
2)) / Math.Pow(iTpr, 3)) * (1 + (iA8 * Math.Pow(iDensReducida, 2))) * Math.Exp(-
iA8 * Math.Pow(iDensReducida, 2)));
if (Math.Abs(iZsupuesto - iz) <= 0.00000001)
{Console.WriteLine("El valor de z es: " + iz);
break; }
else
{iZsupuesto = iz; }
j++;
}
break;
default:
Console.WriteLine(" Ingres mal la opcin. Adis. ");
break;
}
Console.ReadKey();
}
}
}
Aplicacin de consola:

Вам также может понравиться