Difference between revisions of "Examples"

From ZCubes Wiki
Jump to navigation Jump to search
 
(108 intermediate revisions by the same user not shown)
Line 1: Line 1:
<div style="font-size:24px">'''Engineering Examples of Java and z3 Programs'''</div><br/>
+
<div style="font-size:24px">'''Engineering Examples in z3'''</div><br/>
 
==DESCRIPTION==
 
==DESCRIPTION==
 
*Basic Engineering examples in z3.<br>
 
*Basic Engineering examples in z3.<br>
 
*z3 codes with z3 notations are shown below.<br>
 
*z3 codes with z3 notations are shown below.<br>
*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.<br>
 
*Testing how we can make better solutions to the standard problems compared to other software, due to the presence of units.<br><br>
 
  
==Examples==
+
==Engineering Examples==
 
'''ExampleS1: Chemical Engineering<br>'''
 
'''ExampleS1: Chemical Engineering<br>'''
*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.
+
'''LengthParallelContraFlow'''<br>
 
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code1a <span style="color:blue;"> z3 code: Normal Calculation without using Function]</span><br>
 
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code1b <span style="color:blue;"> z3 code: Using Function]</span><br>
'''z3 code: Normal Calculation without using Function'''<br>
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code1c <span style="color:blue;"> z3 code: Multi-calculation Using Function(variable diameter)]</span><br>
<source lang="cpp">
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code1d <span style="color:blue;"> z3 code: USING EXAMPLE1 function SOLUTION IN EXAMPLE2 function]</span><br><br>
//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</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
 
  
 +
'''ExampleS2: Civil Engineering<br>'''
 +
'''HoopStress'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code2a <span style="color:blue;"> z3 code: Using Function]</span><br>
  
//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)
 
  
 +
'''ExampleS3: Civil Engineering<br>'''
 +
'''InternalForce'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code3a <span style="color:blue;"> z3 code: Normal Calculation without using Function]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code3b <span style="color:blue;"> z3 code: Using Function]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code3c <span style="color:blue;"> z3 code: USING EXAMPLE1 function SOLUTION IN EXAMPLE2 function]</span><br>
  
Example1(hg,hw,cpg,cpw,mg,mw)</source>
 
  
 +
'''ExampleS4: Civil Engineering<br>'''
 +
'''NotchDesign'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code4a <span style="color:blue;"> z3 code: Using Function]</span><br>
  
  
'''z3 code: USING EXAMPLE1 function SOLUTION IN EXAMPLE2 function'''<br>
+
'''ExampleS5: Engineering Economics<br>'''
<source lang="cpp">
+
'''RateOfEarnings'''<br>
function Example1(hg,hw)
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code5a <span style="color:blue;"> z3 code: Using Function]</span><br>
{
 
   
 
//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 U = 1</>((1</>hg)<+>(1</>hw))
 
                       
 
return [U]
 
  
}
+
'''ExampleS6: Fluid Mechanics<br>'''
+
'''BernoullisPressure'''<br>
hg = 300(W/m2.degK)
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code6a <span style="color:blue;"> z3 code: Using Function]</span><br>
hw = 1500(W/m2.degK)
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3code6b <span style="color:blue;"> z3 code: Multi-calculation Using Function(variable diameter)]</span><br>
  
Example1(hg,hw)</source>
 
  
<source lang="cpp">
+
==Examples of Java and z3 Programs==
function Example2(tw1,mg,mw,cpg,cpw)
+
'''ExampleR1: Check if number is Odd/Even'''<br>
{
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes1a <span style="color:blue;"> Java code]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes1b <span style="color:blue;"> z3 code]</span>
  
var tg1 = 350degC<>degK
+
'''ExampleR2: Sum of a given Array'''<br>
var tg2 = 100degC<>degK
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes2a <span style="color:blue;"> Java code]</span><br>
var delt = tg1<->tg2
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes2b <span style="color:blue;"> z3 code]</span>
  
var φ = mg<*>cpg<*>delt
+
'''ExampleR3: Linear Search'''<br>
var tw2 = tw1<+></>(mw<*>cpw))
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes3a <span style="color:blue;"> Java code]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes3b <span style="color:blue;"> z3 code]</span><br>
  
 +
'''ExampleR4: Floyd's Triangle'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes4a <span style="color:blue;"> Java code]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes4b <span style="color:blue;"> z3 code]</span><br>
  
