You are on page 1of 6

UNIVERSIDAD NACIONAL DE SAN AGUSTÍN

ESCUELA PROFESIONAL DE INGENIERÍA QUÍMICA


CURSO DE DISEÑO Y EVALUACIÓN DE PROCESOS
INFORME DE LABORATORIO 8
PROGRAMAS EN VISUAL BASIC.
Luis Felipe Miranda Z.

1. En la tabla adjunta se presentan datos correspondientes a la conductividad del dióxido de


carbono, en BTU/hr.ft.ºF, y a la viscosidad del etilen glicol, en lb/ft.hr, siendo la temperatura
expresada en grados Fahrenheit
Temp Conductividad Temp Viscosidad
32 0,085 0 242
212 0,0133 50 82,1
392 0,0181 100 30,5
572 0,0228 150 12,6
200 5,57
Para cada propiedad determine el polinomio más sencillo para interpolar. Con este polinomio,
formule un programa en Visual Basic que genere datos calculados y estime el error cometido
en cada punto. Asimismo, presente una tabla con intervalos regulares de 25 ºF partiendo
desde las temperaturas iniciales señaladas para cada caso. Genere un archivo donde registre
estos resultados y grafique en Excel los resultados.

2. En la tabla de valores siguientes algunos datos de sin(x) pueden tener errores. Elabore un
programa que calcule diferencias finitas y que a partir de los valores calculados el
programa indique qué valores son incorrectos. Este método podrá servir para filtrar datos
incorrectos en términos generales?. Justifique su respuesta.
X SIN(X)
0,2 0,19867
0,25 0,24740
0,30 0,29552
0,35 0,34920
0,40 0,38492
0,45 0,43497
0,50 0,47943
0,55 0,52269
0,60 0,56464
0,65 0,60529
0,70 0,64422
0,75 0,68164
0,80 0,72736
EJEMPLO ILUSTRATIVO
PROGRAMA QUE EMPLEA ALMACENAMIENTO DE RESULTADOS EN ARCHIVO
El archivo creado con Visual Basic puede ser abierto con Excel y los resultados graficados
mediante los utilitarios de Excel. Este programa ilustra además el uso de funciones, la
documentación al interior del programa, el uso de ciclos de cálculo y el empleo de variables
indexadas.

Public x0 As Double, y0 As Double, z0 As Double, ZStep As Single


Public x2 As Double, y2 As Double, z2 As Double
Public Nrey As Double, Cdrag As Double, DragFactor As Double, DragForce As Double

Public Sub Command1_Click()


'ELECTROSTATIC ATOMIZATION: SIMULATION MODULE
‘Luis Felipe Miranda Zanardi.
‘University of Brunel. Department of Systems Engineering. July 21st, 2001.

'Declaring variables
Dim Ntrial As Integer
Dim Zmax As Single, Xmax As Single, X1 As Double, Z1 As Double
Dim voltage As Double, current As Double, permittivity As Double, flow As Single
Dim diameter As Single, adens As Single, avisc As Single, ldens As Single
Dim vel0 As Double, Angle As Single
Dim z As Single, Veff As Single, Path As Single, charge As Single
Dim Mass As Double
Dim VelZ0 As Double, VelX0 As Double, VelX As Double, VelZ As Double, VelMod As Double
Dim potent(4) As Double

'*** INPUT INITIAL DATA


