Difference between revisions of "Examples"

From ZCubes Wiki
Jump to navigation Jump to search
Line 50: Line 50:
 
L = A</>(π<*>D)
 
L = A</>(π<*>D)
 
//answer:1.44m</source>
 
//answer:1.44m</source>
 +
 +
 +
 +
'''z3 code: Using Function'''<br>
 +
<source lang="cpp">
 +
function Example1(hg,hw,cpg,cpw,mg,mw)
 +
{
 +
   
 +
//Overall Heat transfer coefficient
 +
//U = 1/((1/hg)+(1/hw)+(x/k))
 +
var x = 0  //wall very thin
 +
//U = 1</>((1</>hg)+(1</>hw))
 +
 +
var D = 75mm
 +
var tg1 = 350degC<>degK
 +
var tg2 = 100degC<>degK
 +
var tw1 = 10degC<>degK
 +
 +
var U = 1</>((1</>hg)<+>(1</>hw))
 +
var delt = tg1<->tg2
 +
var φ = mg<*>cpg<*>delt
 +
var tw2 = tw1<+>(φ</>(mw<*>cpw))
 +
 +
 +
//Parallel flow
 +
var delti = tg1<->tw1
 +
var delt0 = tg2<->tw2
 +
var A1 = φ<*>(log(delt0</>delti))</>(U<*>(delt0<->delti))
 +
var LParallel = A1</>(π<*>D)
 +
//answer:1.48m
 +
 +
 +
//Contra Flow
 +
delti = tg1<->tw2
 +
delt0 = tg2<->tw1
 +
var A2 = φ<*>(log(delt0</>delti))</>(U<*>(delt0<->delti))
 +
var LContra = A2</>(π<*>D)
 +
//answer:1.44m
 +
 +
return [LParallel,LContra]
 +
           
 +
}
 +
           
 +
           
 +
hg = 300(W/m2.degK)
 +
hw = 1500(W/m2.degK)
 +
cpg = 1130(J/kg.degK)
 +
cpw = 4190(J/kg.degK)
 +
mg = 200(kg/hr)
 +
mw = 1400(kg/hr)
 +
 +
 +
Example1(hg,hw,cpg,cpw,mg,mw)</source>

Revision as of 04:58, 29 January 2018

Engineering Examples of Java and z3 Programs


DESCRIPTION

  • Basic Engineering examples in z3.
  • z3 codes with z3 notations are shown below.
  • Reflecting different domains like Engineering, Statistics, Medicine, etc.
  • Set of cases that are progressively complex on units are used to show the user how it goes from simple to complex cases.
  • Testing how we can make better solutions to the standard problems compared to other software, due to the presence of units.

Examples

ExampleS1: Chemical Engineering

  • An exhaust pipe is 75mm diameter and it is cooled by surrounding it witha water jacket. The exhaust gas enters at 350C and the water enters at 10C. The surface heat transfer coefficients for the gas and water are 300 and 1500 W/m2K respectively. The wall is thin so the temperature drop due to conduction is negligible. The gasses have a mean specific heat capacity Cp of 1130 J/kgK and they must be cooled to 100C. The specific heat capacity of the water is 4190 J/kgK. The flow rate of the gas and water is 200 and 1400 kg/h respectively. Calculate the required length of pipe for parellel flow and contra flow.


z3 code: Normal Calculation without using Function

//Overall Heat transfer coefficient
//U = 1/((1/hg)+(1/hw)+(x/k))
x = 0  //wall very thin
//U = 1</>((1</>hg)+(1</>hw))

hg = 300(W/m2.degK)
hw = 1500(W/m2.degK)
cpg = 1130(J/kg.degK)
cpw = 4190(J/kg.degK)
mg = 200(kg/hr)
mw = 1400(kg/hr)
D = 75mm
tg1 = 350degC<>degK
tg2 = 100degC<>degK
tw1 = 10degC<>degK

U = 1</>((1</>hg)<+>(1</>hw))
delt = tg1<->tg2
φ = mg<*>cpg<*>delt
tw2 = tw1<+>(φ</>(mw<*>cpw))


//Parallel flow
delti = tg1<->tw1
delt0 = tg2<->tw2
A = φ<*>(log(delt0</>delti))</>(U<*>(delt0<->delti))
L = A</>(π<*>D)
//answer:1.48m


//Contra Flow
delti = tg1<->tw2
delt0 = tg2<->tw1
A = φ<*>(log(delt0</>delti))</>(U<*>(delt0<->delti))
L = A</>(π<*>D)
//answer:1.44m


z3 code: Using Function

function Example1(hg,hw,cpg,cpw,mg,mw)
{
    
//Overall Heat transfer coefficient
//U = 1/((1/hg)+(1/hw)+(x/k))
var x = 0  //wall very thin
//U = 1</>((1</>hg)+(1</>hw))

var D = 75mm
var tg1 = 350degC<>degK
var tg2 = 100degC<>degK
var tw1 = 10degC<>degK

var U = 1</>((1</>hg)<+>(1</>hw))
var delt = tg1<->tg2
var φ = mg<*>cpg<*>delt
var tw2 = tw1<+>(φ</>(mw<*>cpw))


//Parallel flow
var delti = tg1<->tw1
var delt0 = tg2<->tw2
var A1 = φ<*>(log(delt0</>delti))</>(U<*>(delt0<->delti))
var LParallel = A1</>(π<*>D)
//answer:1.48m


//Contra Flow
delti = tg1<->tw2
delt0 = tg2<->tw1
var A2 = φ<*>(log(delt0</>delti))</>(U<*>(delt0<->delti))
var LContra = A2</>(π<*>D)
//answer:1.44m
 
return [LParallel,LContra]
             
}
             
             
hg = 300(W/m2.degK)
hw = 1500(W/m2.degK)
cpg = 1130(J/kg.degK)
cpw = 4190(J/kg.degK)
mg = 200(kg/hr)
mw = 1400(kg/hr)


Example1(hg,hw,cpg,cpw,mg,mw)