Docsity

Computer Method and Civil Engineering - Lab Work | CGN 3421, Lab Reports of Civil Engineering

Toggle sidebar
bg1
CGN 3421 - Computer Methods Gurley
page 1 of 11
CGN 3421 - Computer Methods
Class web site:
www.ce.ufl.edu/~kgurl
Class text books: Recommended as a reference
‘Numerical Methods for Engineers’, Chapra and Canale
Fourth Edition, McGraw-Hill
Class software: Required purchase from Tech Hub
Mathcad 2000 (Circa labs and 200 Weil lab)
Mathcad 2001 (current version available for purchase, differences from 2000 minimal for our purposes)
Class Outline
Learn fundamentals of programming skills in general and Mathcad in particular ~ 5 or 6 weeks
Use Mathcad as a medium to investigate a variety of numerical methods of problem solving. The context
will generally be civil engineering-type problems.
A more detailed list of topics covered can be found in the syllabus, avaiable at the class web site:
www.ce.ufl.edu/~kgurl -->classes/syllabi
The Programming Process
1) Read problem statement
2) Identify given input and variable input
3) Identify required output
4) Map a path from starting point to ending point
5) Write a pseudo-code in words to describe the process
6) Solve a simple example problem by hand or calculator or spreadsheet
7) Write the Mathcad worksheet (program)
8) Test the code with the example problem from step 6, verify the result
9) Be sure to test each of the desired features of the program. Never assume the answer out is correct
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Computer Method and Civil Engineering - Lab Work | CGN 3421 and more Lab Reports Civil Engineering in PDF only on Docsity!

CGN 3421 - Computer Methods

Class web site:

www.ce.ufl.edu/~kgurl

Class text books: Recommended as a reference

‘ Numerical Methods for Engineers ’, Chapra and Canale Fourth Edition, McGraw-Hill

Class software: Required purchase from Tech Hub

Mathcad 2000 (Circa labs and 200 Weil lab) Mathcad 2001 (current version available for purchase, differences from 2000 minimal for our purposes)

Class Outline

Learn fundamentals of programming skills in general and Mathcad in particular ~ 5 or 6 weeks Use Mathcad as a medium to investigate a variety of numerical methods of problem solving. The context will generally be civil engineering-type problems.

A more detailed list of topics covered can be found in the syllabus, avaiable at the class web site: www.ce.ufl.edu/~kgurl -->classes/syllabi

The Programming Process

  1. Read problem statement
  2. Identify given input and variable input
  3. Identify required output
  4. Map a path from starting point to ending point
  5. Write a pseudo-code in words to describe the process
  6. Solve a simple example problem by hand or calculator or spreadsheet
  7. Write the Mathcad worksheet (program)
  8. Test the code with the example problem from step 6, verify the result
  9. Be sure to test each of the desired features of the program. Never assume the answer out is correct

Example: Write a program to calculate the mass of a hollow sphere. The outer diameter is 10.2, the den- sity is 1.25, the thickness is variable (the program user decides)

Apply the Programming Process :

  1. given input: diameter, density variable input: thickness
  2. output: mass
  3. Map a path:
  4. Write a pseudo-code

gather all necessary input (diameter, density, thickness) calculate outer and inner radius calculate volume of the solid material multiply volume by density to get mass display result

  1. Solve a simple example problem by hand or calculator or spreadsheet
  2. Write the Mathcad worksheet (program)

Now test the code I’ll use a calculator to run an example and compare with my results

NOTE: Mathcad knows the value of , unless it has been redefined as a new variable

Please enter a value for the thickness of the skin of the sphere

thickness := 2 These variables will remain constant

Density := 1.25 Diameter :=10.

Calculate outer and inner radius

Router Diameter 2

:=

Rinner :=Router −thickness

Volume 4 3

:= ⋅ π⋅(Router^3 −Rinner^3 )

Volume =430.

π

Let’s go to the Mathcad worksheet to play around with units...

There are some tricks to using units properly. We’ll discuss when the proper context comes up.

Programming Ingredients