//Parallel flow
+
'''ExampleR5: Reverse Number'''<br>
var delti = tg1<->tw1
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes5a <span style="color:blue;"> Java code]</span><br>
var delt0 = tg2<->tw2
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes5b <span style="color:blue;"> z3 code]</span><br>
var A1 = φ<*>(log(delt0</>delti))</>(Example1(hg,hw)<*>(delt0<->delti))
 
var LParallel = A1</><*>D)
 
//answer:1.48m
 
  
 +
'''ExampleR6: Calculate the Factorial of a number'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes6a <span style="color:blue;"> Java code]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes6b <span style="color:blue;"> z3 code]</span><br>
  
//Contra Flow
+
'''ExampleR7: Area of Rectangle'''<br>
delti = tg1<->tw2
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes7a <span style="color:blue;"> Java code]</span><br>
delt0 = tg2<->tw1
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes7b <span style="color:blue;"> z3 code]</span><br>
var A2 = φ<*>(log(delt0</>delti))</>(Example1(hg,hw)<*>(delt0<->delti))
 
var LContra = A2</><*>D)
 
//answer:1.44m
 
 
  
return [LParallel,LContra]
+
'''ExampleR8: Display Prime Numbers'''<br>
                 
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes8a <span style="color:blue;"> Java code]</span><br>
}
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes8b <span style="color:blue;"> z3 code]</span><br>
                 
 
  
cpg = 1130(J/kg.degK)
+
'''ExampleR9: Ascending Order'''<br>
cpw = 4190(J/kg.degK)
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes9a <span style="color:blue;"> Java code]</span><br>
mg = 200(kg/hr)
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes9b <span style="color:blue;"> z3 code]</span><br>
mw = 1400(kg/hr)
 
tw1 = 10degC<>degK               
 
                 
 
                 
 
Example2(tw1,mg,mw,cpg,cpw)</source>
 
  
 +
'''ExampleR10: Inputting Matrix and Calculating it's Inverse'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes10a <span style="color:blue;"> Java code]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes10b <span style="color:blue;"> z3 code]</span><br>
  
 +
'''ExampleR11: Inputting 2 Matrices and Calculating Sum,Difference and Product'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes11a <span style="color:blue;"> Java code]</span><br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples#z3codes11b <span style="color:blue;"> z3 code]</span><br><br>
  
 +
==Unit Conversion Examples==
 +
'''ExampleP1: FrictionFactor'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3codep1 <span style="color:blue;"> z3 code: Solution with SI units<br> Solution with SI and Imperial units<br> Solution with imperial units<br>]</span><br>
  
