Difference between revisions of "Examples"

From ZCubes Wiki
Jump to navigation Jump to search
Line 205: Line 205:
  
 
civil1(p,D,t)</source>
 
civil1(p,D,t)</source>
 +
 +
 +
 +
'''ExampleS3: Civil Engineering<br>'''
 +
A 1/2-in. (12.7-mm) diameter Copperweld bar consists of a steel core 3/8 in. (9.53 mm) indiameter and a copper skin 1/16 in. (1.6 mm) thick. What is the elongation of a 1-ft (0.3-m) length of this bar, and what is the internal force between the steel and copper arising from a temperature rise of 80°F (44.4°C)? Use the following values for thermal expansion coefficients: cs = 6.5*106 and cc = 9.0*106 , where the subscripts s and c refer to steel and copper, respectively. Also, Ec = 15*106 lb/sq.in. (1.03*108 kPa).
 +
 +
'''z3 code: Normal Calculation without using Function'''<br>
 +
<source lang="cpp">
 +
dc = 12.7(mm)
 +
ds = (3/8)<>(inch)
 +
dcs = (1/16)<>(inch)
 +
Es = 30e+6(lbf/in2)
 +
Ec = 1.03e+11(Pa)
 +
cs = 6.5e-6(diffF-1)
 +
cc = 9e-6(diffF-1)
 +
L = 1(ft)
 +
delT = 44.4(diffC)
 +
 +
 +
//cross-sectional area
 +
A = π<*>(dc)^2</>4
 +
As = π<*>(ds)^2</>4
 +
Ac = A<->As
 +
   
 +
 +
//coeff of expansion
 +
//c = ((As<*>Es<*>cs)<+>(Ac<*>Ec<*>cc))</>(As<*>Es<+>Ac<*>Ec)
 +
a = (As<*>Es<*>cs)
 +
b = (Ac<*>Ec<*>cc)<>(lbf.diffF-1)
 +
d = (As<*>Es<+>Ac<*>Ec)
 +
c = (a<+>b)</>d
 +
 +
 +
//thermal expansion
 +
delL = c<*>L<*>delT
 +
 +
//expansion w.o restraint
 +
delLc = cc<*>L<*>delT
 +
delLcs = delLc<->delL
 +
delLs= cs<*>L<*>delT
 +
delLsc = delL<->delLs
 +
 +
//restraining force
 +
P1 = Ac<*>Ec<*>delLcs</>L
 +
P2 = As<*>Es<*>delLsc</>L</source>

Revision as of 05:16, 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))
U = 1</>((1</>hg)+(1</>hw))*/

x = 0  //wall very thin
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))
U = 1</>((1</>hg)+(1</>hw))*/

x = 0  //wall very thin
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)


z3 code: USING EXAMPLE1 function SOLUTION IN EXAMPLE2 function

function Example1(hg,hw)
{
    
/*Overall Heat transfer coefficient
U = 1/((1/hg)+(1/hw)+(x/k))
U = 1</>((1</>hg)+(1</>hw))*/

x = 0  //wall very thin
var U = 1</>((1</>hg)<+>(1</>hw))
                         
return [U]

}
 
hg = 300(W/m2.degK)
hw = 1500(W/m2.degK)

Example1(hg,hw)
function Example2(tw1,mg,mw,cpg,cpw)
{

var tg1 = 350degC<>degK
var tg2 = 100degC<>degK
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))</>(Example1(hg,hw)<*>(delt0<->delti))
var LParallel = A1</>(π<*>D)
//answer:1.48m


//Contra Flow
delti = tg1<->tw2
delt0 = tg2<->tw1
var A2 = φ<*>(log(delt0</>delti))</>(Example1(hg,hw)<*>(delt0<->delti))
var LContra = A2</>(π<*>D)
//answer:1.44m
 

return [LParallel,LContra]
                  
}
                  

cpg = 1130(J/kg.degK)
cpw = 4190(J/kg.degK)
mg = 200(kg/hr)
mw = 1400(kg/hr)
tw1 = 10degC<>degK                 
                  
                  
Example2(tw1,mg,mw,cpg,cpw)



ExampleS2: Civil Engineering
A steel pipe 5 ft (1.5 m) in diameter and 3/5 in. (9.53 mm) thick sustains a fluid pressure of 180 lb/sq.in. (1241.1 kPa). Determine the hoop stress, the longitudinal stress, and the increase in diameter of this pipe. Use 0.25 for Poisson’s ratio.


z3 code: Using Function

function civil1(p,D,t){
    
var E = 30e+6(lb/sqin)//for steel
var v = 0.25

/*hoop stress
s = pD/2t
longitudinal stress
s'= pD/4t
increase in cyl diameter
delD = D(s-vs')/E */

var s = p<*>D</>(2<*>t)
var sdash = p<*>D</>(4<*>t)
var delD = D<*>(s<->v<*>sdash)</>E

return [s,sdash,delD<>inch]

}

p = 180(lb/sqin)
D = 5(ft)
t = (3/8)<>(inch)

civil1(p,D,t)


ExampleS3: Civil Engineering
A 1/2-in. (12.7-mm) diameter Copperweld bar consists of a steel core 3/8 in. (9.53 mm) indiameter and a copper skin 1/16 in. (1.6 mm) thick. What is the elongation of a 1-ft (0.3-m) length of this bar, and what is the internal force between the steel and copper arising from a temperature rise of 80°F (44.4°C)? Use the following values for thermal expansion coefficients: cs = 6.5*106 and cc = 9.0*106 , where the subscripts s and c refer to steel and copper, respectively. Also, Ec = 15*106 lb/sq.in. (1.03*108 kPa).

z3 code: Normal Calculation without using Function

dc = 12.7(mm)
ds = (3/8)<>(inch)
dcs = (1/16)<>(inch)
Es = 30e+6(lbf/in2)
Ec = 1.03e+11(Pa)
cs = 6.5e-6(diffF-1)
cc = 9e-6(diffF-1)
L = 1(ft)
delT = 44.4(diffC)


//cross-sectional area
A = π<*>(dc)^2</>4
As = π<*>(ds)^2</>4
Ac = A<->As
    

//coeff of expansion
//c = ((As<*>Es<*>cs)<+>(Ac<*>Ec<*>cc))</>(As<*>Es<+>Ac<*>Ec) 
a = (As<*>Es<*>cs)
b = (Ac<*>Ec<*>cc)<>(lbf.diffF-1)
d = (As<*>Es<+>Ac<*>Ec)
c = (a<+>b)</>d


//thermal expansion
delL = c<*>L<*>delT

//expansion w.o restraint
delLc = cc<*>L<*>delT
delLcs = delLc<->delL
delLs= cs<*>L<*>delT
delLsc = delL<->delLs

//restraining force
P1 = Ac<*>Ec<*>delLcs</>L
P2 = As<*>Es<*>delLsc</>L