The following list breaks down programming into 9 basic topics. We’ll discuss each in detail and learn them all in the next few weeks. Once we understand the basics, even the most complicated programming tasks are just the proper combination fo basic concepts.

  1. Data Types
  2. Variables / Arrays
  3. Input / Output
  4. Assignment Statements
  5. Sequential Execution
  6. Branching
  7. Loops
  8. Subprograms / functions
  9. Built in functions

Operators Order of Operations

Please enter a value for the thickness of the skin of the sphere

thickness :=2m

These variables will remain constant

Density 1.25 kg m^3

:= Diameter :=10.2m

Calculate outer and inner radius

Router Diameter 2 := Rinner :=Router −thickness

Volume 4 3

:= ⋅π ⋅(^ Router 3 −Rinner 3 ) Volume =430.859m^3

1) Data Types

Types of information that can be stored and manipulated

  • integers - whole numbers x:=
  • real - decimal numbers x:=5.
  • characters - non-numerical data (text) message:= “GO IRISH”
  • complex - real and imaginary parts x = 5 + 4i
  • logical - binary on/off switch x = 1 or 0

2) Variables / Arrays

Named locations for storing data types. We can represent quantities with whatever names we like.

CONSTANT

  • numbers and words entered explicitly

VARIABLE

  • Individual location to store a single piece of information
  • Information can be any data type
  • Stored information can be changed
  • No limit on the number of variables you can create (practically speaking)

example: x is a variable assigned the constant 5, then 15

x := 5 x := 15

what is the value of x?

Using a single array (grade) to store student grades

grade 1 := 23

grade 2 := 25

grade 3 := 18

grade=

we’ll see later why there are four values although we only entered 3 values

Array types

scalar - single piece of information (no index) x := 8

vector (1-D array)- column of information (one index)

x := Ctrl+M pick # rows and 1 column, enter values

x := 1 column, 3 rows

x 2 =

2-D array - multiple rows and columns

x := Ctrl+M pick # rows and columns, enter values

x:= 2 rows, three columns

x1,3= 9.

3) Input / Output

Input - methods of including data needed to begin or continue

  • enter as constants weight := 185
  • load from a separate saved file (excell, ascii text, and other forms can be handled in Mathcad) use the insert => component command see help -> import data
  • output from variables
  • visual display (plots and graphs) - export to M.S.Word, etc.

4) Assignment statements

Assign information to a variable using : =

  • constants x:= 14.
  • expressions x:= 14.5 - 6 + 18.0/3.
  • equations y:= 5 x:= 2. z:= (y - 1)/2 + y^3 - sin(x)
  • load or read an outside data file

Conditional loops - repeat if condition is true

Use a conditional loop when the number of times we want to run it is dependent on satisfying certain con- ditions that change as the loop iterates.

while (condition is true) instructions to be looped

e.g. while the value of mass is greaterthan 100, continually multiply mass by 0.9, and automatically stop when the value of mass falls below 100

8) Subprograms / functions

User-created smaller programs used by the main program when needed. Users can create any set of instructions that they wish to apply often, and assign that set of instructions a name. These functions do not need to appear in the same Mathcad worksheet. They can be in a different worksheet and called from the current sheet. In this manner, we can create whole suites of complicated functions, and not have to actually see them in the worksheet in which we use them.

  • breaks large problems into several smaller ones
  • Eliminates re-writing statements over and over
  • Can be accessed by any future main program
  • User can create his / her own functions
  • Mathcad has hundreds of built in functions

9) Built in Functions

built-in (comes with Mathcad) smaller programs used by main program when needed same attributes as in 8) above

mass := 200 out x( ) x (^) ←x 0.9⋅

while x > 100

x

:=

mass :=out mass( )

mass =95.

e.g. enter in several student grades and calculate the mean

mean is a built in function that calculates an average value of the data sent to it.

Operators

  • Addition
  • Subtraction
  • Multiplication / Division ^ Power ( ) Specify evaluation order

Order of Operations

( ) ^

x

3 8 9

:=

mean x( ) =6.