'Properties of Fluids
ldens = 789 'density of ethanol kg/m3
adens = 1.12 'density of air kg/m3
avisc = 0.0000211 'air viscosity kg/(m.s)
permittivity = 0.000000000008854 'vacuum permittivity F/m
'Operating Conditions
flow = 0.0000000003 'flow rate m3/s
curr = 0.00000013 'total current, A
voltage = 20000# 'electric potential, V
diameter = 0.000015 'diameter of droplets, m
vel0 = 15# 'initial velocity of droplets m/s
Zmax = 0.15 'distance from nozzle to target
'Simulation Conditions
Angle = 20 'Half Spray cone angle in degrees
ZStep = 0.005 'Integration step in Z coordinate
TimeStep = 0.1 'Time integration step
Ntrial = 30 'Number of elements in potential comp.
'Constants Declaration
Const pi = 3.1416
Const g = 9.81 'Acceleration of gravity m/s2
Const void = 0.65 'void fraction in packed bed of spheres
'
'***INITIAL COMPUTATIONS
'Initial calculations
Angle = Angle * pi / 180 'angle in radians
VolDrop = pi / 6 * diameter ^ 3 'volume of droplet
Mass = VolDrop * ldens 'mass of droplet
Ndrop = flow / VolDrop 'number of droplets produced per second
Veff = Ndrop * VolDrop / void 'total volume occupied by droplets
VelX0 = vel0 * Abs(Sin(Angle))
VelZ0 = vel0 * Abs(Cos(Angle))
'Computation of the Charge of the Parcel
' A parcel is a group of droplets that have the same size.
' As a first approach, before introducing size distribution of particles, it is
' assumed that all particles have the same size and charge.
' So the charge per particle is the total current divided by the number of particles N
charge = curr / Ndrop 'units are Coulombs/s divided by drops/s
UnitCharge = charge / Mass 'charge per mass of droplet
'
'CREATE A FILE TO STORE RESULTS
FileName = "A:\Modelling2.dat" & n&
Open FileName For Output As #1 ' Open file to write
Print #1, "RESULTS OF THE SIMULATION"
Print #1, 'introduces blank line
Print #1, "z0, x0, DragForce, ZSpaceChargeForce, ZExternalForce, XExternalForce,
ZTotalForce, XTotalForce, VelX, VelZ"
Print #1,
'
'INITIAL DRAG FACTOR COMPUTATIONS
Call Drag(diameter, adens, avisc, ldens, vel0, Mass)
InitVel = vel0 'Saving Initial value of velocity
InitDrag = DragFactor 'Saving the Drag Factor at initial conditions
InitDragForce = DragForce
'INITIAL EXTERNAL ELECTRIC FIELD COMPUTATIONS
' Computing boundary conditions for the external electric field
potent(0) = 0 'initial electric potential value
x0 = 0
y0 = 0
z0 = Zmax
Xmax = Zmax * Tan(Angle)
' Calling function to compute initial electrical potential at boundary??
potent(0) = Potential(Ntrial, x0, y0, z0, ZStep, Zmax, Xmax, voltage)
' Initial Values of the potential vector
For i = 1 To 3
potent(i) = 0
Next i
' Initializing value of z0 for loop computations
z0 = 0#
'STARTS LOOP TO COMPUTE MAIN VARIABLES ALONG THE Z COORDINATE
Do Until z0 > Zmax
'Computation of the DRAG FORCE
'
Call Drag(diameter, adens, avisc, ldens, VelZ0, Mass)
'
Z1 = z0 + ZStep
'Computation of the SPACE CHARGE FORCE
Path = FreePath(Angle, Veff, ZStep, Z1) 'call function to compute free path
ZSpaceChargeForce = SumCharge(Path, charge, permittivity) * UnitCharge
XSpaceChargeForce = SumCharge(Path, charge, permittivity) * UnitCharge
'
'Computation of the EXTERNAL ELECTRIC FIELD FORCE
'Inner LOOP in the X Direction
'Initial condition
x0 = 0
Xmax = Z1 * Tan(Angle)
Do Until x0 > Xmax 'Starting loop in X direction
X1 = x0 + ZStep
'Computation of electrical potential at point x(i),0,z(i)
potent(1) = Potential(Ntrial, X1, 0, Z1, ZStep, Zmax, Xmax, voltage)
'Computation of electrical potential at point x(i-1),0,z(i)
potent(2) = Potential(Ntrial, x0, 0, Z1, ZStep, Zmax, Xmax, voltage)
'Computation of electrical potential at point x(i),0,z(i-1)
potent(3) = Potential(Ntrial, X1, 0, z0, ZStep, Zmax, Xmax, voltage)
'Computing Electric Field Force
XExternalForce = (potent(2) - potent(1)) * UnitCharge / ZStep 'This is a finite divided
difference
ZExternalForce = (potent(3) - potent(1)) * UnitCharge / ZStep 'This is a finite divided
difference
'Computation of Electric Field Force is finished
'Now it is performed the computation of the TOTAL FORCE
XTotalForce = XExternalForce + XSpaceChargeForce
ZTotalForce = ZExternalForce + ZSpaceChargeForce + DragForce + g
If (z0 = 0#) And (x0 = 0#) Then
InitXTotalForce = XTotalForce 'Saving values for initial conditions
InitZTotalForce = ZTotalForce 'Saving Values for initial conditions
End If
'Computation of DROPLET VELOCITY for Transient State
'This expression is the result of integrating the equation dVel/dt -DragFactor*Vel =
TotalForce
'The Init values refer to initial conditions at t=0 and vel=vel0
'VelX = VelX0 - DragFactor * XTotalForce - InitVel / InitDrag * InitXTotalForce * Exp(-
DragFactor * Time)
'VelZ = VelZ0 - DragFactor * ZTotalForce - InitVel / InitDrag * InitZTotalForce * Exp(-
DragFactor * Time)
'Computation of Droplet Velocity for Steady State
VelX = XTotalForce / (-DragFactor) 'Velocity Component X
VelZ = ZTotalForce / (-DragFactor) 'Velocity Component Z
VelMod = Sqr(VelX * VelX + VelZ * VelZ) 'Computation of the module of velocity
'PRINTING RESULTS IN FILE
Print #1, Format(Z1, 0#), Format(X1, 0#), Format(DragForce, 0#),
Format(ZSpaceChargeForce, 0#), Format(ZExternalForce, 0#), Format(XExternalForce, 0#),
Format(ZTotalForce, 0#), Format(XTotal, 0#); Format(VelX, 0#), Format(VelZ, 0#)
x0 = X1 'Actualizing value for X
VelX0 = VelX 'Actualizing value for X velocity component
VelZ0 = VelZ 'Actualizing value for Z velocity component

'
Loop 'Closing X loop
'
'Call ElectricPotential(Ntrial, x0, y0, z0, Zstep, voltage)

z0 = Z1 'Actualizing value for Z


Loop 'Closing Z loop

'FILE OPERATIONS
Close #1 'Close File
'
Open FileName For Input As #1 ' open file to read results
Do While Not EOF(1)
Line Input #1, Filedata 'Reads a line from a file
Loop
Close #1 'close file
'
End Sub

You might also like