'''ExampleS2: Civil Engineering<br>'''
+
'''ExampleP2: ReynoldsNumber'''<br>
A steel pipe 5 ft (1.5 m) in diameter and 3/5 in. (9.53 mm) thick sustains a fluid pressure of
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3codep2 <span style="color:blue;"> z3 code: Solution with SI units<br> Solution with SI and Imperial units<br> Solution with imperial units<br>]</span><br>
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'''<br>
 
<source lang="cpp">
 
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)
+
'''ExampleP3: FouriersLaw'''<br>
var sdash = p<*>D</>(4<*>t)
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3codep3 <span style="color:blue;"> z3 code: Solution with SI units<br> Solution with SI and Imperial units<br> Solution with imperial units<br>]</span><br>
var delD = D<*>(s<->v<*>sdash)</>E
 
  
return [s,sdash,delD<>inch]
+
'''ExampleP4: MaximumHeight'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3codep4 <span style="color:blue;"> z3 code: Solution with SI units<br> Solution with SI and Imperial units<br> Solution with imperial units<br>]</span><br>
  
}
+
'''ExampleP5: DopplerEffect'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3codep5 <span style="color:blue;"> z3 code: Solution with SI units<br> Solution with SI and Imperial units<br> Solution with imperial units<br>]</span><br>
  
p = 180(lb/sqin)
+
'''ExampleP6: CircularSegmentArea'''<br>
D = 5(ft)
+
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3codep6 <span style="color:blue;"> z3 code: Solution with SI units<br> Solution with SI and Imperial units<br> Solution with imperial units<br>]</span><br>
t = (3/8)<>(inch)
 
  
civil1(p,D,t)</source>
+
'''ExampleP7: CoulombsLaw'''<br>
 +
<span class="plainlinks">[http://wiki.zcubes.com/Manuals/calci/Examples1#z3codep7 <span style="color:blue;">  z3 code: Solution with SI units<br> Solution with SI and Imperial units<br> Solution with imperial units<br>]</span><br><br>

Latest revision as of 02:44, 15 February 2018

Engineering Examples in z3


DESCRIPTION

  • Basic Engineering examples in z3.
  • z3 codes with z3 notations are shown below.

Engineering Examples

ExampleS1: Chemical Engineering
LengthParallelContraFlow
z3 code: Normal Calculation without using Function
z3 code: Using Function
z3 code: Multi-calculation Using Function(variable diameter)
z3 code: USING EXAMPLE1 function SOLUTION IN EXAMPLE2 function

ExampleS2: Civil Engineering
HoopStress
z3 code: Using Function


ExampleS3: Civil Engineering
InternalForce
z3 code: Normal Calculation without using Function
z3 code: Using Function
z3 code: USING EXAMPLE1 function SOLUTION IN EXAMPLE2 function


ExampleS4: Civil Engineering
NotchDesign
z3 code: Using Function


ExampleS5: Engineering Economics
RateOfEarnings
z3 code: Using Function


ExampleS6: Fluid Mechanics
BernoullisPressure
z3 code: Using Function
z3 code: Multi-calculation Using Function(variable diameter)


Examples of Java and z3 Programs

ExampleR1: Check if number is Odd/Even
Java code
z3 code

ExampleR2: Sum of a given Array
Java code
z3 code

ExampleR3: Linear Search
Java code
z3 code

ExampleR4: Floyd's Triangle
Java code
z3 code

ExampleR5: Reverse Number
Java code
z3 code

ExampleR6: Calculate the Factorial of a number
Java code
z3 code

ExampleR7: Area of Rectangle
Java code
z3 code

ExampleR8: Display Prime Numbers
Java code
z3 code

ExampleR9: Ascending Order
Java code
z3 code

ExampleR10: Inputting Matrix and Calculating it's Inverse
Java code
z3 code

ExampleR11: Inputting 2 Matrices and Calculating Sum,Difference and Product
Java code
z3 code

Unit Conversion Examples

ExampleP1: FrictionFactor
z3 code: Solution with SI units
Solution with SI and Imperial units
Solution with imperial units

ExampleP2: ReynoldsNumber
z3 code: Solution with SI units
Solution with SI and Imperial units
Solution with imperial units

ExampleP3: FouriersLaw
z3 code: Solution with SI units
Solution with SI and Imperial units
Solution with imperial units

ExampleP4: MaximumHeight
z3 code: Solution with SI units
Solution with SI and Imperial units
Solution with imperial units

ExampleP5: DopplerEffect
z3 code: Solution with SI units
Solution with SI and Imperial units
Solution with imperial units

ExampleP6: CircularSegmentArea
z3 code: Solution with SI units
Solution with SI and Imperial units
Solution with imperial units

ExampleP7: CoulombsLaw
z3 code: Solution with SI units
Solution with SI and Imperial units
Solution with imperial units